From: Keith Wood Date: Thu, 21 Aug 2008 09:04:44 +0000 (+0000) Subject: Fixed 3159 Datepicker function to do refresh/redraw X-Git-Tag: 1.6rc2~84 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=187c97bef0a92f8840abc2f04952d8786eef0705;p=jquery-ui.git Fixed 3159 Datepicker function to do refresh/redraw Simplified iso8601Week function --- diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index da8f89cd2..fee8ed9a8 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -230,10 +230,10 @@ $.extend(Datepicker.prototype, { /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { - var input = $(target); - if (input.hasClass(this.markerClassName)) + var divSpan = $(target); + if (divSpan.hasClass(this.markerClassName)) return; - input.addClass(this.markerClassName).append(inst.dpDiv). + divSpan.addClass(this.markerClassName).append(inst.dpDiv). bind("setData.datepicker", function(event, key, value){ inst.settings[key] = value; }).bind("getData.datepicker", function(event, key){ @@ -416,6 +416,15 @@ $.extend(Datepicker.prototype, { } }, + /* Redraw the date picker attached to an input field or division. + @param target element - the target input field or division or span */ + _refreshDatepicker: function(target) { + var inst = $.data(target, PROP_NAME); + if (inst) { + this._updateDatepicker(inst); + } + }, + /* Set the dates for a jQuery selection. @param target element - the target input field or division or span @param date Date - the new date @@ -838,7 +847,8 @@ $.extend(Datepicker.prototype, { @param date Date - the date to get the week for @return number - the number of the week within the year that contains this date */ iso8601Week: function(date) { - var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), (date.getTimezoneOffset() / -60)); + var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), + (date.getTimezoneOffset() / -60)); var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday @@ -848,8 +858,7 @@ $.extend(Datepicker.prototype, { } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary - checkDate.setDate(checkDate.getDate() + 3); // Generate for next year - return $.datepicker.iso8601Week(checkDate); + return 1; } } return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date