From 2fa8edb2c43c4c4c8aceb3b2df6ab522452aefd8 Mon Sep 17 00:00:00 2001 From: VorTechS Date: Thu, 9 Dec 2010 07:07:30 -0800 Subject: [PATCH 1/2] Add a new property (changeDays) for removing the day selection from the calendar, allowing you to select only the month and/or year. --- ui/jquery.ui.datepicker.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index abcb3706719..ed9b1c814fe 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -74,6 +74,7 @@ function Datepicker() { gotoCurrent: false, // True if today link goes back to current selection instead changeMonth: false, // True if month can be selected directly, false if only prev/next changeYear: false, // True if year can be selected directly, false if only prev/next + changeDays: true, // True if the day can be selected directly, false if only prev/next yearRange: 'c-10:c+10', // Range of years to display in drop-down, // either relative to today's year (-nn:+nn), relative to currently displayed year // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) @@ -1443,6 +1444,8 @@ $.extend(Datepicker.prototype, { var selectOtherMonths = this._get(inst, 'selectOtherMonths'); var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week; var defaultDate = this._getDefaultDate(inst); + var showDays = this._get(inst, 'changeDays'); + var html = ''; for (var row = 0; row < numMonths[0]; row++) { var group = ''; @@ -1469,6 +1472,7 @@ $.extend(Datepicker.prototype, { row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers '' + ''; + if (showDays) { var thead = (showWeek ? '' : ''); for (var dow = 0; dow < 7; dow++) { // days of the week var day = (dow + firstDay) % 7; @@ -1517,6 +1521,7 @@ $.extend(Datepicker.prototype, { } calender += tbody + ''; } +} drawMonth++; if (drawMonth > 11) { drawMonth = 0; @@ -1539,12 +1544,18 @@ $.extend(Datepicker.prototype, { secondary, monthNames, monthNamesShort) { var changeMonth = this._get(inst, 'changeMonth'); var changeYear = this._get(inst, 'changeYear'); + var changeDays = this._get(inst, 'changeDays'); + var showMonthAfterYear = this._get(inst, 'showMonthAfterYear'); var html = '
'; var monthHtml = ''; // month selection if (secondary || !changeMonth) +{ + if (changeDays) { monthHtml += '' + monthNames[drawMonth] + ''; + } +} else { var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); From 8d7e7bbc038d2c901a8a030091d3756e53a61949 Mon Sep 17 00:00:00 2001 From: VorTechS Date: Sun, 12 Dec 2010 23:24:53 -0800 Subject: [PATCH 2/2] Required functionality that raises the _selectDate event when the UI loses focus and hides. --- ui/jquery.ui.datepicker.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index ed9b1c814fe..dfe64978102 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -812,6 +812,13 @@ $.extend(Datepicker.prototype, { !$target.hasClass($.datepicker.markerClassName) && !$target.hasClass($.datepicker._triggerClass) && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) + + /* Support for month/year selection only, to modify raise the date selection event when the UI loses focus */ + var inst = $.advdatepicker._getInst(event.currentTarget.activeElement); + if (!$.advdatepicker._get(inst, 'changeDays')) { + + $.advdatepicker._selectDate('#' + inst.id, $.advdatepicker._formatDate($.advdatepicker._curInst, $.advdatepicker._curInst.currentDay, $.advdatepicker._curInst.drawMonth, $.advdatepicker._curInst.drawYear)); + } $.datepicker._hideDatepicker(); },
' + this._get(inst, 'weekHeader') + '