Django

Code

Changeset 9403

Show
Ignore:
Timestamp:
11/12/08 10:23:04 (2 months ago)
Author:
kmtracey
Message:

Fixed #106 -- Refrain from generating popup window names that IE refuses to pop up. Thanks for the reports and initial patches nbstrite and jsmullyan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/media/js/admin/RelatedObjectLookups.js

    r7967 r9403  
    1212} 
    1313 
     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. 
     18function id_to_windowname(text) { 
     19    text = text.replace(/\./g, '__dot__'); 
     20    text = text.replace(/\-/g, '__dash__'); 
     21    return text; 
     22} 
     23 
     24function windowname_to_id(text) { 
     25    text = text.replace(/__dot__/g, '.'); 
     26    text = text.replace(/__dash__/g, '-'); 
     27    return text; 
     28} 
     29 
    1430function showRelatedObjectLookupPopup(triggeringLink) { 
    1531    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); 
    1833    var href; 
    1934    if (triggeringLink.href.search(/\?/) >= 0) { 
     
    2843 
    2944function dismissRelatedLookupPopup(win, chosenId) { 
    30     var name = win.name.replace(/___/g, '.'); 
     45    var name = windowname_to_id(win.name); 
    3146    var elem = document.getElementById(name); 
    3247    if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { 
     
    4055function showAddAnotherPopup(triggeringLink) { 
    4156    var name = triggeringLink.id.replace(/^add_/, ''); 
    42     name = name.replace(/\./g, '___'); 
     57    name = id_to_windowname(name); 
    4358    href = triggeringLink.href 
    4459    if (href.indexOf('?') == -1) { 
     
    5772    newId = html_unescape(newId); 
    5873    newRepr = html_unescape(newRepr); 
    59     var name = win.name.replace(/___/g, '.'); 
     74    var name = windowname_to_id(win.name); 
    6075    var elem = document.getElementById(name); 
    6176    if (elem) {