~loco-django-dev/loco-django/trunk

« back to all changes in this revision

Viewing changes to locodjango/templates/default/media/js/admin/RelatedObjectLookups.js

  • Committer: NerdyNick
  • Date: 2007-10-26 04:52:01 UTC
  • Revision ID: nerdynick@gmail.com-20071026045201-4hrnxmnpddf46s63
Improved the Navigation system
        Now supports categories
        PageCategory 1 is the default menu system
        The first page in the default menu is the default page for the website
        A RequestContext variable has been added containing a dictionary of all categories and there pages
                Check locodjango.navigation.views.siteMenu for an example of how to push it into your template
                Check /template/default/sitemenu.htm for example usage of the links dictionary in a template
                Note: You will need to follow the same render_to_string shortcut for all views in order to keep you navigation on all pages
OpenID support has been started
Default template media has been included into the /template/default/media folder.
        A Symbolic link or apache virtual directory will need to be added to your apache root directory for the site

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Handles related-objects functionality: lookup link for raw_id_admin=True
 
2
// and Add Another links.
 
3
 
 
4
function showRelatedObjectLookupPopup(triggeringLink) {
 
5
    var name = triggeringLink.id.replace(/^lookup_/, '');
 
6
    // IE doesn't like periods in the window name, so convert temporarily.
 
7
    name = name.replace(/\./g, '___');
 
8
    var href;
 
9
    if (triggeringLink.href.search(/\?/) >= 0) {
 
10
        href = triggeringLink.href + '&pop=1';
 
11
    } else {
 
12
        href = triggeringLink.href + '?pop=1';
 
13
    }
 
14
    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
 
15
    win.focus();
 
16
    return false;
 
17
}
 
18
 
 
19
function dismissRelatedLookupPopup(win, chosenId) {
 
20
    var name = win.name.replace(/___/g, '.');
 
21
    var elem = document.getElementById(name);
 
22
    if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) {
 
23
        elem.value += ',' + chosenId;
 
24
    } else {
 
25
        document.getElementById(name).value = chosenId;
 
26
    }
 
27
    win.close();
 
28
}
 
29
 
 
30
function showAddAnotherPopup(triggeringLink) {
 
31
    var name = triggeringLink.id.replace(/^add_/, '');
 
32
    name = name.replace(/\./g, '___');
 
33
    href = triggeringLink.href
 
34
    if (href.indexOf('?') == -1) {
 
35
        href += '?_popup=1';
 
36
    } else {
 
37
        href  += '&_popup=1';
 
38
    }
 
39
    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
 
40
    win.focus();
 
41
    return false;
 
42
}
 
43
 
 
44
function dismissAddAnotherPopup(win, newId, newRepr) {
 
45
    var name = win.name.replace(/___/g, '.');
 
46
    var elem = document.getElementById(name);
 
47
    if (elem) {
 
48
        if (elem.nodeName == 'SELECT') {
 
49
            var o = new Option(newRepr, newId);
 
50
            elem.options[elem.options.length] = o;
 
51
            o.selected = true;
 
52
        } else if (elem.nodeName == 'INPUT') {
 
53
            elem.value = newId;
 
54
        }
 
55
    } else {
 
56
        var toId = name + "_to";
 
57
        elem = document.getElementById(toId);
 
58
        var o = new Option(newRepr, newId);
 
59
        SelectBox.add_to_cache(toId, o);
 
60
        SelectBox.redisplay(toId);
 
61
    }
 
62
    win.close();
 
63
}