Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes for Ticket 4045 #989

Closed
wants to merge 2 commits into from

2 participants

@andrewjesaitis

This is the remaining piece of the patch for ticket 4045. All we are doing is using the core.js removeEvent function to unbind the dismissClock and dismissCalendar functions from the click event. Trac Ticket

andrewjesaitis added some commits
@andrewjesaitis andrewjesaitis Explicitly removes dismissClock
Uses the removeEvent function in core.js to remove the function from
the document click event.
b7196a0
@andrewjesaitis andrewjesaitis Explicitly removes dismissCalendar
Uses the removeEvent function in core.js to remove the dismissCalendar
function from the document click event.
6f57ae0
@claudep
Collaborator

Thanks, pushed in 4509a1b and 5ab66de

@claudep claudep closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @andrewjesaitis

    Explicitly removes dismissClock

    andrewjesaitis authored
    Uses the removeEvent function in core.js to remove the function from
    the document click event.
  2. @andrewjesaitis

    Explicitly removes dismissCalendar

    andrewjesaitis authored
    Uses the removeEvent function in core.js to remove the dismissCalendar
    function from the document click event.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 5 deletions.
  1. +9 −5 django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
View
14 django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
@@ -6,6 +6,8 @@ var DateTimeShortcuts = {
calendars: [],
calendarInputs: [],
clockInputs: [],
+ dismissClockFunc: [],
+ dismissCalendarFunc: [],
calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
calendarDivName2: 'calendarin', // name of <div> that contains calendar
calendarLinkName: 'calendarlink',// name of the link that is used to toggle
@@ -39,7 +41,8 @@ var DateTimeShortcuts = {
addClock: function(inp) {
var num = DateTimeShortcuts.clockInputs.length;
DateTimeShortcuts.clockInputs[num] = inp;
-
+ DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
+
// Shortcut links (clock icon and "Now" link)
var shortcuts_span = document.createElement('span');
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
@@ -118,11 +121,11 @@ var DateTimeShortcuts = {
// Show the clock box
clock_box.style.display = 'block';
- addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
+ addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
},
dismissClock: function(num) {
document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
- window.document.onclick = null;
+ removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
},
handleClockQuicklink: function(num, val) {
DateTimeShortcuts.clockInputs[num].value = val;
@@ -134,6 +137,7 @@ var DateTimeShortcuts = {
var num = DateTimeShortcuts.calendars.length;
DateTimeShortcuts.calendarInputs[num] = inp;
+ DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
// Shortcut links (calendar icon and "Today" link)
var shortcuts_span = document.createElement('span');
@@ -241,11 +245,11 @@ var DateTimeShortcuts = {
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
cal_box.style.display = 'block';
- addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
+ addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
},
dismissCalendar: function(num) {
document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
- window.document.onclick = null;
+ removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
},
drawPrev: function(num) {
DateTimeShortcuts.calendars[num].drawPreviousMonth();
Something went wrong with that request. Please try again.