Ticket #9784: 9784.2.diff
File 9784.2.diff, 6.0 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/media/js/core.js
29 29 } 30 30 } 31 31 32 function fireEvent(obj, evType) { 33 if(document.createEvent) { 34 var evObj = document.createEvent('HTMLEvents'); 35 evObj.initEvent(evType, true, false); 36 obj.dispatchEvent(evObj); 37 } 38 else if(document.createEventObject) { 39 obj.fireEvent('on' + evType); 40 } 41 } 42 43 function hasClass(obj, className) { 44 return !!className && obj.className.indexOf(className) > -1 45 } 46 32 47 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]); 33 48 function quickElement() { 34 49 var obj = document.createElement(arguments[0]); -
django/contrib/admin/media/js/admin/DateTimeShortcuts.js
116 116 window.document.onclick = null; 117 117 }, 118 118 handleClockQuicklink: function(num, val) { 119 DateTimeShortcuts.clockInputs[num].value = val; 120 DateTimeShortcuts.dismissClock(num); 119 var elem = DateTimeShortcuts.clockInputs[num]; 120 elem.value = val; 121 fireEvent(elem, 'keyup'); 122 DateTimeShortcuts.dismissClock(num); 121 123 }, 122 124 // Add calendar widget to a given field. 123 125 addCalendar: function(inp) { … … 237 239 DateTimeShortcuts.calendars[num].drawNextMonth(); 238 240 }, 239 241 handleCalendarCallback: function(num) { 240 return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+(m<10?'0':'')+m+'-'+(d<10?'0':'')+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";242 return "function(y, m, d) { var elem = DateTimeShortcuts.calendarInputs[" + num + "]; elem.value = y+'-'+(m<10?'0':'')+m+'-'+(d<10?'0':'')+d; document.getElementById(DateTimeShortcuts.calendarDivName1+" + num + ").style.display='none'; fireEvent(elem, 'keyup');}"; 241 243 }, 242 244 handleCalendarQuickLink: function(num, offset) { 243 245 var d = new Date(); 244 d.setDate(d.getDate() + offset) 245 DateTimeShortcuts.calendarInputs[num].value = d.getISODate(); 246 d.setDate(d.getDate() + offset); 247 var elem = DateTimeShortcuts.calendarInputs[num]; 248 elem.value = d.getISODate(); 249 fireEvent(elem, 'keyup'); 246 250 DateTimeShortcuts.dismissCalendar(num); 247 251 }, 248 252 cancelEventPropagation: function(e) { -
django/contrib/admin/templates/admin/prepopulated_fields_js.html
1 {% autoescape off %} 1 2 <script type="text/javascript"> 2 3 {% for field in prepopulated_fields %} 3 4 document.getElementById("{{ field.field.auto_id }}").onchange = function() { this._changed = true; }; … … 2 3 {% for dependency in field.dependencies %} 3 document.getElementById("{{ dependency.auto_id }}").onkeyup = function() { 4 var e = document.getElementById("{{ field.field.auto_id }}"); 5 if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById("{{ innerdep.auto_id }}").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}); } 6 } 4 {% if dependency.field.widget.widgets %} 5 {% comment %} widget is a MultiWidget {% endcomment %} 6 {% for widget in dependency.field.widget.widgets %} 7 document.getElementById("{{ dependency.auto_id }}_{{ forloop.counter0 }}").onkeyup = function() { 8 var e = document.getElementById("{{ field.field.auto_id }}"); 9 if (!e._changed) { 10 var value = ''; 11 var inputs = []; 12 {% for innerdep in field.dependencies %} 13 {% if innerdep.field.widget.widgets %} 14 inputs = inputs.concat({% for widget in innerdep.field.widget.widgets %}"{{ innerdep.auto_id }}_{{ forloop.counter0 }}"{% if not forloop.last %}, {% endif %}{% endfor %}); 15 {% else %} 16 inputs.push("{{ innerdep.auto_id }}"); 17 {% endif %} 18 {% endfor %} 19 for (var i = 0; i < inputs.length; i++) { 20 var elem = document.getElementById(inputs[i]); 21 if (hasClass(elem, 'vTimeField')) { 22 value += elem.value.replace(/:/g, "-"); 23 } else { 24 value += elem.value; 25 } 26 if (i != (inputs.length - 1)) { 27 value += " "; 28 } 29 } 30 e.value = URLify(value, {{ field.field.field.max_length|default_if_none:"50" }}); 31 } 32 } 33 {% endfor %} 34 {% else %} 35 document.getElementById("{{ dependency.auto_id }}").onkeyup = function() { 36 var e = document.getElementById("{{ field.field.auto_id }}"); 37 if (!e._changed) { 38 e.value = URLify({% for innerdep in field.dependencies %}document.getElementById("{{ innerdep.auto_id }}").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}); 39 } 40 } 41 {% endif %} 7 42 {% endfor %} 8 43 {% endfor %} 9 44 </script> 45 {% endautoescape %} 46 No newline at end of file