From 7c3387ae3a313ae1b255c1bfdbb6f0d594a906bc Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 4 Jan 2010 22:48:36 +0000 Subject: [PATCH] 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 --- django/contrib/admin/media/js/calendar.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/django/contrib/admin/media/js/calendar.js b/django/contrib/admin/media/js/calendar.js index 9804339e1d3..c95a95db1b1 100644 --- a/django/contrib/admin/media/js/calendar.js +++ b/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++; }