Skip to content
Permalink
Browse files

Fixed 3159 Datepicker function to do refresh/redraw

Simplified iso8601Week function
  • Loading branch information
Keith Wood
Keith Wood committed Aug 21, 2008
1 parent 50fae39 commit 187c97bef0a92f8840abc2f04952d8786eef0705
Showing with 15 additions and 6 deletions.
  1. +15 −6 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

0 comments on commit 187c97b

Please sign in to comment.
You can’t perform that action at this time.