Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Explicitly removes dismissCalendar

Uses the removeEvent function in core.js to remove the dismissCalendar
function from the document click event.
Fixes #4045.
  • Loading branch information...
commit 5ab66dea50eab6625e3a07b71342268432e9cfaf 1 parent 4509a1b
Andrew Jesaitis authored March 27, 2013 claudep committed April 06, 2013
6  django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
@@ -7,6 +7,7 @@ var DateTimeShortcuts = {
7 7
     calendarInputs: [],
8 8
     clockInputs: [],
9 9
     dismissClockFunc: [],
  10
+    dismissCalendarFunc: [],
10 11
     calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
11 12
     calendarDivName2: 'calendarin',  // name of <div> that contains calendar
12 13
     calendarLinkName: 'calendarlink',// name of the link that is used to toggle
@@ -136,6 +137,7 @@ var DateTimeShortcuts = {
136 137
         var num = DateTimeShortcuts.calendars.length;
137 138
 
138 139
         DateTimeShortcuts.calendarInputs[num] = inp;
  140
+        DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
139 141
 
140 142
         // Shortcut links (calendar icon and "Today" link)
141 143
         var shortcuts_span = document.createElement('span');
@@ -243,11 +245,11 @@ var DateTimeShortcuts = {
243 245
         cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
244 246
 
245 247
         cal_box.style.display = 'block';
246  
-        addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
  248
+        addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
247 249
     },
248 250
     dismissCalendar: function(num) {
249 251
         document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
250  
-        window.document.onclick = null;
  252
+        removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
251 253
     },
252 254
     drawPrev: function(num) {
253 255
         DateTimeShortcuts.calendars[num].drawPreviousMonth();

0 notes on commit 5ab66de

Please sign in to comment.
Something went wrong with that request. Please try again.