From 66e45411017a4526670ba2c4e465c3ca45d55602 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 14 Sep 2007 21:04:45 +0000 Subject: [PATCH] Fixed #4448: the calendar widget now refreshes if the date field is changed. THanks, gkelly. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6214 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../admin/media/js/admin/DateTimeShortcuts.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/django/contrib/admin/media/js/admin/DateTimeShortcuts.js b/django/contrib/admin/media/js/admin/DateTimeShortcuts.js index b1504fc819..4682a6841a 100644 --- a/django/contrib/admin/media/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/media/js/admin/DateTimeShortcuts.js @@ -195,6 +195,19 @@ var DateTimeShortcuts = { openCalendar: function(num) { var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num) var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num) + var inp = DateTimeShortcuts.calendarInputs[num]; + + // Determine if the current value in the input has a valid date. + // If so, draw the calendar with that date's year and month. + if (inp.value) { + var date_parts = inp.value.split('-'); + var year = date_parts[0]; + var month = parseFloat(date_parts[1]); + if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) { + DateTimeShortcuts.calendars[num].drawDate(month, year); + } + } + // Recalculate the clockbox position // is it left-to-right or right-to-left layout ?