Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Explicitly removes dismissClock

Uses the removeEvent function in core.js to remove the function from
the document click event.
Refs #4045.
  • Loading branch information...
commit 4509a1be1f1164164c2b654d1e3e4169ef71b5ae 1 parent 216580e
Andrew Jesaitis authored March 27, 2013 claudep committed April 06, 2013
6  django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
@@ -6,6 +6,7 @@ var DateTimeShortcuts = {
6 6
     calendars: [],
7 7
     calendarInputs: [],
8 8
     clockInputs: [],
  9
+    dismissClockFunc: [],
9 10
     calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
10 11
     calendarDivName2: 'calendarin',  // name of <div> that contains calendar
11 12
     calendarLinkName: 'calendarlink',// name of the link that is used to toggle
@@ -39,6 +40,7 @@ var DateTimeShortcuts = {
39 40
     addClock: function(inp) {
40 41
         var num = DateTimeShortcuts.clockInputs.length;
41 42
         DateTimeShortcuts.clockInputs[num] = inp;
  43
+        DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
42 44
 
43 45
         // Shortcut links (clock icon and "Now" link)
44 46
         var shortcuts_span = document.createElement('span');
@@ -118,11 +120,11 @@ var DateTimeShortcuts = {
118 120
 
119 121
         // Show the clock box
120 122
         clock_box.style.display = 'block';
121  
-        addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
  123
+        addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
122 124
     },
123 125
     dismissClock: function(num) {
124 126
        document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
125  
-       window.document.onclick = null;
  127
+       removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
126 128
     },
127 129
     handleClockQuicklink: function(num, val) {
128 130
        DateTimeShortcuts.clockInputs[num].value = val;

0 notes on commit 4509a1b

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