/* Month and Year picker for jQuery UI Datepicker 1.8.21 Written by Anton Ludescher (silverskater{at}gmail.com). Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. */ if (datepicker == undefined){ var datepicker_fn = $.fn.datepicker var datepicker = $.datepicker } (function($, undefined ) { //overriding functions meant to be private (starting with an underscore) $.ui_datepicker = datepicker $.fn.ui_datepicker = datepicker_fn $.ui_datepicker._updateDatepicker_MonthYearPicker = $.ui_datepicker._updateDatepicker; $.ui_datepicker._showDatepicker_MonthYearPicker = $.ui_datepicker._showDatepicker; $.ui_datepicker._doKeyDown_MonthYearPicker = $.ui_datepicker._doKeyDown; $.extend($.ui_datepicker, { _doKeyDown: function(event) { var inst = $.ui_datepicker._getInst(event.target); var handled = true; //var isRTL = inst.dpDiv.is('.ui-datepicker-rtl'); inst._keyEvent = true; if ($.ui_datepicker._datepickerShowing) { switch (event.keyCode) { case 27: if($('.ui-datepicker-select-month').is(':visible')) { $.ui_datepicker._updateDatepicker(inst); } else if($('.ui-datepicker-select-year').is(':visible')) { $.ui_datepicker._toggleDisplay_MonthYearPicker(inst, 2, this); } else { $.ui_datepicker._hideDatepicker(); } break; // hide on escape //TODO prev/next month/year on month/year picker screens default: //call the original function $.ui_datepicker._doKeyDown_MonthYearPicker(event); } } else { //call the original function $.ui_datepicker._doKeyDown_MonthYearPicker(event); } }, _updateDatepicker: function(inst) { //call the original function if (this._get(inst, 'show_view') == 'year' && !$('.ui-datepicker-select-year').is(':visible')){ var current_format = this._get(inst, 'dateFormat') var regex = /\W/, indice = 0; var result = current_format.split(/\W/) for (var i=0;i').append(this.dpDiv.clone()).html()); var uidptitle = inst.dpDiv.find('.ui-datepicker-title'); var uidptitle_link = uidptitle.wrapInner(''); uidptitle_link.click(function(){$.ui_datepicker.select_month = false;$.ui_datepicker._toggleDisplay_MonthYearPicker('#' + inst.id, 2); return false;}); inst.dpDiv.children('table.ui-datepicker-calendar').after(this._generateExtraHTML_MonthYearPicker(inst)); if (!$('.ui-datepicker-select-year').is(':visible') && !$('.ui-datepicker-select-month').is(':visible')){ if (this._get(inst, 'show_view') == 'month') { this._toggleDisplay_MonthYearPicker('#' + inst.id,2) }else if (this._get(inst, 'show_view') == 'year'){ this._toggleDisplay_MonthYearPicker('#' + inst.id,3) } } this._reposition_MonthYearPicker(inst); }, //focus the date input field _instInputFocus_MYP: function(inst) { //code copied from datePicker's _updateDatepicker() if (inst == $.ui_datepicker._curInst && $.ui_datepicker._datepickerShowing && inst.input && // #6694 - don't focus the input if it's already focused // this breaks the change event in IE inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement) inst.input.focus(); }, _generateMonthPickerHTML_MonthYearPicker: function(inst, minDate, maxDate, drawMonth, inMinYear, inMaxYear) { //TODO RTL? var monthNamesShort = this._get(inst, 'monthNamesShort'); var monthPicker = ''; var unselectable = false; for (var month = 0; month < 12; ) { unselectable = (inMinYear && month < minDate.getMonth()) || (inMaxYear && month > maxDate.getMonth()); monthPicker += ''; // display selectable date if(++month % 4 === 0) { monthPicker += ''; if(month != 12) { monthPicker += ''; } } } monthPicker += '
' + // actions ((unselectable ? '' + monthNamesShort[month] + '' : '' + monthNamesShort[month] + '')) + '
'; return monthPicker; }, _generateExtraHTML_MonthYearPicker: function(inst,show_view) { if (show_view != 'year'){ var minDate = this._getMinMaxDate(inst, 'min'); var maxDate = this._getMinMaxDate(inst, 'max'); var drawYear = inst.drawYear; var drawMonth = inst.drawMonth; var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); var monthPicker = this._generateMonthPickerHTML_MonthYearPicker(inst, minDate, maxDate, drawMonth, inMinYear, inMaxYear); if (show_view != 'month'){ return '' + ''; //yearPicker gets filled dinamically } else{ return '
' + monthPicker + '
' + ''; } } else{ return '' + '
'; } }, _pickMonthYear_MonthYearPicker: function(id, valueMY, period) { var dummySelect = $('