Ticket #4448: openCalendar_redraw_with_current.diff

File openCalendar_redraw_with_current.diff, 1.1 KB (added by gkelly@…, 17 years ago)

Updates calendar widget on redraw when date in text input changes.

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

     
    195195    openCalendar: function(num) {
    196196        var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num)
    197197        var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num)
     198        var inp = DateTimeShortcuts.calendarInputs[num];
     199
     200        // Determine if the current value in the input has a valid date.
     201        // If so, draw the calendar with that date's year and month.
     202        if (inp.value) {
     203            var date_parts = inp.value.split('-');
     204            var year = date_parts[0];
     205            var month = parseFloat(date_parts[1]);
     206            if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) {
     207                DateTimeShortcuts.calendars[num].drawDate(month, year);
     208            }
     209        }
     210
    198211   
    199212        // Recalculate the clockbox position
    200213        // is it left-to-right or right-to-left layout ?
Back to Top