Code

Ticket #106: patch.diff

File patch.diff, 1.9 KB (added by nbstrite, 6 years ago)

This patch fixes the issue that dashes and dots cause for IE6+

Line 
1Index: django/contrib/admin/media/js/admin/RelatedObjectLookups.js
2===================================================================
3--- django/contrib/admin/media/js/admin/RelatedObjectLookups.js (revision 9368)
4+++ django/contrib/admin/media/js/admin/RelatedObjectLookups.js (working copy)
5@@ -13,8 +13,9 @@
6 
7 function showRelatedObjectLookupPopup(triggeringLink) {
8     var name = triggeringLink.id.replace(/^lookup_/, '');
9-    // IE doesn't like periods in the window name, so convert temporarily.
10-    name = name.replace(/\./g, '___');
11+    // IE doesn't like periods or dashes in the window name, so convert temporarily.
12+    name = name.replace(/\./g, '___dot___');
13+    name = name.replace(/\-/g, '___dash___');
14     var href;
15     if (triggeringLink.href.search(/\?/) >= 0) {
16         href = triggeringLink.href + '&pop=1';
17@@ -27,7 +28,8 @@
18 }
19 
20 function dismissRelatedLookupPopup(win, chosenId) {
21-    var name = win.name.replace(/___/g, '.');
22+    var name = win.name.replace(/___dot___/g, '.');
23+    name = name.replace(/___dash___/g, '-');
24     var elem = document.getElementById(name);
25     if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
26         elem.value += ',' + chosenId;
27@@ -39,7 +41,8 @@
28 
29 function showAddAnotherPopup(triggeringLink) {
30     var name = triggeringLink.id.replace(/^add_/, '');
31-    name = name.replace(/\./g, '___');
32+    name = name.replace(/\./g, '___dot___');
33+    name = name.replace(/\-/g, '___dash___');
34     href = triggeringLink.href
35     if (href.indexOf('?') == -1) {
36         href += '?_popup=1';
37@@ -56,7 +59,8 @@
38     // django.utils.html.escape.
39     newId = html_unescape(newId);
40     newRepr = html_unescape(newRepr);
41-    var name = win.name.replace(/___/g, '.');
42+    var name = win.name.replace(/___dot___/g, '.');
43+    name = name.replace(/___dash___/g, '-');
44     var elem = document.getElementById(name);
45     if (elem) {
46         if (elem.nodeName == 'SELECT') {