' : '';
- var firstDay = parseInt(this._get(inst, 'firstDay'),10);
+
+ firstDay = parseInt(this._get(inst, 'firstDay'),10);
firstDay = (isNaN(firstDay) ? 0 : firstDay);
- var showWeek = this._get(inst, 'showWeek');
- var dayNames = this._get(inst, 'dayNames');
- var dayNamesMin = this._get(inst, 'dayNamesMin');
- var monthNames = this._get(inst, 'monthNames');
- var monthNamesShort = this._get(inst, 'monthNamesShort');
- var beforeShowDay = this._get(inst, 'beforeShowDay');
- var showOtherMonths = this._get(inst, 'showOtherMonths');
- var selectOtherMonths = this._get(inst, 'selectOtherMonths');
- var defaultDate = this._getDefaultDate(inst);
- var html = '';
- for (var row = 0; row < numMonths[0]; row++) {
- var group = '';
+
+ showWeek = this._get(inst, 'showWeek');
+ dayNames = this._get(inst, 'dayNames');
+ dayNamesMin = this._get(inst, 'dayNamesMin');
+ monthNames = this._get(inst, 'monthNames');
+ monthNamesShort = this._get(inst, 'monthNamesShort');
+ beforeShowDay = this._get(inst, 'beforeShowDay');
+ showOtherMonths = this._get(inst, 'showOtherMonths');
+ selectOtherMonths = this._get(inst, 'selectOtherMonths');
+ defaultDate = this._getDefaultDate(inst);
+ html = '';
+ dow;
+ for (row = 0; row < numMonths[0]; row++) {
+ group = '';
this.maxRows = 4;
- for (var col = 0; col < numMonths[1]; col++) {
- var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
- var cornerClass = ' ui-corner-all';
- var calender = '';
+ for (col = 0; col < numMonths[1]; col++) {
+ selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
+ cornerClass = ' ui-corner-all';
+ calender = '';
if (isMultiMonth) {
calender += '
' : '') : '');
group += calender;
}
html += group;
@@ -1614,52 +1790,58 @@ $.extend(Datepicker.prototype, {
/* Generate the month and year header. */
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
secondary, monthNames, monthNamesShort) {
- var changeMonth = this._get(inst, 'changeMonth');
- var changeYear = this._get(inst, 'changeYear');
- var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
- var html = '
';
- var monthHtml = '';
+
+ var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
+ changeMonth = this._get(inst, 'changeMonth'),
+ changeYear = this._get(inst, 'changeYear'),
+ showMonthAfterYear = this._get(inst, 'showMonthAfterYear'),
+ html = '
',
+ monthHtml = '';
+
// month selection
- if (secondary || !changeMonth)
+ if (secondary || !changeMonth) {
monthHtml += '' + monthNames[drawMonth] + '';
- else {
- var inMinYear = (minDate && minDate.getFullYear() == drawYear);
- var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
+ } else {
+ inMinYear = (minDate && minDate.getFullYear() === drawYear);
+ inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
monthHtml += '';
}
- if (!showMonthAfterYear)
+
+ if (!showMonthAfterYear) {
html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
+ }
+
// year selection
if ( !inst.yearshtml ) {
inst.yearshtml = '';
- if (secondary || !changeYear)
+ if (secondary || !changeYear) {
html += '' + drawYear + '';
- else {
+ } else {
// determine range of years to display
- var years = this._get(inst, 'yearRange').split(':');
- var thisYear = new Date().getFullYear();
- var determineYear = function(value) {
+ years = this._get(inst, 'yearRange').split(':');
+ thisYear = new Date().getFullYear();
+ determineYear = function(value) {
var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
(value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
parseInt(value, 10)));
return (isNaN(year) ? thisYear : year);
};
- var year = determineYear(years[0]);
- var endYear = Math.max(year, determineYear(years[1] || ''));
+ year = determineYear(years[0]);
+ endYear = Math.max(year, determineYear(years[1] || ''));
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
inst.yearshtml += '';
@@ -1668,49 +1850,51 @@ $.extend(Datepicker.prototype, {
inst.yearshtml = null;
}
}
+
html += this._get(inst, 'yearSuffix');
- if (showMonthAfterYear)
+ if (showMonthAfterYear) {
html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml;
+ }
html += '
'; // Close datepicker_header
return html;
},
/* Adjust one of the date sub-fields. */
_adjustInstDate: function(inst, offset, period) {
- var year = inst.drawYear + (period == 'Y' ? offset : 0);
- var month = inst.drawMonth + (period == 'M' ? offset : 0);
- var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
- (period == 'D' ? offset : 0);
- var date = this._restrictMinMax(inst,
- this._daylightSavingAdjust(new Date(year, month, day)));
+ var year = inst.drawYear + (period === 'Y' ? offset : 0),
+ month = inst.drawMonth + (period === 'M' ? offset : 0),
+ day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === 'D' ? offset : 0),
+ date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
+
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
- if (period == 'M' || period == 'Y')
+ if (period === 'M' || period === 'Y') {
this._notifyChange(inst);
+ }
},
/* Ensure a date is within any min/max bounds. */
_restrictMinMax: function(inst, date) {
- var minDate = this._getMinMaxDate(inst, 'min');
- var maxDate = this._getMinMaxDate(inst, 'max');
- var newDate = (minDate && date < minDate ? minDate : date);
- newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
- return newDate;
+ var minDate = this._getMinMaxDate(inst, 'min'),
+ maxDate = this._getMinMaxDate(inst, 'max'),
+ newDate = (minDate && date < minDate ? minDate : date);
+ return (maxDate && newDate > maxDate ? maxDate : newDate);
},
/* Notify change of month/year. */
_notifyChange: function(inst) {
var onChange = this._get(inst, 'onChangeMonthYear');
- if (onChange)
+ if (onChange) {
onChange.apply((inst.input ? inst.input[0] : null),
[inst.selectedYear, inst.selectedMonth + 1, inst]);
+ }
},
/* Determine the number of months to show. */
_getNumberOfMonths: function(inst) {
var numMonths = this._get(inst, 'numberOfMonths');
- return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
+ return (numMonths == null ? [1, 1] : (typeof numMonths === 'number' ? [1, numMonths] : numMonths));
},
/* Determine the current maximum date - ensure no time components are set. */
@@ -1730,24 +1914,27 @@ $.extend(Datepicker.prototype, {
/* Determines if we should allow a "next/prev" month display change. */
_canAdjustMonth: function(inst, offset, curYear, curMonth) {
- var numMonths = this._getNumberOfMonths(inst);
- var date = this._daylightSavingAdjust(new Date(curYear,
+ var numMonths = this._getNumberOfMonths(inst),
+ date = this._daylightSavingAdjust(new Date(curYear,
curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
- if (offset < 0)
+
+ if (offset < 0) {
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
+ }
return this._isInRange(inst, date);
},
/* Is the given date in the accepted range? */
_isInRange: function(inst, date) {
- var minDate = this._getMinMaxDate(inst, 'min');
- var maxDate = this._getMinMaxDate(inst, 'max');
- var minYear = null;
- var maxYear = null;
- var years = this._get(inst, 'yearRange');
+ var yearSplit, currentYear,
+ minDate = this._getMinMaxDate(inst, 'min'),
+ maxDate = this._getMinMaxDate(inst, 'max'),
+ minYear = null,
+ maxYear = null,
+ years = this._get(inst, 'yearRange');
if (years){
- var yearSplit = years.split(':');
- var currentYear = new Date().getFullYear();
+ yearSplit = years.split(':');
+ currentYear = new Date().getFullYear();
minYear = parseInt(yearSplit[0], 10) + currentYear;
maxYear = parseInt(yearSplit[1], 10) + currentYear;
}
@@ -1761,7 +1948,7 @@ $.extend(Datepicker.prototype, {
/* Provide the configuration settings for formatting/parsing. */
_getFormatConfig: function(inst) {
var shortYearCutoff = this._get(inst, 'shortYearCutoff');
- shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
+ shortYearCutoff = (typeof shortYearCutoff !== 'string' ? shortYearCutoff :
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
return {shortYearCutoff: shortYearCutoff,
dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
@@ -1775,7 +1962,7 @@ $.extend(Datepicker.prototype, {
inst.currentMonth = inst.selectedMonth;
inst.currentYear = inst.selectedYear;
}
- var date = (day ? (typeof day == 'object' ? day :
+ var date = (day ? (typeof day === 'object' ? day :
this._daylightSavingAdjust(new Date(year, month, day))) :
this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
@@ -1791,15 +1978,23 @@ function bindHover(dpDiv) {
var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
return dpDiv.delegate(selector, 'mouseout', function() {
$(this).removeClass('ui-state-hover');
- if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
- if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
+ if (this.className.indexOf('ui-datepicker-prev') !== -1) {
+ $(this).removeClass('ui-datepicker-prev-hover');
+ }
+ if (this.className.indexOf('ui-datepicker-next') !== -1) {
+ $(this).removeClass('ui-datepicker-next-hover');
+ }
})
.delegate(selector, 'mouseover', function(){
if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
$(this).addClass('ui-state-hover');
- if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
- if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
+ if (this.className.indexOf('ui-datepicker-prev') !== -1) {
+ $(this).addClass('ui-datepicker-prev-hover');
+ }
+ if (this.className.indexOf('ui-datepicker-next') !== -1) {
+ $(this).addClass('ui-datepicker-next-hover');
+ }
}
});
}
@@ -1807,9 +2002,11 @@ function bindHover(dpDiv) {
/* jQuery extend now ignores nulls! */
function extendRemove(target, props) {
$.extend(target, props);
- for (var name in props)
- if (props[name] == null)
+ for (var name in props) {
+ if (props[name] == null) {
target[name] = props[name];
+ }
+ }
return target;
}
@@ -1832,14 +2029,16 @@ $.fn.datepicker = function(options){
}
var otherArgs = Array.prototype.slice.call(arguments, 1);
- if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
+ if (typeof options === 'string' && (options === 'isDisabled' || options === 'getDate' || options === 'widget')) {
return $.datepicker['_' + options + 'Datepicker'].
apply($.datepicker, [this[0]].concat(otherArgs));
- if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
+ }
+ if (options === 'option' && arguments.length === 2 && typeof arguments[1] === 'string') {
return $.datepicker['_' + options + 'Datepicker'].
apply($.datepicker, [this[0]].concat(otherArgs));
+ }
return this.each(function() {
- typeof options == 'string' ?
+ typeof options === 'string' ?
$.datepicker['_' + options + 'Datepicker'].
apply($.datepicker, [this].concat(otherArgs)) :
$.datepicker._attachDatepicker(this, options);