Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #11314 - Highlight the current date in the admin calendar widget.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12089 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7c3387ae3a313ae1b255c1bfdbb6f0d594a906bc 1 parent b59d621
@jezdez jezdez authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 django/contrib/admin/media/js/calendar.js
View
14 django/contrib/admin/media/js/calendar.js
@@ -46,6 +46,12 @@ var CalendarNamespace = {
return days;
},
draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
+ var today = new Date();
+ var todayDay = today.getDate();
+ var todayMonth = today.getMonth()+1;
+ var todayYear = today.getFullYear();
+ var todayClass = '';
+
month = parseInt(month);
year = parseInt(year);
var calDiv = document.getElementById(div_id);
@@ -76,7 +82,13 @@ var CalendarNamespace = {
if (i%7 == 0 && currentDay != 1) {
tableRow = quickElement('tr', tableBody);
}
- var cell = quickElement('td', tableRow, '');
+ if ((currentDay==todayDay) && (month==todayMonth) && (year==todayYear)) {
+ todayClass='today';
+ } else {
+ todayClass='';
+ }
+ var cell = quickElement('td', tableRow, '', 'class', todayClass);
+
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
currentDay++;
}
Please sign in to comment.
Something went wrong with that request. Please try again.