aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorKeith Wood <kbwood.au@gmail.com>2009-06-21 07:28:51 +0000
committerKeith Wood <kbwood.au@gmail.com>2009-06-21 07:28:51 +0000
commit3b5c91fdc668bd02cfb0293cf167f05a5c5b4b86 (patch)
tree1c0730894087b648203750643e0f2cf01e6cdbaa /ui
parent82df8dbf533f2b44602e33c4201d7fe8475be919 (diff)
downloadjquery-ui-3b5c91fdc668bd02cfb0293cf167f05a5c5b4b86.tar.gz
jquery-ui-3b5c91fdc668bd02cfb0293cf167f05a5c5b4b86.zip
Datepicker. Fixed #3657 showOtherMonths should allow the selection of days from other months
Diffstat (limited to 'ui')
-rw-r--r--ui/ui.datepicker.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js
index 478b756e3..f3f00acb3 100644
--- a/ui/ui.datepicker.js
+++ b/ui/ui.datepicker.js
@@ -76,6 +76,7 @@ function Datepicker() {
yearRange: '-10:+10', // Range of years to display in drop-down,
// either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
showOtherMonths: false, // True to show dates in other months, false to leave blank
+ selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
// takes a Date and returns the number of the week for it
shortYearCutoff: '+10', // Short year values < this are in the current century,
@@ -1340,6 +1341,7 @@ $.extend(Datepicker.prototype, {
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 calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
var defaultDate = this._getDefaultDate(inst);
var html = '';
@@ -1385,7 +1387,7 @@ $.extend(Datepicker.prototype, {
var daySettings = (beforeShowDay ?
beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
var otherMonth = (printDate.getMonth() != drawMonth);
- var unselectable = otherMonth || !daySettings[0] ||
+ var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
tbody += '<td class="' +
((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
@@ -1401,11 +1403,12 @@ $.extend(Datepicker.prototype, {
((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
(unselectable ? '' : ' onclick="DP_jQuery.datepicker._selectDay(\'#' +
inst.id + '\',' + drawMonth + ',' + drawYear + ', this);return false;"') + '>' + // actions
- (otherMonth ? (showOtherMonths ? printDate.getDate() : '&#xa0;') : // display for other months
+ (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
(printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
- '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
+ (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
+ '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
printDate.setDate(printDate.getDate() + 1);
printDate = this._daylightSavingAdjust(printDate);
}