~ubuntu-branches/ubuntu/jaunty/python-django/jaunty-updates

« back to all changes in this revision

Viewing changes to django/contrib/admin/media/js/admin/RelatedObjectLookups.js

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2008-11-15 19:15:33 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081115191533-xbt1ut2xf4fvwtvc
Tags: 1.0.1-0ubuntu1
* New upstream release:
  - Bug fixes.

* The tests/ sub-directory appaers to have been dropped upstream, so pull
  our patch to workaround the tests and modify the rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    return text;
12
12
}
13
13
 
 
14
// IE doesn't accept periods or dashes in the window name, but the element IDs
 
15
// we use to generate popup window names may contain them, therefore we map them
 
16
// to allowed characters in a reversible way so that we can locate the correct 
 
17
// element when the popup window is dismissed.
 
18
function id_to_windowname(text) {
 
19
    text = text.replace(/\./g, '__dot__');
 
20
    text = text.replace(/\-/g, '__dash__');
 
21
    return text;
 
22
}
 
23
 
 
24
function windowname_to_id(text) {
 
25
    text = text.replace(/__dot__/g, '.');
 
26
    text = text.replace(/__dash__/g, '-');
 
27
    return text;
 
28
}
 
29
 
14
30
function showRelatedObjectLookupPopup(triggeringLink) {
15
31
    var name = triggeringLink.id.replace(/^lookup_/, '');
16
 
    // IE doesn't like periods in the window name, so convert temporarily.
17
 
    name = name.replace(/\./g, '___');
 
32
    name = id_to_windowname(name);
18
33
    var href;
19
34
    if (triggeringLink.href.search(/\?/) >= 0) {
20
35
        href = triggeringLink.href + '&pop=1';
27
42
}
28
43
 
29
44
function dismissRelatedLookupPopup(win, chosenId) {
30
 
    var name = win.name.replace(/___/g, '.');
 
45
    var name = windowname_to_id(win.name);
31
46
    var elem = document.getElementById(name);
32
47
    if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
33
48
        elem.value += ',' + chosenId;
39
54
 
40
55
function showAddAnotherPopup(triggeringLink) {
41
56
    var name = triggeringLink.id.replace(/^add_/, '');
42
 
    name = name.replace(/\./g, '___');
 
57
    name = id_to_windowname(name);
43
58
    href = triggeringLink.href
44
59
    if (href.indexOf('?') == -1) {
45
60
        href += '?_popup=1';
56
71
    // django.utils.html.escape.
57
72
    newId = html_unescape(newId);
58
73
    newRepr = html_unescape(newRepr);
59
 
    var name = win.name.replace(/___/g, '.');
 
74
    var name = windowname_to_id(win.name);
60
75
    var elem = document.getElementById(name);
61
76
    if (elem) {
62
77
        if (elem.nodeName == 'SELECT') {