Ticket #11314: CalUsability.diff

File CalUsability.diff, 1.3 KB (added by latentflip, 15 years ago)

Adds Today's date highlighting to admin calendar widget

  • django/contrib/admin/media/js/calendar.js

     
    4545        return days;
    4646    },
    4747    draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
     48        var today = new Date();
     49        var todayDay = today.getDate();
     50        var todayMonth = today.getMonth()+1;
     51        var todayYear = today.getFullYear();
     52        var todayClass = '';
     53       
    4854        month = parseInt(month);
    4955        year = parseInt(year);
    5056        var calDiv = document.getElementById(div_id);
     
    7581            if (i%7 == 0 && currentDay != 1) {
    7682                tableRow = quickElement('tr', tableBody);
    7783            }
    78             var cell = quickElement('td', tableRow, '');
     84            if ((currentDay==todayDay) && (month==todayMonth) && (year==todayYear)) {
     85                todayClass='today';
     86            } else {
     87                todayClass='';
     88            }
     89            var cell = quickElement('td', tableRow, '', 'class', todayClass);
     90           
    7991            quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
    8092            currentDay++;
    8193        }
Back to Top