]> source.dussan.org Git - jquery-ui.git/commitdiff
Fixed 3159 Datepicker function to do refresh/redraw
authorKeith Wood <kbwood.au@gmail.com>
Thu, 21 Aug 2008 09:04:44 +0000 (09:04 +0000)
committerKeith Wood <kbwood.au@gmail.com>
Thu, 21 Aug 2008 09:04:44 +0000 (09:04 +0000)
Simplified iso8601Week function

ui/ui.datepicker.js

index da8f89cd2cd96479d7b0919d4604c467f770c52f..fee8ed9a83cdbb9ad9346e7b9923145e974b5fde 100644 (file)
@@ -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