Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moved cancelEventPropagation into core.js

The cancelEventPropagation function is a general utility function that
can be reused by other widgets. Refs #4120.
  • Loading branch information...
commit 0a9ea56056ee4a7ded265dc56fff309c906473d1 1 parent d5824ef
Andrew Jesaitis authored March 22, 2013 claudep committed March 25, 2013
9  django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
@@ -76,7 +76,7 @@ var DateTimeShortcuts = {
76 76
         clock_box.className = 'clockbox module';
77 77
         clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
78 78
         document.body.appendChild(clock_box);
79  
-        addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);
  79
+        addEvent(clock_box, 'click', cancelEventPropagation);
80 80
 
81 81
         quickElement('h2', clock_box, gettext('Choose a time'));
82 82
         var time_list = quickElement('ul', clock_box, '');
@@ -174,7 +174,7 @@ var DateTimeShortcuts = {
174 174
         cal_box.className = 'calendarbox module';
175 175
         cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
176 176
         document.body.appendChild(cal_box);
177  
-        addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);
  177
+        addEvent(cal_box, 'click', cancelEventPropagation);
178 178
 
179 179
         // next-prev links
180 180
         var cal_nav = quickElement('div', cal_box, '');
@@ -277,11 +277,6 @@ var DateTimeShortcuts = {
277 277
        DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
278 278
        DateTimeShortcuts.calendarInputs[num].focus();
279 279
        DateTimeShortcuts.dismissCalendar(num);
280  
-    },
281  
-    cancelEventPropagation: function(e) {
282  
-        if (!e) e = window.event;
283  
-        e.cancelBubble = true;
284  
-        if (e.stopPropagation) e.stopPropagation();
285 280
     }
286 281
 }
287 282
 
6  django/contrib/admin/static/admin/js/core.js
@@ -29,6 +29,12 @@ function removeEvent(obj, evType, fn) {
29 29
     }
30 30
 }
31 31
 
  32
+function cancelEventPropagation(e) {
  33
+    if (!e) e = window.event;
  34
+    e.cancelBubble = true;
  35
+    if (e.stopPropagation) e.stopPropagation();
  36
+}
  37
+
32 38
 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
33 39
 function quickElement() {
34 40
     var obj = document.createElement(arguments[0]);

0 notes on commit 0a9ea56

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