Removed media.ljworld.com reference from admin_media/js/admin/DateTimeShortcuts.js

git-svn-id: http://code.djangoproject.com/svn/django/trunk@452 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-08-10 01:14:50 +00:00
parent d8f5cad47e
commit 9a6e8142b8
1 changed files with 25 additions and 27 deletions

View File

@ -9,10 +9,21 @@ var DateTimeShortcuts = {
calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
calendarDivName2: 'calendarin', // name of <div> that contains calendar
clockDivName: 'clockbox', // name of clock <div> that gets toggled
admin_media_prefix: '',
init: function() {
// Deduce admin_media_prefix by looking at the <script>s in the
// current document and finding the URL of *this* module.
var scripts = document.getElementsByTagName('script');
for (var i=0; i<scripts.length; i++) {
if (scripts[i].src.match(/DateTimeShortcuts/)) {
var idx = scripts[i].src.indexOf('js/admin/DateTimeShortcuts');
DateTimeShortcuts.admin_media_prefix = scripts[i].src.substring(0, idx);
break;
}
}
var inputs = document.getElementsByTagName('input');
for (var i=0; i<inputs.length; i++) {
for (i=0; i<inputs.length; i++) {
var inp = inputs[i];
if (inp.getAttribute('type') == 'text' && inp.className.match(/vTimeField/)) {
DateTimeShortcuts.addClock(inp);
@ -22,7 +33,6 @@ var DateTimeShortcuts = {
}
}
},
// Add clock widget to a given field
addClock: function(inp) {
var num = DateTimeShortcuts.clockInputs.length;
@ -36,7 +46,7 @@ var DateTimeShortcuts = {
now_link.appendChild(document.createTextNode('Now'));
var clock_link = document.createElement('a');
clock_link.setAttribute('href', 'javascript:DateTimeShortcuts.openClock(' + num + ');');
quickElement('img', clock_link, '', 'src', 'http://media.ljworld.com/img/admin/icon_clock.gif', 'alt', 'Clock');
quickElement('img', clock_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_clock.gif', 'alt', 'Clock');
shortcuts_span.appendChild(document.createTextNode('\240'));
shortcuts_span.appendChild(now_link);
shortcuts_span.appendChild(document.createTextNode('\240|\240'));
@ -76,22 +86,18 @@ var DateTimeShortcuts = {
cancel_p = quickElement('p', clock_box, '', 'class', 'calendar-cancel');
quickElement('a', cancel_p, 'Cancel', 'href', 'javascript:DateTimeShortcuts.dismissClock(' + num + ');');
},
openClock: function(num) {
document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'block';
addEvent(window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
},
dismissClock: function(num) {
document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
window.onclick = null;
},
handleClockQuicklink: function(num, val) {
DateTimeShortcuts.clockInputs[num].value = val;
DateTimeShortcuts.dismissClock(num);
},
// Add calendar widget to a given field.
addCalendar: function(inp) {
var num = DateTimeShortcuts.calendars.length;
@ -106,7 +112,7 @@ var DateTimeShortcuts = {
today_link.appendChild(document.createTextNode('Today'));
var cal_link = document.createElement('a');
cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');');
quickElement('img', cal_link, '', 'src', 'http://media.ljworld.com/img/admin/icon_calendar.gif', 'alt', 'Calendar');
quickElement('img', cal_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_calendar.gif', 'alt', 'Calendar');
shortcuts_span.appendChild(document.createTextNode('\240'));
shortcuts_span.appendChild(today_link);
shortcuts_span.appendChild(document.createTextNode('\240|\240'));
@ -163,41 +169,33 @@ var DateTimeShortcuts = {
var cancel_p = quickElement('p', cal_box, '', 'class', 'calendar-cancel');
quickElement('a', cancel_p, 'Cancel', 'href', 'javascript:DateTimeShortcuts.dismissCalendar(' + num + ');');
},
openCalendar: function(num) {
document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'block';
addEvent(window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
},
dismissCalendar: function(num) {
document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
},
drawPrev: function(num) {
DateTimeShortcuts.calendars[num].drawPreviousMonth();
},
drawNext: function(num) {
DateTimeShortcuts.calendars[num].drawNextMonth();
},
handleCalendarCallback: function(num) {
return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";
},
handleCalendarQuickLink: function(num, offset) {
var d = new Date();
d.setDate(d.getDate() + offset)
DateTimeShortcuts.calendarInputs[num].value = d.getISODate();
DateTimeShortcuts.dismissCalendar(num);
},
cancelEventPropagation: function(e) {
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
}
addEvent(window, 'load', DateTimeShortcuts.init);