mirror of https://github.com/django/django.git
Removed admin_media/js/admin/add_calendars.js -- it wasn't being used
git-svn-id: http://code.djangoproject.com/svn/django/trunk@449 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e2426e68e6
commit
65f7e142e4
|
@ -1,95 +0,0 @@
|
|||
// Finds all <input type="text" class="vDateField"> and inserts a calendar after them
|
||||
|
||||
var AddCal = {
|
||||
cals: [],
|
||||
inps: [],
|
||||
divname1: 'calendarbox', // name of <div> that gets toggled
|
||||
divname2: 'calendarin', // name of <div> that contains calendar
|
||||
init: function() {
|
||||
var inputs = document.getElementsByTagName('input');
|
||||
for (var i=0; i < inputs.length; i++) {
|
||||
var inp = inputs[i];
|
||||
if (inp.getAttribute('type') == 'text' && inp.className.match(/vDateField/)) {
|
||||
var num = AddCal.cals.length;
|
||||
|
||||
AddCal.inps[num] = inp;
|
||||
|
||||
// <a href="javascript:AddCal.toggle()">Calendar</a>
|
||||
var cal_link = document.createElement('a');
|
||||
cal_link.setAttribute('href', 'javascript:AddCal.toggle(' + num + ');');
|
||||
quickElement('img', cal_link, '', 'src', 'http://media.ljworld.com/img/admin/icon_calendar.gif', 'alt', 'Calendar');
|
||||
inp.parentNode.insertBefore(cal_link, inp.nextSibling);
|
||||
|
||||
// Markup looks like:
|
||||
//
|
||||
// <div id="calendarbox3" class="calendarbox module">
|
||||
// <h2>
|
||||
// <a href="#" class="link-previous">‹</a>
|
||||
// <a href="#" class="link-next">›</a> February 2003
|
||||
// </h2>
|
||||
// <div class="calendar" id="calendarin3">
|
||||
// <!-- (cal) -->
|
||||
// </div>
|
||||
// <div class="calendar-shortcuts">
|
||||
// <a href="#">Yesterday</a> | <a href="#">Today</a> | <a href="#">Tomorrow</a>
|
||||
// </div>
|
||||
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
||||
// </div>
|
||||
var cal_box = document.createElement('div');
|
||||
cal_box.style.display = 'none';
|
||||
cal_box.style.position = 'absolute';
|
||||
cal_box.style.left = findPosX(cal_link) + 17 + 'px';
|
||||
cal_box.style.top = findPosY(cal_link) - 75 + 'px';
|
||||
cal_box.className = 'calendarbox module';
|
||||
cal_box.setAttribute('id', AddCal.divname1 + num);
|
||||
|
||||
// next-prev links
|
||||
var cal_nav = quickElement('div', cal_box, '');
|
||||
quickElement('a', cal_nav, '<', 'class', 'calendarnav-previous', 'href', 'javascript:AddCal.drawPrev('+num+');');
|
||||
quickElement('a', cal_nav, '>', 'class', 'calendarnav-next', 'href', 'javascript:AddCal.drawNext('+num+');');
|
||||
cal_box.appendChild(cal_nav);
|
||||
|
||||
// main box
|
||||
var cal_main = quickElement('div', cal_box, '', 'id', AddCal.divname2 + num);
|
||||
cal_main.className = 'calendar';
|
||||
document.body.appendChild(cal_box);
|
||||
AddCal.cals[num] = new Calendar(AddCal.divname2 + num, AddCal.handleCallback(num));
|
||||
AddCal.cals[num].drawCurrent();
|
||||
|
||||
// calendar shortcuts
|
||||
var shortcuts = quickElement('div', cal_box, '', 'class', 'calendar-shortcuts');
|
||||
quickElement('a', shortcuts, 'Yesterday', 'href', 'javascript:AddCal.handleQuickLink(' + num + ', -1);');
|
||||
shortcuts.appendChild(document.createTextNode('\240|\240'));
|
||||
quickElement('a', shortcuts, 'Today', 'href', 'javascript:AddCal.handleQuickLink(' + num + ', 0);');
|
||||
shortcuts.appendChild(document.createTextNode('\240|\240'));
|
||||
quickElement('a', shortcuts, 'Tomorrow', 'href', 'javascript:AddCal.handleQuickLink(' + num + ', +1);');
|
||||
|
||||
// cancel bar
|
||||
var cancel_p = quickElement('p', cal_box, '', 'class', 'calendar-cancel');
|
||||
quickElement('a', cancel_p, 'Cancel', 'href', 'javascript:AddCal.toggle(' + num + ');');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
toggle: function(num) {
|
||||
var box = document.getElementById(AddCal.divname1+num);
|
||||
box.style.display = (box.style.display == 'none') ? 'block' : 'none';
|
||||
},
|
||||
drawPrev: function(num) {
|
||||
AddCal.cals[num].drawPreviousMonth();
|
||||
},
|
||||
drawNext: function(num) {
|
||||
AddCal.cals[num].drawNextMonth();
|
||||
},
|
||||
handleCallback: function(num) {
|
||||
return "function(y, m, d) { AddCal.inps["+num+"].value = y+'-'+m+'-'+d; document.getElementById(AddCal.divname1+"+num+").style.display='none';}";
|
||||
},
|
||||
handleQuickLink: function(num, offset) {
|
||||
var d = new Date();
|
||||
d.setDate(d.getDate() + offset)
|
||||
AddCal.inps[num].value = d.getISODate();
|
||||
AddCal.toggle(num);
|
||||
}
|
||||
}
|
||||
addEvent(window, 'load', AddCal.init);
|
Loading…
Reference in New Issue