Ticket #4045: admin-js.diff
File admin-js.diff, 6.9 KB (added by , 18 years ago) |
---|
-
core.js
25 25 } 26 26 } 27 27 28 function cancelEventPropagation(e) { 29 if (!e) e = window.event; 30 e.cancelBubble = true; 31 if (e.stopPropagation) e.stopPropagation(); 32 } 33 28 34 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]); 29 35 function quickElement() { 30 36 var obj = document.createElement(arguments[0]); … … 40 46 return obj; 41 47 } 42 48 49 // "a" is reference to an object 50 function removeChildren(a) { 51 while (a.hasChildNodes()) a.removeChild(a.lastChild); 52 } 53 43 54 // ---------------------------------------------------------------------------- 44 55 // Cross-browser xmlhttp object 45 56 // from http://jibbering.com/2002/4/httprequest.html -
calendar.js
2 2 calendar.js - Calendar functions by Adrian Holovaty 3 3 */ 4 4 5 function removeChildren(a) { // "a" is reference to an object6 while (a.hasChildNodes()) a.removeChild(a.lastChild);7 }8 9 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);10 function quickElement() {11 var obj = document.createElement(arguments[0]);12 if (arguments[2] != '' && arguments[2] != null) {13 var textNode = document.createTextNode(arguments[2]);14 obj.appendChild(textNode);15 }16 var len = arguments.length;17 for (var i = 3; i < len; i += 2) {18 obj.setAttribute(arguments[i], arguments[i+1]);19 }20 arguments[1].appendChild(obj);21 return obj;22 }23 24 5 // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions 25 6 var CalendarNamespace = { 26 7 monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), -
admin/ordering.js
120 120 draw(); 121 121 } 122 122 123 function addEvent(elm, evType, fn, useCapture)124 // addEvent and removeEvent125 // cross-browser event handling for IE5+, NS6 and Mozilla126 // By Scott Andrew127 {128 if (elm.addEventListener){129 elm.addEventListener(evType, fn, useCapture);130 return true;131 } else if (elm.attachEvent){132 var r = elm.attachEvent("on"+evType, fn);133 return r;134 } else {135 elm['on'+evType] = fn;136 }137 } -
admin/DateTimeShortcuts.js
6 6 calendars: [], 7 7 calendarInputs: [], 8 8 clockInputs: [], 9 dismissCalendarFunc: [], 10 dismissClockFunc: [], 9 11 calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled 10 12 calendarDivName2: 'calendarin', // name of <div> that contains calendar 11 13 calendarLinkName: 'calendarlink',// name of the link that is used to toggle … … 39 41 addClock: function(inp) { 40 42 var num = DateTimeShortcuts.clockInputs.length; 41 43 DateTimeShortcuts.clockInputs[num] = inp; 44 DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; }; 42 45 43 46 // Shortcut links (clock icon and "Now" link) 44 47 var shortcuts_span = document.createElement('span'); … … 75 78 clock_box.className = 'clockbox module'; 76 79 clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num); 77 80 document.body.appendChild(clock_box); 78 addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);81 addEvent(clock_box, 'click', cancelEventPropagation); 79 82 80 83 quickElement('h2', clock_box, gettext('Choose a time')); 81 84 time_list = quickElement('ul', clock_box, ''); … … 109 112 110 113 // Show the clock box 111 114 clock_box.style.display = 'block'; 112 addEvent( window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });115 addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]); 113 116 }, 114 117 dismissClock: function(num) { 115 118 document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none'; 116 window.onclick = null;119 removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]); 117 120 }, 118 121 handleClockQuicklink: function(num, val) { 119 122 DateTimeShortcuts.clockInputs[num].value = val; … … 122 125 // Add calendar widget to a given field. 123 126 addCalendar: function(inp) { 124 127 var num = DateTimeShortcuts.calendars.length; 125 126 128 DateTimeShortcuts.calendarInputs[num] = inp; 129 DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; }; 127 130 128 131 // Shortcut links (calendar icon and "Today" link) 129 132 var shortcuts_span = document.createElement('span'); … … 163 166 cal_box.className = 'calendarbox module'; 164 167 cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num); 165 168 document.body.appendChild(cal_box); 166 addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);169 addEvent(cal_box, 'click', cancelEventPropagation); 167 170 168 171 // next-prev links 169 172 var cal_nav = quickElement('div', cal_box, ''); … … 211 214 cal_box.style.top = findPosY(cal_link) - 75 + 'px'; 212 215 213 216 cal_box.style.display = 'block'; 214 addEvent( window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });217 addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); 215 218 }, 216 219 dismissCalendar: function(num) { 217 220 document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none'; 221 removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); 218 222 }, 219 223 drawPrev: function(num) { 220 224 DateTimeShortcuts.calendars[num].drawPreviousMonth(); … … 223 227 DateTimeShortcuts.calendars[num].drawNextMonth(); 224 228 }, 225 229 handleCalendarCallback: function(num) { 226 return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";230 return "function(y, m, d) { var d = new Date(y, m, d); DateTimeShortcuts.calendarInputs["+num+"].value = d.getISODate(); DateTimeShortcuts.dismissCalendar("+num+");}"; 227 231 }, 228 232 handleCalendarQuickLink: function(num, offset) { 229 233 var d = new Date(); 230 234 d.setDate(d.getDate() + offset) 231 235 DateTimeShortcuts.calendarInputs[num].value = d.getISODate(); 232 236 DateTimeShortcuts.dismissCalendar(num); 233 },234 cancelEventPropagation: function(e) {235 if (!e) e = window.event;236 e.cancelBubble = true;237 if (e.stopPropagation) e.stopPropagation();238 237 } 239 238 } 240 239