From 139feac13f0561c5651abbc4b7e670e6d1838bdf Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 20 Nov 2015 13:49:56 +0200 Subject: [PATCH 01/48] Makes the mnue look more like datepicker Makes the month-picker div wrap around the menu. --- MonthPicker.js | 7 +++---- css/MonthPicker.css | 21 ++++++++++++++++++--- test/test.js | 4 ++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 925269b..5aa8ac7 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -170,7 +170,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }; var _markup = - '
' + + '
' + '' + '' + '' + @@ -184,7 +184,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '' + '
' + '
' + - '
' + + '
' + '' + ''; @@ -322,7 +322,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _el.addClass('month-year-input'); - var _menu = this._monthPickerMenu = $('
'); + var _menu = this._monthPickerMenu = $('
'); var isInline = _isInline(_el); $(_markup).appendTo(_menu); @@ -383,7 +383,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._setUseInputMask(); this._setDisabledState(); - this._updateFieldEvents(); this.Destroy = this.destroy; if (isInline) { diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 05b8109..1ad2129 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -17,7 +17,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. */ .month-picker { - width: 200px; + /*padding: 2px;*/ + background-color: #fff; + /*width: 200px;*/ display: none; position: absolute; z-index: 9999; @@ -28,6 +30,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .month-picker .year-container-all { cursor: pointer; } +.month-picker-header { + margin: 3px 3px 0px 3px; +} .month-picker-year-table .year-container-all { text-align: center; } @@ -48,7 +53,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. width: 50px; } .month-picker-year-table .previous-year { - width: 35px; + /*width: 35px;*/ /* In case the user's css reset the user agent stylesheet this is often done in RTL pages. @@ -56,9 +61,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. text-align: left; } .month-picker-year-table .next-year { - width: 35px; + /*width: 35px;*/ text-align: right; } + +.month-picker-year-table .next-year>button { + margin-right: 0; +} + .month-picker-year-table button { width: 28px; width: 1.8em; @@ -70,10 +80,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. text-align: center; } .month-picker-month-table td { + padding: 0; height: 35px; text-align: center; font-size: 12px; } +.month-picker-month-table button { + width: 55px; + margin: 3px; +} .month-picker-open-button { height: 20px; width: 20px; diff --git a/test/test.js b/test/test.js index e4da5d2..6bcf776 100644 --- a/test/test.js +++ b/test/test.js @@ -377,7 +377,7 @@ QUnit.test('Inline menu', function(assert) { assert.notOk($("#MonthPicker_Button_InlineMenuDiv").length, 'The default button was not created'); - field.MonthPicker('destroy'); + //field.MonthPicker('destroy'); }); QUnit.test('SelectedMonth option', function(assert) { @@ -399,7 +399,7 @@ QUnit.test('SelectedMonth option', function(assert) { var date = field.MonthPicker('GetSelectedDate'); assert.ok( menu.find('.button-1').is('.ui-state-active'), 'January is selected after changing the SelectedMonth'); - field.MonthPicker('Destroy'); + //field.MonthPicker('Destroy'); }); // Makes sure that all events are triggered as expected. From 8bcce73e28b1cfa8d18ca398723ea3b7a64f3375 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 21 Nov 2015 11:34:14 +0200 Subject: [PATCH 02/48] Fixed an issue with inline menus's width --- MonthPicker.js | 9 ++++----- MonthPicker.min.js | 2 +- README.md | 2 +- css/MonthPicker.css | 12 +++++------- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.js | 14 +++++++------- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 5aa8ac7..e2d9d6b 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -1,7 +1,7 @@ /* https://github.com/KidSysco/jquery-ui-month-picker/ -Version 2.8.1 +Version 3.0-alpha1 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -154,7 +154,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } $.MonthPicker = { - VERSION: '2.8.1', // Added in version 2.4; + VERSION: '3.0-alpha1', // Added in version 2.4; i18n: { year: "Year", prevYear: "Previous Year", @@ -320,9 +320,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _el.css('width', 'auto'); } - _el.addClass('month-year-input'); - - var _menu = this._monthPickerMenu = $('
'); + var _menu = this._monthPickerMenu = $('
').hide(); var isInline = _isInline(_el); $(_markup).appendTo(_menu); @@ -390,6 +388,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else { // Update the alt field if the user manually changes // the input field. + _el.addClass('month-year-input'); _el.change($proxy(this._updateAlt, this)); } }, diff --git a/MonthPicker.min.js b/MonthPicker.min.js index ce6a410..4327b09 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"2.8.1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto")),b.addClass("month-year-input");var i=this._monthPickerMenu=a('
'),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this._updateFieldEvents(),this.Destroy=this.destroy,k?this.Open():b.change(F(this._updateAlt,this))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/README.md b/README.md index d15ed76..2a1acc8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

The jQuery UI Month Picker Version 2.8.1

+

The jQuery UI Month Picker Version 3.0-alpha1

The jQuery UI Month Picker Plugin is designed to allow user input for only a month and year when only that input is required. Clicking on the year, allows the user to jump ahead or back 5 years at a time. Clicking anywhere on the page, except on the month picker menu itself, will cause the month picker to hide. The Month Picker has lots of options diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 1ad2129..888bfe1 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -1,6 +1,6 @@ /* -The jQuery UI Month Picker Version 2.6 +The jQuery UI Month Picker Version 3.0-alpha1 https://github.com/KidSysco/jquery-ui-month-picker/ @@ -17,10 +17,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. */ .month-picker { - /*padding: 2px;*/ - background-color: #fff; - /*width: 200px;*/ - display: none; + display: inline-block; position: absolute; z-index: 9999; } @@ -49,11 +46,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. font-size: 12px; font-family: Verdana, Arial, sans-serif; } +.month-picker-year-table { + width: 100%; +} .month-picker-year-table .year-container { width: 50px; } .month-picker-year-table .previous-year { - /*width: 35px;*/ /* In case the user's css reset the user agent stylesheet this is often done in RTL pages. @@ -61,7 +60,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. text-align: left; } .month-picker-year-table .next-year { - /*width: 35px;*/ text-align: right; } diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 2cb98b9..0bd0ee4 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker .year-container-all,.option-link{cursor:pointer}.month-picker{width:200px;display:none;position:absolute;z-index:9999}.month-year-input{width:60px}.month-picker-year-table .year-container-all{text-align:center}.month-picker-year-table .year-container{margin:0 auto;width:50px}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table .previous-year{width:35px;text-align:left}.month-picker-year-table .next-year{width:35px;text-align:right}.month-picker-year-table button{width:28px;width:1.8em;height:1.8em;text-align:center;cursor:pointer}.month-picker-year-table .year-container{text-align:center}.month-picker-month-table td{height:35px;text-align:center;font-size:12px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker .year-container-all,.option-link{cursor:pointer}.month-picker{display:inline-block;position:absolute;z-index:9999}.month-year-input{width:60px}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .year-container-all{text-align:center}.month-picker-year-table .year-container{margin:0 auto}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .year-container{width:50px}.month-picker-year-table .previous-year{text-align:left}.month-picker-year-table .next-year{text-align:right}.month-picker-year-table .next-year>button{margin-right:0}.month-picker-year-table button{width:28px;width:1.8em;height:1.8em;text-align:center;cursor:pointer}.month-picker-year-table .year-container{text-align:center}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 257eff4..0c12399 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"2.8.1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='

';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto")),b.addClass("month-year-input");var i=this._monthPickerMenu=a('
'),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this._updateFieldEvents(),this.Destroy=this.destroy,k?this.Open():b.change(F(this._updateAlt,this))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 6bcf776..f7c03e9 100644 --- a/test/test.js +++ b/test/test.js @@ -122,7 +122,8 @@ if ($.ui.position) { collision: 'fit flip' }, OnAfterMenuOpen: function () { - var _lastPointFullyVisibleX = _windowWidth - 200; + var _meun = $(MonthPicker_PositionDemo); + var _lastPointFullyVisibleX = _windowWidth - _meun.width(); var _lastPointFullyVisibleY = _windowHeight - _pickerMenu.height(); assert.equal(_pickerMenu.css('display'), 'block', '#PositionDemo responded to a text input click event and showed the menu.'); assert.ok(_pickerMenu.position().left <= _lastPointFullyVisibleX, "#PositionDemo does not overlap the right window boundary on the X axis."); @@ -363,21 +364,19 @@ QUnit.test('Inline menu', function(assert) { var menu = $(MonthPicker_InlineMenuDiv); - assert.ok(menu.is(':visible'), 'The menu is visible without having to call the Open method'); - + assert.ok(menu.width() <= 200, 'The menu is visible and has the expected width'); $(document.body).trigger('click'); assert.ok(menu.is(':visible'), 'The menu is still visible after clicking outside the menu'); - //var buttons = menu.find('.month-picker-month-table button'); menu.find('.button-1').trigger('click'); assert.ok(menu.is(':visible'), 'The menu is still visible after choosing a month'); assert.notOk($("#MonthPicker_Button_InlineMenuDiv").length, 'The default button was not created'); - //field.MonthPicker('destroy'); + field.MonthPicker('destroy'); }); QUnit.test('SelectedMonth option', function(assert) { @@ -399,7 +398,7 @@ QUnit.test('SelectedMonth option', function(assert) { var date = field.MonthPicker('GetSelectedDate'); assert.ok( menu.find('.button-1').is('.ui-state-active'), 'January is selected after changing the SelectedMonth'); - //field.MonthPicker('Destroy'); + field.MonthPicker('Destroy'); }); // Makes sure that all events are triggered as expected. @@ -612,10 +611,11 @@ QUnit.test('Right to left', function (assert) { assert.ok(nextYearButton.find('span.ui-icon-circle-triangle-w').length, 'Next button is pointed west'); // Make sure the menu opens to the right of the field. + //alert(field.position().left - menu.position().left); var opendToTheRight = (field.position().left - menu.position().left) > 100; assert.ok(opendToTheRight, 'The menu opened to the right of rhe field'); - field.MonthPicker('Close'); + //field.MonthPicker('Close'); }); QUnit.test('Toggle method', function (assert) { From 30d32736cc9a98c41b6bbf5357dcb752642a2901 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 27 Nov 2015 13:25:13 +0200 Subject: [PATCH 03/48] Create .travis.yml --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4dfa8bb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.8" +before_install: npm install -g grunt-cli +install: npm install +before_script: grunt From 14dfe2fcfaa848e8efb74ee4e9756ce6fd099aa8 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 27 Nov 2015 13:32:38 +0200 Subject: [PATCH 04/48] Update package.json for Travis CI --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcdd7f4..be5665a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "devDependencies": { "grunt-contrib-uglify": "~0.6.0", "grunt-contrib-cssmin": "^0.14.0", - "grunt-contrib-qunit": "^0.7.0", + "grunt-contrib-qunit": "^0.6.0", "bower" : "" } } From a0f7622ec24adc169d0ba8efd0cf36cef8965fcb Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 27 Nov 2015 13:36:51 +0200 Subject: [PATCH 05/48] Updated Node.js in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4dfa8bb..9b7c47f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.8" + - "0.12.4" before_install: npm install -g grunt-cli install: npm install before_script: grunt From dbe9a7b1c32316ae976a5eb13b848eb1322ea382 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 27 Nov 2015 14:16:32 +0200 Subject: [PATCH 06/48] Added Travis CI and built with grunt badges to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8bd722c..f7fe4cc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@

The jQuery UI Month Picker Version 3.0-alpha2

+[![Build Status](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker.svg?branch=3.0_prototype)](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker) +[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) +

The jQuery UI Month Picker Plugin is designed to allow user input for only a month and year when only that input is required. Clicking on the year, allows the user to jump ahead or back 5 years at a time. Clicking anywhere on the page, except on the month picker menu itself, will cause the month picker to hide. The Month Picker has lots of options From 1a7d29e08732552bce4c929bc8263d91b3d6676c Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 5 Dec 2015 16:22:48 +0200 Subject: [PATCH 07/48] Makes the next and previous buttons have a transparent background and ajausts the unit tests. --- MonthPicker.js | 18 ++++++++++++++---- css/MonthPicker.css | 6 +++++- test/test.html | 6 +++++- test/test.js | 30 +++++++++++++++--------------- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index f27db96..239b1f3 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -169,18 +169,21 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }; + // + + var _markup = '

' + '
' + '' + - '' + + '' + '' + - '' + + '' + '' + '
' + '
' + '' + '' + '
' + '
' + '
' + @@ -337,8 +340,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._yearContainer = $('.year', _menu); - this._prevButton = $('.previous-year button', _menu).button({ text: false }); - this._nextButton = $('.next-year button', _menu).button({ text: false }); + this._prevButton = $('.previous-year a', _menu); + this._prevButton.button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); + this._nextButton = $('.next-year a', _menu).button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. @@ -865,6 +869,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _year.text(parseInt(_year.text()) + amount, 10); this.element.focus(); + var me = this; + setTimeout(function() { + var _btn = amount > 0 ? me._nextButton : me._prevButton; + _btn.addClass('ui-state-hover'); + }, 1); + this._decorateButtons(); _event('OnAfter' + (amount > 0 ? 'Next' : 'Previous') + 'Year', this)(); diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 888bfe1..8203dd3 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -36,6 +36,10 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .month-picker-year-table .year-container { margin: 0 auto; } +.month-picker-year-table a { + border: 1px solid transparent; +} + .month-picker-year-table .year-title { margin: 3px; font-size: 12px; @@ -67,7 +71,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. margin-right: 0; } -.month-picker-year-table button { +.month-picker-year-table /*button*/ a { width: 28px; width: 1.8em; height: 1.8em; diff --git a/test/test.html b/test/test.html index 4fb31a7..ff57015 100644 --- a/test/test.html +++ b/test/test.html @@ -3,7 +3,11 @@ jQuery UI Month Picker tests + + + @@ -19,7 +23,7 @@ "Welcome to the jQuery UI Month Picker project.\n" + "\n" + "jQuery UI and QUnit are required for testing.\n" + - "Please download node.js, 'cd /jquery-ui-month-picker' and run 'npm install'.\n" + + "Please download node.js, 'cd ./jquery-ui-month-picker' and run 'npm install'.\n" + "\n" + "Tests can be ran from the command line using the 'grunt test' command."; diff --git a/test/test.js b/test/test.js index f8f6b4c..eeb4191 100644 --- a/test/test.js +++ b/test/test.js @@ -404,7 +404,7 @@ QUnit.test('Inline menu', function(assert) { assert.notOk($("#MonthPicker_Button_InlineMenuDiv").length, 'The default button was not created'); - field.MonthPicker('destroy'); + //field.MonthPicker('destroy'); }); QUnit.test('SelectedMonth option', function(assert) { @@ -479,7 +479,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterNextYear was called in the right context' ); }); - var nextYearButton = menu.find('.next-year>button'); + var nextYearButton = menu.find('.next-year>a'); nextYearButton.trigger('click'); assert.ok(OnAfterNextYearTriggered, 'Clicking the next button triggered OnAfterNextYear'); @@ -490,7 +490,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterPreviousYear was called in the right context' ); }); - var previousYearButton = menu.find('.previous-year>button'); + var previousYearButton = menu.find('.previous-year>a'); previousYearButton.trigger('click'); assert.ok(OnAfterPreviousYearTriggerd, 'Clciking rhe previous button triggered OnAfterPreviousYear'); @@ -631,8 +631,8 @@ QUnit.test('Right to left', function (assert) { var menu = $(MonthPicker_RTLField); - var nextYearButton = menu.find('.next-year>button'); - var previousYearButton = menu.find('.previous-year>button'); + var nextYearButton = menu.find('.next-year>a'); + var previousYearButton = menu.find('.previous-year>a'); // Make sure the buttons are pointing in the right (opposite) direction. assert.ok(previousYearButton.find('span.ui-icon-circle-triangle-e').length, 'Previous button is pointed east'); @@ -945,8 +945,8 @@ QUnit.test('Month buttons are disabled', function (assert) { field.MonthPicker('Open'); var menu = $(MonthPicker_RistrictMonthField); - var previousYearButton = menu.find('.previous-year>button'); - var nextYearButton = menu.find('.next-year>button'); + var previousYearButton = menu.find('.previous-year>a'); + var nextYearButton = menu.find('.next-year>a'); // Try to click the disabled buttons. var buttons = menu.find('.month-picker-month-table button'); @@ -1045,7 +1045,7 @@ QUnit.test('Year buttons are disabled', function (assert) { assert.ok(firstVisibleYear, "Clciking the disabled buttons didn't take us to month view"); // Make sure the next years button is disabled. - var nextYearsButton = menu.find('.next-year>button'); + var nextYearsButton = menu.find('.next-year>a'); var isDisabled = nextYearsButton .trigger('click') .is('.ui-button-disabled'); @@ -1054,7 +1054,7 @@ QUnit.test('Year buttons are disabled', function (assert) { var newFirstYrar = parseInt($(buttons[0]).text(), 10); assert.equal(newFirstYrar, firstVisibleYear, "Clicking next year didn't change the year"); - var previousYearsButton = menu.find('.previous-year>button'); + var previousYearsButton = menu.find('.previous-year>a'); // Keep going back until there are no disabled buttons. // We count to 10 to avoid an infinite loop in case there's // a bug where we are going back in time but the the buttons stay disabled. @@ -1227,8 +1227,8 @@ QUnit.test('Today and selected months are highlighted', function (assert) { var buttons = menu.find('.month-picker-month-table button'); var todaysButton = $(buttons[new Date().getMonth()]); - var nextYearButton = menu.find('.next-year>button'); - var previousYearButton = menu.find('.previous-year>button'); + var nextYearButton = menu.find('.next-year>a'); + var previousYearButton = menu.find('.previous-year>a'); assert.ok(todaysButton.is('.ui-state-highlight'), "Today's month is highlighted"); @@ -1288,8 +1288,8 @@ QUnit.test('Number of months from today', function (assert) { // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); - var nextYearButton = menu.find('.next-year>button'); - var previousYearButton = menu.find('.previous-year>button'); + var nextYearButton = menu.find('.next-year>a'); + var previousYearButton = menu.find('.previous-year>a'); var enabledMonths = 0; @@ -1344,8 +1344,8 @@ QUnit.test('Relative month periods', function (assert) { // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); - var nextYearButton = menu.find('.next-year>button'); - var previousYearButton = menu.find('.previous-year>button'); + var nextYearButton = menu.find('.next-year>a'); + var previousYearButton = menu.find('.previous-year>a'); var enabledMonths = 0; // Make sure that 18 buttons + 1 for today are disabled. From e1fa4b89d26efd561468ee1a5d8b5ef15aef85e4 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 5 Dec 2015 19:39:31 +0200 Subject: [PATCH 08/48] Removes the width:60px rule from .month-year-input --- MonthPicker.js | 13 +++++-------- MonthPicker.min.js | 2 +- README.md | 2 +- css/MonthPicker.css | 25 ++++++++++++------------- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.html | 2 +- test/test.js | 4 ++-- 8 files changed, 24 insertions(+), 28 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 239b1f3..8846348 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -1,7 +1,7 @@ /* https://github.com/KidSysco/jquery-ui-month-picker/ -Version 3.0-alpha2 +Version 3.0-alpha3 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -154,7 +154,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } $.MonthPicker = { - VERSION: '3.0-alpha2', // Added in version 2.4; + VERSION: '3.0-alpha3', // Added in version 2.4; i18n: { year: "Year", prevYear: "Previous Year", @@ -169,12 +169,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }; - // - - var _markup = '
' + - '' + + '
' + '' + '' + '
' + @@ -188,9 +185,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
' + '
' + '
' + - '' + + '
' + ''; - + $.widget("KidSysco.MonthPicker", { /******* Properties *******/ diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 3a8c8ad..57d2b7c 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha2",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha3",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus();var c=this;setTimeout(function(){var b=a>0?c._nextButton:c._prevButton;b.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/README.md b/README.md index f7fe4cc..d0099c5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

The jQuery UI Month Picker Version 3.0-alpha2

+

The jQuery UI Month Picker Version 3.0-alpha3

[![Build Status](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker.svg?branch=3.0_prototype)](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 8203dd3..741d18a 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -21,9 +21,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. position: absolute; z-index: 9999; } -.month-year-input { - width: 60px; -} .month-picker .year-container-all { cursor: pointer; } @@ -39,7 +36,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .month-picker-year-table a { border: 1px solid transparent; } - .month-picker-year-table .year-title { margin: 3px; font-size: 12px; @@ -56,25 +52,28 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .month-picker-year-table .year-container { width: 50px; } -.month-picker-year-table .previous-year { +.month-picker-year-table .previous-year>a { /* In case the user's css reset the user agent stylesheet this is often done in RTL pages. */ - text-align: left; + /*text-align: left;*/ + float: left; } -.month-picker-year-table .next-year { - text-align: right; +.month-picker-year-table .next-year>a { + /*text-align: right;*/ + float: right; } -.month-picker-year-table .next-year>button { - margin-right: 0; +.month-picker-year-table td { + padding: 0px; } .month-picker-year-table /*button*/ a { - width: 28px; - width: 1.8em; - height: 1.8em; + /*width: 28px;*/ + margin: 0px; + width: 1.5em; + height: 1.5em; text-align: center; cursor: pointer; } diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 0bd0ee4..d66cfad 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker .year-container-all,.option-link{cursor:pointer}.month-picker{display:inline-block;position:absolute;z-index:9999}.month-year-input{width:60px}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .year-container-all{text-align:center}.month-picker-year-table .year-container{margin:0 auto}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .year-container{width:50px}.month-picker-year-table .previous-year{text-align:left}.month-picker-year-table .next-year{text-align:right}.month-picker-year-table .next-year>button{margin-right:0}.month-picker-year-table button{width:28px;width:1.8em;height:1.8em;text-align:center;cursor:pointer}.month-picker-year-table .year-container{text-align:center}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker .year-container-all,.option-link{cursor:pointer}.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .year-container-all{text-align:center}.month-picker-year-table .year-container{margin:0 auto}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .year-container{width:50px;text-align:center}.month-picker-year-table .previous-year>a{float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table td{padding:0}.month-picker-year-table a{border:1px solid transparent;margin:0;width:1.5em;height:1.5em;text-align:center;cursor:pointer}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index d0a4379..4376acd 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha2",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year button",i).button({text:!1}),this._nextButton=a(".next-year button",i).button({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(a,b){var c=a.trim();c=c.replace(/y/i,'":"y"'),c=c.replace(/m/i,'":"m"');try{var f=JSON.parse('{"'+c.replace(/ /g,',"')+"}"),g={};for(var h in f)g[f[h]]=h;var i=e(new d);return i+=parseInt(g.m,10)||0,i+12*(parseInt(g.y,10)||0)}catch(j){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha3",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===["text","month",void 0].indexOf(b.attr("type"))){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===C[h].indexOf(e[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===[null,""].indexOf(b)){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus();var c=this;setTimeout(function(){var b=a>0?c._nextButton:c._prevButton;b.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.html b/test/test.html index ff57015..5774922 100644 --- a/test/test.html +++ b/test/test.html @@ -3,7 +3,7 @@ jQuery UI Month Picker tests - + + + + + + + + + + + + + + + + + + + + Theme:
+ +

+

+

+ Example:
+ + + \ No newline at end of file From fc99cc497bd8e0feebe6d49ff2118e1808f0ac35 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 18 Dec 2015 17:49:10 +0200 Subject: [PATCH 10/48] Turns the year title into a button that fades in the text Jump Years when you mouse over it --- MonthPicker.js | 306 ++++++++++++++++++++++++-------------------- css/MonthPicker.css | 12 +- 2 files changed, 179 insertions(+), 139 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 6479957..d9b91aa 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -1,7 +1,7 @@ /* https://github.com/KidSysco/jquery-ui-month-picker/ -Version 3.0-alpha3 +Version 3.0-alpha4 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,7 +16,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. */ (function ($, window, document, Date) { 'use strict'; - + // This test must be run before any rererence is made to jQuery. // In case the user didn't load jQuery or jQuery UI the plugin // will fail before it get's to this test + there is no reason @@ -25,7 +25,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. alert(_setupErr + 'The jQuery UI button and datepicker plug-ins must be loaded.'); return; } - + var _speeds = $.fx.speeds; var _eventsNs = '.MonthPicker'; var _disabledClass = 'month-picker-disabled'; @@ -46,8 +46,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }; var _setOptionHooks = { ValidationErrorMessage: '_createValidationMessage', - Disabled: '_setDisabledState', - ShowIcon: '_updateButton', + Disabled: '_setDisabledState', + ShowIcon: '_updateButton', Button: '_updateButton', ShowOn: '_updateFieldEvents', IsRTL: '_setRTL', @@ -62,28 +62,28 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var $proxy = $.proxy; var $datepicker = $.datepicker; var click = 'click' + _eventsNs; - + function _toMonth(date) { return date.getMonth() + (date.getFullYear() * 12); } - + function _toYear(month) { return Math.floor(month / 12); } - + function _stayActive() { $(this).addClass(_selectedClass); } - + function _setActive( el, state ) { return el[ state ? 'on' : 'off' ]('mousenter mouseout', _stayActive ) .toggleClass(_selectedClass, state); } - + function _between(month, from, until) { return (!from || month >= from) && (!until || month <= until); } - + function _encodeMonth(_inst, _val) { if (_val === null) { return _val; @@ -92,7 +92,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else if ($.isNumeric(_val)) { return _toMonth(new Date) + parseInt(_val, 10); } - + var _date = _inst._parseMonth(_val); if (_date) { return _toMonth(_date); @@ -100,14 +100,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return _parsePeriod(_val); } - + function _event(_event, _inst) { return $proxy(_inst.options[_event] || $noop, _inst.element[0]); } - + function _parsePeriod(_val, _initDate) { // Parsing is done by replacing tokens in the value to form - // a JSON object with it's keys and values reversed + // a JSON object with it's keys and values reversed // (example '+1y +2m' will turn into {"+1":"y","+2":"m"}) // After that we just revers the keys and values. var _json = $.trim(_val); @@ -116,11 +116,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. try { var _rev = JSON.parse( '{"' + _json.replace(/ /g, ',"') + '}' ), obj = {}; - + for (var key in _rev) { obj[ _rev[key] ] = key; } - + var _month = _toMonth(new Date); _month += (parseInt(obj.m, 10) || 0); return _month + (parseInt(obj.y, 10) || 0) * 12; @@ -128,7 +128,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return false; } } - + function _makeDefaultButton(options) { // this refers to the associated input field. return $('' + options.i18n.buttonText + '') @@ -140,7 +140,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }); } - + function _applyArrowButton($el, dir) { $el.button('option', { icons: { @@ -148,13 +148,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }); } - + function _isInline(elem) { return !elem.is('input'); } - + $.MonthPicker = { - VERSION: '3.0-alpha3', // Added in version 2.4; + VERSION: '3.0-alpha4', // Added in version 2.4; i18n: { year: "Year", prevYear: "Previous Year", @@ -168,17 +168,21 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. months: ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'June', 'July', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'] } }; - + var _markup = '

' + '
' + '' + '' + '' + '' + '' + @@ -187,7 +191,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
' + '
' + + /* '
' + '' + '' + - '
' + + '' + */ + + ''+ + '
' + ''; - + $.widget("KidSysco.MonthPicker", { /******* Properties *******/ @@ -201,7 +205,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. UseInputMask: false, ValidationErrorMessage: null, Disabled: false, - MonthFormat: 'mm/yy', + MonthFormat: 'mm/yy', Animation: 'fadeToggle', ShowAnim: null, HideAnim: null, @@ -214,9 +218,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _monthPickerButton: $(), - + _validationMessage: $(), - + _selectedBtn: $(), /******* jQuery UI Widget Factory Overrides ********/ @@ -225,7 +229,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _elem = this.element; if (jQuery.mask && this.options.UseInputMask) { _elem.unmask(); - + if (!this.GetSelectedDate()) { _elem.val(''); } @@ -236,12 +240,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $(document).off(_eventsNs + this.uuid); this._monthPickerMenu.remove(); - + var _button = this._monthPickerButton.off(click); if (this._removeOldBtn) { _button.remove(); } - + this._validationMessage.remove(); }, @@ -263,18 +267,18 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } break; } - + // Make sure the user passed in a valid Animation, ShowAnim and HideAnim options values. if (key in _animVals && _animVals[key].indexOf(value) === -1) { alert(_badOptValErr.replace(/%/, key) + _animVals[key]); return; } - + // In jQuery UI 1.8, manually invoke the _setOption method from the base widget. //$.Widget.prototype._setOption.apply(this, arguments); // In jQuery UI 1.9 and above, you use the _super method instead. this._super(key, value); - + _setOptionHooks[key] ? this[ _setOptionHooks[key] ](value) : 0; }, @@ -284,13 +288,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. // An input element with no type attribute specified represents the same thing as an // input element with its type attribute set to "text". // TLDR: - // http://www.w3.org/TR/html5/forms.html#the-input-element + // http://www.w3.org/TR/html5/forms.html#the-input-element // https://api.jquery.com/text-selector/ if (!_el.is('input,div,span') || $.inArray(_el.attr('type'), ['text', 'month', void 0]) === -1) { var error = _setupErr + 'MonthPicker can only be called on text or month inputs.'; // Call alert first so that IE<10 won't trip over console.log and swallow all errors. alert(error + ' \n\nSee (developer tools) for more details.'); - + console.error(error + '\n Caused by:'); console.log(_el[0]); return false; @@ -300,12 +304,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. alert(_setupErr + 'The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com'); return false; } - + if (_opts.Position !== null && !_hasPosition) { alert(_posErr); return false; } - + // Make sure the user passed in a valid Animation, ShowAnim and HideAnim options values. for (var opt in _animVals) { if (_opts[opt] !== null && $.inArray(_opts[opt], _animVals[opt]) === -1) { @@ -313,7 +317,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return false; } } - + this._isMonthInputType = _el.attr('type') === 'month'; if (this._isMonthInputType) { this.options.MonthFormat = this.MonthInputFormat; @@ -322,27 +326,55 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _menu = this._monthPickerMenu = $('
').hide(); var isInline = _isInline(_el); - + $(_markup).appendTo(_menu); (_menu).appendTo( isInline ? _el : document.body ); $('.year-title', _menu).text(this._i18n('year')); - - this._yearContainerAll = + + this._yearContainerAll = $('.year-container-all', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)); + this._yearContainerAll.find('a').css({'cursor': 'default','fontWeight':'bold'}).button({label:'Year 2015'}).removeClass('ui-state-default'); + + + var tOut = null, speed = 125, _yca = this._yearContainerAll[0]; +/*_menu.find('.month-picker-year-table').*/$(_yca).mouseover(function(e) { + var me = this; + if ($.contains(_yca, e.target)) { +tOut = setTimeout(function() { + tOut = null; + /*$(".year-container-all span", me)*/$("span", me).animate({ opacity: .45 },{ + duration: speed, + complete: function() { + $(/*".year-container-all*/"span", me).animate({opacity: 1}, speed).text("Jump Years"); + } + }); +}, 175); } else $(".year-container-all a", me).addClass('ui-state-default') ; +}).mouseout(function(e) { +if (tOut) return clearTimeout(tOut); +var me = this; +if ($.contains(_yca, e.target)) { + $(/*".year-container-all*/ "span", me).animate({ opacity: .45 },{ + duration: speed, + complete: function() { + $("span", me).text("Year 2015").animate({opacity: 1}, speed); + } + }); } else $(".year-container-all a", me).removeClass('ui-state-default') ; +}); + this._createValidationMessage(); this._yearContainer = $('.year', _menu); - + this._prevButton = $('.previous-year a', _menu); this._prevButton.button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); this._nextButton = $('.next-year a', _menu).button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); - + this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. - + var _iconClass = '.ui-button-icon-primary'; $(_iconClass, this._nextButton).text(this._i18n('nextLabel')); $(_iconClass, this._prevButton).text(this._i18n('prevLabel')); @@ -352,14 +384,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var $tr = !(i % 3) ? $('').appendTo($table) : $tr; $tr.append(''); } - + this._buttons = $('button', $table).button(); - + _menu.on(click, function (event) { return false; }); - // Checks and initailizes Min/MaxMonth properties + // Checks and initailizes Min/MaxMonth properties // (creates _setMinMonth and _setMaxMonth methods). var me = this, Month = 'Month'; $.each(['Min', 'Max'], function(i, type) { @@ -368,22 +400,22 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. alert(_badMinMaxVal.replace(/%/, type).replace(/_/, val)); } }; - + me._setOption(type + Month, me.options[type + Month]); }); - + var _selMonth = _opts.SelectedMonth; if (_selMonth !== void 0) { var month = _encodeMonth(this, _selMonth); _el.val( this._formatMonth(new Date( _toYear(month), month % 12, 1)) ); } - + this._updateAlt(); - + this._setUseInputMask(); this._setDisabledState(); this.Destroy = this.destroy; - + if (isInline) { this.Open(); } else { @@ -395,11 +427,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, /****** Publicly Accessible API functions ******/ - + GetSelectedDate: function () { return this._parseMonth(); }, - + GetSelectedYear: function () { var date = this.GetSelectedDate(); return date ? date.getFullYear() : NaN; @@ -409,17 +441,17 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var date = this.GetSelectedDate(); return date ? date.getMonth()+1 : NaN; }, - + Validate: function() { var _date = this.GetSelectedDate(); - + if (this.options.ValidationErrorMessage !== null && !this.options.Disabled) { this._validationMessage.toggle(!_date); } - + return _date; }, - + GetSelectedMonthYear: function () { var date = this.Validate(); return date ? (date.getMonth() + 1) + '/' + date.getFullYear() : null; @@ -445,11 +477,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this.element.val(''); this._validationMessage.hide(); }, - + Toggle: function (event) { return this._visible ? this.Close(event) : this.Open(event); }, - + Open: function (event) { var _elem = this.element, _opts = this.options; if (!_opts.Disabled && !this._visible) { @@ -458,13 +490,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (_event('OnBeforeMenuOpen', this)(event) === false || event.isDefaultPrevented()) { return false; } - + this._visible = true; this._ajustYear(_opts); var _menu = this._monthPickerMenu; this._showMonths(); - + if (_isInline(_elem)) { _menu.css('position', 'static').show(); _event('OnAfterMenuOpen', this)(); @@ -473,22 +505,22 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (_openedInstance) { _openedInstance.Close(event); } - + _openedInstance = this; - + $(document).on(click + this.uuid, $proxy(this.Close, this)) .on('keydown' + _eventsNs + this.uuid, $proxy(this._keyDown, this)); - + // Trun off validation so that clicking one of the months // won't blur the input field and trogger vlaidation // befroe the month was chosen (click event was triggered). // It is turned back on when Hide() is called. _elem.off('blur' + _eventsNs).focus(); - + var _anim = _opts.ShowAnim || _opts.Animation, _noAnim = _anim === 'none'; - - // jQuery UI overrides jQuery.show and dosen't + + // jQuery UI overrides jQuery.show and dosen't // call the start callback. // see: http://api.jqueryui.com/show/ _menu[ _noAnim ? 'fadeIn' : _anim ]({ @@ -498,30 +530,30 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }); } } - + return false; }, - - Close: function (event) { + + Close: function (event) { var _elem = this.element; if (!_isInline(_elem) && this._visible) { - var _menu = this._monthPickerMenu, + var _menu = this._monthPickerMenu, _opts = this.options; - + event = event || $.Event(); if (_event('OnBeforeMenuClose', this)(event) === false || event.isDefaultPrevented()) { return; } - + this._visible = false; _openedInstance = null; $(document).off('keydown' + _eventsNs + this.uuid) .off(click + this.uuid); - + this.Validate(); _elem.on('blur' + _eventsNs, $proxy(this.Validate, this)); var _callback = _event('OnAfterMenuClose', this); - + var _anim = _opts.HideAnim || _opts.Animation; if (_anim === 'none') { _menu.hide(0, _callback); @@ -530,13 +562,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } } }, - + /** * Methods the user can override to use a third party library * such as http://momentjs.com for parsing and formatting months. */ MonthInputFormat: 'yy-mm', - + ParseMonth: function (str, format) { try { return $datepicker.parseDate('dd' + format, '01' + str); @@ -544,7 +576,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return null; } }, - + FormatMonth: function (date, format) { try { return $datepicker.formatDate(format, date) || null; @@ -552,18 +584,18 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return null; } }, - + /****** Private and Misc Utility functions ******/ - - _setSelectedMonth: function (_selMonth) { + + _setSelectedMonth: function (_selMonth) { var month = _encodeMonth(this, _selMonth), _el = this.element; - + if (!month) { _el.val( '' ); } else { _el.val( this._formatMonth( new Date( _toYear(month), month % 12, 1)) ); } - + this._ajustYear(this.options); this._showMonths(); }, @@ -571,21 +603,21 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _i18n: function(str) { return this.options.i18n[str] || $.MonthPicker.i18n[str]; }, - + _parseMonth: function (str, format) { return this.ParseMonth(str || this.element.val(), format || this.options.MonthFormat); }, - + _formatMonth: function (date, format) { return this.FormatMonth(date || this._parseMonth(), format || this.options.MonthFormat); }, _updateButton: function () { var isDisabled = this.options.Disabled; - + this._createButton(); - - // If the button is a jQuery UI button, + + // If the button is a jQuery UI button, // plain HTML button or an input we support disable it, // otherwise the user must handle the diabled state // by creating an appropriate button by passing @@ -604,14 +636,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _createButton: function () { var _elem = this.element, _opts = this.options; if (_isInline(_elem)) return; - + var _oldButton = this._monthPickerButton.off(_eventsNs); var _btnOpt = _opts.ShowIcon ? _opts.Button : false; - + if ($.isFunction(_btnOpt)) { _btnOpt = _btnOpt.call(_elem[0], $.extend(true, {i18n: $.MonthPicker.i18n}, this.options)); } - + var _removeOldBtn = false; this._monthPickerButton = ( _btnOpt instanceof $ ? _btnOpt : $(_btnOpt) ) .each(function() { @@ -621,11 +653,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }) .on(click, $proxy(this.Toggle, this)); - + if (this._removeOldBtn) { _oldButton.remove(); } - + this._removeOldBtn = _removeOldBtn; }, @@ -644,18 +676,18 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _button = this._monthPickerButton; this._validationMessage = _msgEl.insertAfter(_button.length ? _button : _elem); - + _elem.on('blur' + _eventsNs, $proxy(this.Validate, this)); } else { this._validationMessage.remove(); } }, - + _setRTL: function(value) { _applyArrowButton(this._prevButton, !value); _applyArrowButton(this._nextButton, value); }, - + _keyDown: function (event) { // Don't use $.ui.keyCode to help minification. switch (event.keyCode) { @@ -671,7 +703,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. break; } }, - + _duration: function() { var _dur = this.options.Duration; @@ -681,16 +713,16 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return _dur in _speeds ? _speeds[ _dur ] : _speeds._default; }, - + _position: _hasPosition ? function($menu) { var _defauts = this.options.IsRTL ? _RTL_defaultPos : _defaultPos; var _posOpts = $.extend(_defauts, this.options.Position); - + return $menu.position($.extend({of: this.element}, _posOpts)); } : function($menu) { - var _el = this.element, + var _el = this.element, _css = { top: (_el.offset().top + _el.height() + 7) + 'px' }; if (this.options.IsRTL) { @@ -698,14 +730,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else { _css.left = _el.offset().left + 'px'; } - + return $menu.css(_css); }, - + _setUseInputMask: function () { if (!this._isMonthInputType) { try { - if (this.options.UseInputMask) { + if (this.options.UseInputMask) { this.element.mask( this._formatMonth(new Date).replace(/\d/g, 9) ); } else { this.element.unmask(); @@ -716,21 +748,21 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setDisabledState: function () { var isDisabled = this.options.Disabled, _elem = this.element; - + // Disable the associated input field. _elem[0].disabled = isDisabled; _elem.toggleClass(_disabledClass, isDisabled); - + if (isDisabled) { this._validationMessage.hide(); } - + this.Close(); this._updateButton(); _event('OnAfterSetDisabled', this)(isDisabled); }, - + _getPickerYear: function () { return parseInt(this._yearContainer.text(), 10); }, @@ -746,15 +778,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _field.val(this._formatMonth(date, this.options.AltFormat)); } }, - + _chooseMonth: function (month) { var date = new Date(this._getPickerYear(), month-1); this.element.val(this._formatMonth( date )).blur(); this._updateAlt(0, date); - + _setActive( this._selectedBtn, false ); this._selectedBtn = _setActive( $(this._buttons[month-1]), true ); - + _event('OnAfterChooseMonth', this)(date); }, @@ -768,7 +800,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _showMonths: function () { var _months = this._i18n('months'); - + this._prevButton .attr('title', this._i18n('prevYear')) .off(click) @@ -780,7 +812,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .on(click, $proxy(this._addToYear, this, 1)); this._yearContainerAll.css('cursor', 'pointer'); - + this._buttons.off(_eventsNs); var me = this, _onMonthClick = $proxy(me._onMonthClick, me); @@ -789,7 +821,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .on(click, {month: index+1}, _onMonthClick ) .button('option', 'label', monthName); }); - + this._decorateButtons(); }, @@ -806,7 +838,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _firstYear = (_currYear + _yearDifferential), AMOUNT_TO_ADD = 5, _thisYear = new Date().getFullYear(); - + var _minDate = this._MinMonth; var _maxDate = this._MaxMonth; var _minYear = _minDate ? _toYear(_minDate) : 0; @@ -827,53 +859,53 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._buttons.off(_eventsNs); _setActive( this._selectedBtn, false ); - + var _selYear = this.GetSelectedYear(); var _onClick = $proxy(this._onYearClick, this); var _todayWithinBounds = _between(_thisYear, _minYear, _maxYear); var _selWithinBounds = _between(_selYear, _minYear, _maxYear); - + for (var _counter = 0; _counter < 12; _counter++) { var _year = _currYear + _yearDifferential; - + var _btn = $( this._buttons[_counter] ).button({ disabled: !_between(_year, _minYear, _maxYear), label: _year }) .toggleClass(_todayClass, _year === _thisYear && _todayWithinBounds) // Heighlight the current year. .on(click, { year: _year }, _onClick ) - + // Heighlight the selected year. if (_selWithinBounds && _selYear && _selYear === _year) { this._selectedBtn = _setActive( _btn , true ); } - + _yearDifferential++; } }, - + _onMonthClick: function(event) { this._chooseMonth(event.data.month); this.Close(event); }, - + _onYearClick: function(event) { this._chooseYear(event.data.year); }, - + _addToYear: function(amount) { var _year = this._yearContainer; _year.text(parseInt(_year.text()) + amount, 10); this.element.focus(); - + var me = this; setTimeout(function() { var _btn = amount > 0 ? me._nextButton : me._prevButton; _btn.addClass('ui-state-hover'); }, 1); - + this._decorateButtons(); - + _event('OnAfter' + (amount > 0 ? 'Next' : 'Previous') + 'Year', this)(); }, @@ -885,7 +917,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _event('OnAfter' + (amount > 0 ? 'Next' : 'Previous') + 'Years', this)(); }, - + _ajustYear: function(_opts) { var _year = _opts.StartYear || this.GetSelectedYear() || new Date().getFullYear(); if (this._MinMonth !== null) { @@ -894,32 +926,32 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (this._MaxMonth !== null) { _year = Math.min(_toYear(this._MaxMonth), _year); } - + this._setPickerYear( _year ); }, - + _decorateButtons: function() { var _curYear = this._getPickerYear(), _todaysMonth = _toMonth(new Date), _minDate = this._MinMonth, _maxDate = this._MaxMonth; - + // Heighlight the selected month. _setActive( this._selectedBtn, false ); var _sel = this.GetSelectedDate(); var _withinBounds = _between(_sel ? _toMonth(_sel) : null, _minDate, _maxDate); - + if (_sel && _sel.getFullYear() === _curYear) { this._selectedBtn = _setActive( $(this._buttons[_sel.getMonth()]) , _withinBounds ); - } - + } + // Disable the next/prev button if we've reached the min/max year. this._prevButton.button('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); this._nextButton.button('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); - + for (var i = 0; i < 12; i++) { - // Disable the button if the month is not between the + // Disable the button if the month is not between the // min and max interval. var _month = (_curYear * 12) + i, _isBetween = _between(_month, _minDate, _maxDate); - + $(this._buttons[i]) .button({ disabled: !_isBetween }) .toggleClass(_todayClass, _isBetween && _month == _todaysMonth); // Highlights today's month. diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 741d18a..4682d1c 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -1,6 +1,6 @@ /* -The jQuery UI Month Picker Version 3.0-alpha1 +The jQuery UI Month Picker Version 3.0-alpha4 https://github.com/KidSysco/jquery-ui-month-picker/ @@ -53,7 +53,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. width: 50px; } .month-picker-year-table .previous-year>a { - /* + /* In case the user's css reset the user agent stylesheet this is often done in RTL pages. */ @@ -77,6 +77,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. text-align: center; cursor: pointer; } +.year-container-all a { + width: 100%; +} + +.month-picker-year-table .year-container-all span { + padding: inherit; /*padding-bottom: 0 inherit;*/ + } + .month-picker-year-table .year-container { text-align: center; } From 1f677231b9ff0985f7a638b87e942d6c2930e11a Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 18 Dec 2015 19:26:17 +0200 Subject: [PATCH 11/48] Version bump in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0099c5..524f075 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

The jQuery UI Month Picker Version 3.0-alpha3

+

The jQuery UI Month Picker Version 3.0-alpha4

[![Build Status](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker.svg?branch=3.0_prototype)](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) From b1781322e2a33b69bcb298d6fe939506409cb8cf Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 10:37:38 +0200 Subject: [PATCH 12/48] Makes jump years button update it's text when the year changes --- MonthPicker.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index d9b91aa..e643bb7 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -330,17 +330,18 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $(_markup).appendTo(_menu); (_menu).appendTo( isInline ? _el : document.body ); - $('.year-title', _menu).text(this._i18n('year')); + //$('.year-title', _menu).text(this._i18n('year')); this._yearContainerAll = $('.year-container-all', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)); - this._yearContainerAll.find('a').css({'cursor': 'default','fontWeight':'bold'}).button({label:'Year 2015'}).removeClass('ui-state-default'); + this._yearButton = this._yearContainerAll.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); var tOut = null, speed = 125, _yca = this._yearContainerAll[0]; + var _prevText; /*_menu.find('.month-picker-year-table').*/$(_yca).mouseover(function(e) { var me = this; if ($.contains(_yca, e.target)) { @@ -349,10 +350,11 @@ tOut = setTimeout(function() { /*$(".year-container-all span", me)*/$("span", me).animate({ opacity: .45 },{ duration: speed, complete: function() { + _prevText=$(/*".year-container-all*/"span", me).text(); $(/*".year-container-all*/"span", me).animate({opacity: 1}, speed).text("Jump Years"); } }); -}, 175); } else $(".year-container-all a", me).addClass('ui-state-default') ; +}, 175); } else $("a", me).addClass('ui-state-default') ; }).mouseout(function(e) { if (tOut) return clearTimeout(tOut); var me = this; @@ -360,9 +362,9 @@ if ($.contains(_yca, e.target)) { $(/*".year-container-all*/ "span", me).animate({ opacity: .45 },{ duration: speed, complete: function() { - $("span", me).text("Year 2015").animate({opacity: 1}, speed); + $("span", me).text(_prevText).animate({opacity: 1}, speed); } - }); } else $(".year-container-all a", me).removeClass('ui-state-default') ; + }); } else $("a", me).removeClass('ui-state-default') ; }); this._createValidationMessage(); @@ -764,11 +766,14 @@ if ($.contains(_yca, e.target)) { }, _getPickerYear: function () { - return parseInt(this._yearContainer.text(), 10); + //return parseInt(this._yearContainer.text(), 10); + return this._pickerYear; }, _setPickerYear: function (year) { - this._yearContainer.text(year || new Date().getFullYear()); + this._pickerYear = year || new Date().getFullYear(); + this._yearButton.button({ label: this._i18n('year') + ' ' + this._pickerYear }) + //this._yearContainer.text(year || new Date().getFullYear()); }, _updateAlt: function (noop, date) { @@ -894,8 +899,9 @@ if ($.contains(_yca, e.target)) { }, _addToYear: function(amount) { - var _year = this._yearContainer; - _year.text(parseInt(_year.text()) + amount, 10); + //var _year = this._yearContainer; + this._setPickerYear( this._getPickerYear() + amount ); + //_year.text(parseInt(_year.text()) + amount, 10); this.element.focus(); var me = this; @@ -910,8 +916,9 @@ if ($.contains(_yca, e.target)) { }, _addToYears: function(amount) { - var _year = this._yearContainer; - _year.text(parseInt(_year.text()) + amount, 10); + //var _year = this._yearContainer; + //_year.text(parseInt(_year.text()) + amount, 10); + this._setPickerYear( this._getPickerYear() + amount ); this._showYears(); this.element.focus(); From 46dd4823ea9e80f42b02fbedaf4298ebb9e53684 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 16:34:32 +0200 Subject: [PATCH 13/48] Renames classes and properties to reflect the new jump years button structure --- MonthPicker.js | 28 ++++++++++++---------------- css/MonthPicker.css | 20 +++++--------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index e643bb7..635314a 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -174,7 +174,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
' + '' + '' + - '
' + + '' + /* '
' + '' + @@ -332,45 +332,44 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. //$('.year-title', _menu).text(this._i18n('year')); - this._yearContainerAll = - $('.year-container-all', _menu) + var jumpYears = + $('.jump-years', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)); - this._yearButton = this._yearContainerAll.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); + this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); - var tOut = null, speed = 125, _yca = this._yearContainerAll[0]; + var tOut = null, speed = 125, _yca = jumpYears[0]; var _prevText; + var that = this; /*_menu.find('.month-picker-year-table').*/$(_yca).mouseover(function(e) { var me = this; - if ($.contains(_yca, e.target)) { + //if ($.contains(_yca, e.target)) { tOut = setTimeout(function() { tOut = null; /*$(".year-container-all span", me)*/$("span", me).animate({ opacity: .45 },{ duration: speed, complete: function() { _prevText=$(/*".year-container-all*/"span", me).text(); - $(/*".year-container-all*/"span", me).animate({opacity: 1}, speed).text("Jump Years"); + $(/*".year-container-all*/"span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); } }); -}, 175); } else $("a", me).addClass('ui-state-default') ; +}, 175); //} else $("a", me).addClass('ui-state-default') ; }).mouseout(function(e) { if (tOut) return clearTimeout(tOut); var me = this; -if ($.contains(_yca, e.target)) { +//if ($.contains(_yca, e.target)) { $(/*".year-container-all*/ "span", me).animate({ opacity: .45 },{ duration: speed, complete: function() { $("span", me).text(_prevText).animate({opacity: 1}, speed); } - }); } else $("a", me).removeClass('ui-state-default') ; + }); //} else $("a", me).removeClass('ui-state-default') ; }); this._createValidationMessage(); - this._yearContainer = $('.year', _menu); - this._prevButton = $('.previous-year a', _menu); this._prevButton.button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); this._nextButton = $('.next-year a', _menu).button({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); @@ -772,7 +771,7 @@ if ($.contains(_yca, e.target)) { _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); - this._yearButton.button({ label: this._i18n('year') + ' ' + this._pickerYear }) + this._jumpYearsButton.button({ label: this._i18n('year') + ' ' + this._pickerYear }) //this._yearContainer.text(year || new Date().getFullYear()); }, @@ -816,8 +815,6 @@ if ($.contains(_yca, e.target)) { .off(click) .on(click, $proxy(this._addToYear, this, 1)); - this._yearContainerAll.css('cursor', 'pointer'); - this._buttons.off(_eventsNs); var me = this, _onMonthClick = $proxy(me._onMonthClick, me); @@ -860,7 +857,6 @@ if ($.contains(_yca, e.target)) { .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)) .button('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); - this._yearContainerAll.css('cursor', 'default'); this._buttons.off(_eventsNs); _setActive( this._selectedBtn, false ); diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 4682d1c..ea4b742 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -21,18 +21,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. position: absolute; z-index: 9999; } -.month-picker .year-container-all { - cursor: pointer; -} .month-picker-header { margin: 3px 3px 0px 3px; } -.month-picker-year-table .year-container-all { +.month-picker-year-table .jump-years { text-align: center; } -.month-picker-year-table .year-container { - margin: 0 auto; -} .month-picker-year-table a { border: 1px solid transparent; } @@ -49,9 +43,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .month-picker-year-table { width: 100%; } -.month-picker-year-table .year-container { - width: 50px; -} + .month-picker-year-table .previous-year>a { /* In case the user's css reset the user agent stylesheet @@ -77,17 +69,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. text-align: center; cursor: pointer; } -.year-container-all a { + +.jump-years a { width: 100%; } -.month-picker-year-table .year-container-all span { +.month-picker-year-table .jump-years span { padding: inherit; /*padding-bottom: 0 inherit;*/ } -.month-picker-year-table .year-container { - text-align: center; -} .month-picker-month-table td { padding: 0; height: 35px; From e314ddb0d54a9495f893318b8150c5a1661f63e1 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 16:47:45 +0200 Subject: [PATCH 14/48] Ajusts the Start Year Option Tests to the new jump years button structure --- test/test.js | 514 +++++++++++++++++++++++++-------------------------- 1 file changed, 256 insertions(+), 258 deletions(-) diff --git a/test/test.js b/test/test.js index ceea025..0ac59a3 100644 --- a/test/test.js +++ b/test/test.js @@ -43,7 +43,7 @@ QUnit.module("Functionality"); QUnit.test('Icon Option Tests', function (assert) { var _picker = $('#IconDemo').MonthPicker({ - Animation: 'none', + Animation: 'none', ShowIcon: true }); @@ -104,7 +104,7 @@ QUnit.test('HTML 5 & Formatting Tests', function (assert) { }); var _pickerMenu = $('#MonthPicker_Html5'); - + // click the the button to show the monthpicker menu _picker.trigger($.Event('click')); assert.equal(_pickerMenu.length, 1, '#Html5 month picker menu exists in the DOM.'); @@ -178,7 +178,7 @@ QUnit.test('Override Start Year Tests', function (assert) { ShowIcon: false, StartYear: 2023 }); - + done(); } }); @@ -197,7 +197,7 @@ QUnit.test('Start Year Option Tests', function (assert) { assert.equal(_pickerMenu.css('display'), 'block', '#StartYearDemo responded to a text input click event and showed the menu.'); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2025, '#StartYearDemo defaulted to 2025, the year specified in the textbox.'); _picker.MonthPicker('option', 'StartYear', 2095); - assert.equal(parseInt($('.year', _pickerMenu).text(), 10), 2095, '#StartYearDemo switched the year to 2095 after init.'); + assert.equal(parseInt($('.jump-years span', _pickerMenu).text().replace(/\D/g, ''), 10), 2095, '#StartYearDemo switched the year to 2095 after init.'); $('.button-1', _pickerMenu).trigger($.Event('click')); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2095, '#StartYearDemo selected the correct year, 2095, upon choosing a month.'); done(); @@ -210,17 +210,16 @@ QUnit.test('Start Year Option Tests', function (assert) { $('#StartYearDemo').val('1/2025').MonthPicker({ ShowIcon: false, OnAfterMenuOpen: function () { - + // get the picker menu again because it was removed from the dom upon destroying StartYearDemo. _pickerMenu = $('#MonthPicker_StartYearDemo'); assert.equal(_pickerMenu.css('display'), 'block', '#StartYearDemo responded to a text input click event and showed the menu.'); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2025, '#StartYearDemo defaulted to 2025, the year specified in the textbox.'); - $(document).trigger($.Event('click')); + _picker.MonthPicker('Close'); done(); done = assert.async(); }, OnAfterMenuClose: function () { - assert.equal(_pickerMenu.css('display'), 'none', '#StartYearDemo responded to a button click event by closing the menu.'); _picker.MonthPicker('destroy'); // get the picker menu again because it was removed from the dom upon destroying StartYearDemo. @@ -230,33 +229,32 @@ QUnit.test('Start Year Option Tests', function (assert) { $('#StartYearDemo').val('1/2025').MonthPicker({ ShowIcon: false }); - + assert.ok(_pickerMenu.length === 1, "#StartYearDemo has been re-initialized for demo purposes."); done(); } }); - + assert.ok(_pickerMenu.length === 1, "#StartYearDemo has been re-initialized for more tests."); - + done(); done = assert.async(); - - _picker.trigger($.Event('click')); + + _picker.MonthPicker('Open'); } }); var _pickerMenu = $('#MonthPicker_StartYearDemo'); assert.equal(_pickerMenu.length, 1, '#StartYearDemo month picker menu exists in the DOM.'); done = assert.async(); - _picker.trigger($.Event('click')); - + _picker.MonthPicker('Open'); }); QUnit.test('API Tests', function (assert) { var _picker = $('#GetYearDemo').MonthPicker({ ValidationErrorMessage: 'Invalid Date!' }); - + assert.ok($('#MonthPicker_GetYearDemo').length === 1, '#GetYearDemo has been initialized.'); assert.equal(jQuery.type(_picker.MonthPicker('GetSelectedDate')), 'date', '#GetYearDemo GetSelectedDate() API call returned a date object.'); assert.equal(_picker.MonthPicker('GetSelectedDate').getFullYear(), 2012, '#GetYearDemo GetSelectedDate() API call returned a date object containing the correct year, 2012.'); @@ -278,18 +276,18 @@ QUnit.test('API Tests', function (assert) { _picker = $('#EnableDisableDemo').MonthPicker({ Disabled: true }); - + assert.equal(_picker.prop('disabled'), true, '#EnableDisableDemo was initialized into a disabled state.'); _picker.MonthPicker('option', 'Disabled', false); assert.equal(_picker.prop('disabled'), false, '#EnableDisableDemo was enabled by changing the Disabled option.'); _picker.MonthPicker('Disable'); assert.equal(_picker.prop('disabled'), true, '#EnableDisableDemo was disabled using the Disable() API call.'); - + assert.ok(_picker.is('.month-picker-disabled'), 'The input field has the month-picker-disabled class'); - + _picker.MonthPicker('Enable'); assert.equal(_picker.prop('disabled'), false, '#EnableDisableDemo was enabled using the Disable() API call.'); - + assert.notOk(_picker.is('.month-picker-disabled'), 'The month-picker-disabled class was removed from the input field'); }); @@ -303,10 +301,10 @@ QUnit.test('Digital Bush Tests', function (assert) { UseInputMask: true, ValidationErrorMessage: 'Invalid Date!' }); - + assert.equal($('#DigitalBushBoth').MonthPicker('GetSelectedMonthYear'), null, '#DigitalBushBoth GetSelectedMonthYear API call returned null as expected.'); assert.equal($('#MonthPicker_Validation_DigitalBushBoth').css('display'), 'inline', '#DigitalBushBoth showed a validation message about a bad date.'); - + $('#DigitalBushBoth').MonthPicker('Clear'); assert.equal($('#MonthPicker_Validation_DigitalBushBoth').css('display'), 'none', '#DigitalBushBoth cleared the validation error message using the Clear() API call.'); }); @@ -326,27 +324,27 @@ QUnit.test('Keydown handling', function (assert) { var field = $(EventsField).val('').MonthPicker({ Animation: 'none' // Disable animation to make sure opening and closing the menu is synchronous. }); - + field.MonthPicker('Open'); - + field.trigger($.Event('keydown', {keyCode: $.ui.keyCode.ENTER})); assert.equal(field.val(), _today.getMonth()+1 + '/' + _today.getFullYear(), 'Pressing enter selected todays month'); - + var menu = $(MonthPicker_EventsField); assert.ok(!menu.is(':visible'), 'Pressing enter closed the menu'); - + var mayOfNextYear = '05/' + (_today.getFullYear()+1); field.MonthPicker('Open'); field.val( mayOfNextYear ); - + field.trigger($.Event('keydown', {keyCode: $.ui.keyCode.ENTER})); assert.ok(!menu.is(':visible'), 'Pressing enter closed the menu'); assert.equal(field.val(), mayOfNextYear, "Pressing enter didn't override the month the user entered"); - + field.MonthPicker('Open'); field.trigger($.Event('keydown', {keyCode: $.ui.keyCode.ESCAPE})); assert.ok(!menu.is(':visible'), 'Pressing escape closed the menu'); - + field.MonthPicker('Destroy'); }); @@ -354,19 +352,19 @@ QUnit.test('MonthFormat Option Tests', function (assert) { // Create a month picker with a funky month format. $(FormatField).val('10---> {2010}').MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MonthFormat: 'm---> {yy}' }); - + // Make sure the plugin parsed the month correctly (the date value is undefined). var selectedDate = $(FormatField).MonthPicker('GetSelectedDate'); assert.equal(selectedDate.getFullYear(), 2010, 'The selected year is 2010'); assert.equal(selectedDate.getMonth() + 1, 10, 'The selected month is October'); - + // Change the format after init to sonething more appropriate. $(FormatField).MonthPicker('option', 'MonthFormat', 'MM yy'); assert.equal($(FormatField).val(), 'October 2010', 'the text was updated to reflect the new format'); - + // Make sure the plugin parsed the month according to the new format. selectedDate = $(FormatField).MonthPicker('GetSelectedDate'); assert.equal(selectedDate.getFullYear(), 2010, 'The selected year is still 2010'); @@ -376,11 +374,11 @@ QUnit.test('MonthFormat Option Tests', function (assert) { selectedDate = $(FormatField).MonthPicker('GetSelectedDate'); assert.equal(selectedDate.getFullYear(), 2012, 'The selected year changed to 2012'); assert.equal(selectedDate.getMonth() + 1, 1, 'The selected month changed to January'); - + // Open the menu and choose April 2012. $(FormatField).MonthPicker('Open'); $('.button-4', MonthPicker_FormatField).trigger('click'); - + // Make sure set the right text in the input field. assert.equal($(FormatField).val(), 'April 2012', 'The text field has the value April 2012'); }); @@ -389,58 +387,58 @@ QUnit.test('Inline menu', function(assert) { var field = $(InlineMenuDiv).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. }); - + var menu = $(MonthPicker_InlineMenuDiv); - + assert.ok(menu.width() <= 200, 'The menu is visible and has the expected width'); - + $(document.body).trigger('click'); - + assert.ok(menu.is(':visible'), 'The menu is still visible after clicking outside the menu'); - + menu.find('.button-1').trigger('click'); - + assert.ok(menu.is(':visible'), 'The menu is still visible after choosing a month'); - + assert.notOk($("#MonthPicker_Button_InlineMenuDiv").length, 'The default button was not created'); - + //field.MonthPicker('destroy'); }); QUnit.test('SelectedMonth option', function(assert) { var field = $(InlineMenuDiv).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + SelectedMonth: 0 }); - + var menu = $(MonthPicker_InlineMenuDiv); var date = field.MonthPicker('GetSelectedDate'); assert.equal( date.getMonth(), _today.getMonth(), 'The correct month was selected'); assert.equal( date.getFullYear(), _today.getFullYear(), 'The correct year was selected'); - + assert.ok( menu.find('.button-' + (_today.getMonth()+1)).is('.ui-state-active'), 'The correct button is highlighted'); - + field.MonthPicker('option', 'SelectedMonth', '01/2015'); - + var date = field.MonthPicker('GetSelectedDate'); assert.ok( menu.find('.button-1').is('.ui-state-active'), 'January is selected after changing the SelectedMonth'); - + field.MonthPicker('Destroy'); }); // Makes sure that all events are triggered as expected. // Perhaps we should consider removing some of these events. QUnit.test('Events and context', function (assert) { // A.k.a duplicate code test. - // Good luck figuring out which callback is causing the + // Good luck figuring out which callback is causing the // problem if this test fails. assert.expect(31); - + var field = $(EventsField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. ShowOn: 'both' }); - + var menu = $(MonthPicker_EventsField); var OnBeforeMenuOpenTriggred = false; // This event should be triggered twice, the first time it is prevented @@ -448,90 +446,90 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes field.MonthPicker('option', 'OnBeforeMenuOpen', function(event) { OnBeforeMenuOpenTriggred = true; assert.equal( this, EventsField, 'OnBeforeMenuOpen was called in the right context' ); - + // Prevent opening if the event was triggered on the input field. if (event.target === EventsField) { event.preventDefault(); } }); - + // Make sure the open event triggered by clicking the field was prevented. field.trigger('click'); assert.ok(OnBeforeMenuOpenTriggred, 'The OnBeforeMenuOpen event was triggered'); assert.notOk( menu.is(':visible'), 'The open event was prevented when clicking on the field' ); - + var OnAfterMenuOpenTriggred = false; field.MonthPicker('option', 'OnAfterMenuOpen', function() { OnAfterMenuOpenTriggred = true; assert.equal( this, EventsField, 'OnAfterMenuOpen was called in the right context' ); }); - + // Make sure calling the open method doesn't get prevented. field.MonthPicker('Open'); assert.ok(OnAfterMenuOpenTriggred, 'The OnAfterMenuOpen event was triggered'); assert.ok( menu.is(':visible'), 'The menu was opend by calling the Open method' ); - + // Start duplicate code var OnAfterNextYearTriggered = false; field.MonthPicker('option', 'OnAfterNextYear', function() { OnAfterNextYearTriggered = true; - + assert.equal( this, EventsField, 'OnAfterNextYear was called in the right context' ); }); - + var nextYearButton = menu.find('.next-year>a'); nextYearButton.trigger('click'); assert.ok(OnAfterNextYearTriggered, 'Clicking the next button triggered OnAfterNextYear'); - + var OnAfterPreviousYearTriggerd = false; field.MonthPicker('option', 'OnAfterPreviousYear', function() { OnAfterPreviousYearTriggerd = true; - + assert.equal( this, EventsField, 'OnAfterPreviousYear was called in the right context' ); }); - + var previousYearButton = menu.find('.previous-year>a'); previousYearButton.trigger('click'); assert.ok(OnAfterPreviousYearTriggerd, 'Clciking rhe previous button triggered OnAfterPreviousYear'); - + var OnAfterChooseYearsTriggerd = false; field.MonthPicker('option', 'OnAfterChooseYears', function() { OnAfterChooseYearsTriggerd = true; assert.equal( this, EventsField, 'OnAfterChooseYears was called in the right context' ); }); - + var showYearsButton = menu.find('.year-container-all'); showYearsButton.trigger('click'); - + assert.ok(OnAfterChooseYearsTriggerd, 'Clicking the show years button triggered OnAfterChooseYears'); - + var OnAfterNextYearsTriggered = false; field.MonthPicker('option', 'OnAfterNextYears', function() { OnAfterNextYearsTriggered = true; assert.equal( this, EventsField, 'OnAfterNextYears was called in the right context' ); }); - + nextYearButton.trigger('click'); assert.ok(OnAfterChooseYearsTriggerd, 'Clicking the next button triggered the OnAfterNextYears event'); - + var OnAfterPreviousYearsTriggered = false; field.MonthPicker('option', 'OnAfterPreviousYears', function() { OnAfterPreviousYearsTriggered = true; assert.equal( this, EventsField, 'OnAfterPreviousYears was called in the right context' ); }); - + previousYearButton.trigger('click'); assert.ok(OnAfterPreviousYearsTriggered, 'Clicking the prev button triggered the OnAfterPreviousYears event'); - + var OnAfterChooseYearTriggered = false; field.MonthPicker('option', 'OnAfterChooseYear', function() { OnAfterChooseYearTriggered = true; assert.equal( this, EventsField, 'OnAfterChooseYear was called in the right context' ); }); - + menu.find('.button-1').trigger('click'); assert.ok(OnAfterChooseYearTriggered, 'Clicking a year triggered OnAfterChooseYear'); - + var OnAfterChooseMonthTriggered = false; field.MonthPicker('option', 'OnAfterChooseMonth', function(date) { assert.ok(date instanceof Date, 'A date value was passed to OnAfterChooseMonth as the first argument'); @@ -539,84 +537,84 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterChooseMonth was called in the right context' ); }); // End duplicate code - + // This event should be triggered twice, the first time it is prevented // and the sceond time it goes through. field.MonthPicker('option', 'OnBeforeMenuClose', function(event) { assert.equal( this, EventsField, 'OnBeforeMenuClose was called in the right context' ); - + var target = event.target, btn1 = menu.find('.button-1')[0]; if (event.target === btn1) { event.preventDefault(); } }); - + // Click January which should triger the OnAfterChooseMonth event // but the OnBeforeMenuClose will be prevented. menu.find('.button-1').trigger('click'); assert.ok(OnAfterChooseMonthTriggered, 'Clicking January triggered OnAfterChooseMonth'); assert.ok( menu.is(':visible'), 'The close event was canceled' ); field.MonthPicker('option', 'OnAfterChooseMonth', $.noop); - + var OnAfterMenuCloseTriggered = false; field.MonthPicker('option', 'OnAfterMenuClose', function(event) { OnAfterMenuCloseTriggered = true; - assert.equal( this, EventsField, 'OnAfterMenuClose was called in the right context' ); + assert.equal( this, EventsField, 'OnAfterMenuClose was called in the right context' ); }); - + // Clicking May should not be prevented. menu.find('.button-5').trigger('click'); assert.ok( !menu.is(':visible'), 'Clicking May closed the menu' ); assert.ok(OnAfterMenuCloseTriggered, 'Clicking May triggered the OnAfterMenuClose event'); - - + + field.MonthPicker('option', 'OnAfterSetDisabled', function(disabled) { - assert.equal( this, EventsField, 'OnAfterSetDisabled was called in the right context' ); - + assert.equal( this, EventsField, 'OnAfterSetDisabled was called in the right context' ); + assert.ok(disabled, 'Disabling the field passed true as the first argument to the OnAfterSetDisabled callback'); }); - + field.MonthPicker('Disable'); - + field.MonthPicker('option', 'OnAfterSetDisabled', function(disabled) { assert.notOk(disabled, 'Enabling the field passed false as the first argument to the OnAfterSetDisabled callback'); }); - + field.MonthPicker('Enable'); - + field.MonthPicker('destroy'); }); QUnit.test('AltField and AltFormat tests', function( assert ) { var hiddenField = $(''); - + var field = $(MainAltField).MonthPicker({ SelectedMonth: '05/2010', Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. AltField: hiddenField, AltFormat: 'yy-mm' }); - + assert.equal(hiddenField.val(), '2010-05', "The secondary field has the main field's value in the alt format"); - + field.MonthPicker('Open'); - + var menu = $(MonthPicker_MainAltField); menu.find('.button-1').trigger('click'); - + assert.equal( field.val(), '01/2010', 'The main field was populated'); assert.equal( hiddenField.val(), '2010-01', 'The secondary field was populated with a different format'); - + field.MonthPicker('option', 'AltFormat', null); - + assert.equal( hiddenField.val(), '01/2010', 'Clearing AltFormat set the format to the MonthFormat'); - + field.MonthPicker('option', 'AltField', '#SecondaryAltField'); - + assert.equal( $(SecondaryAltField).val(), '01/2010', 'Changing the altField after init assigned the current value'); - + field.val('11/2015').trigger('change'); - + assert.equal( $(SecondaryAltField).val(), '11/2015', 'Triggering a change event on the main field updated the secondary field'); }); @@ -626,23 +624,23 @@ QUnit.test('Right to left', function (assert) { Position: {collision: 'none'}, // Ensure the menu opens to the right. IsRTL: true }); - + field.MonthPicker('Open'); - + var menu = $(MonthPicker_RTLField); - + var nextYearButton = menu.find('.next-year>a'); var previousYearButton = menu.find('.previous-year>a'); - + // Make sure the buttons are pointing in the right (opposite) direction. assert.ok(previousYearButton.find('span.ui-icon-circle-triangle-e').length, 'Previous button is pointed east'); assert.ok(nextYearButton.find('span.ui-icon-circle-triangle-w').length, 'Next button is pointed west'); - + // Make sure the menu opens to the right of the field. //alert(field.position().left - menu.position().left); var opendToTheRight = (field.position().left - menu.position().left) > 5; assert.ok(opendToTheRight, 'The menu opened to the right of the field'); - + //field.MonthPicker('Close'); }); @@ -650,45 +648,45 @@ QUnit.test('Toggle method', function (assert) { var field = $(ToggleField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. }); - + field.MonthPicker('Toggle'); - + var menu = $(MonthPicker_ToggleField); - + assert.ok(menu.is(':visible'), 'The menu was opened'); - + field.MonthPicker('Toggle'); - + assert.ok(!menu.is(':visible'), 'The menu was closed'); - + field.MonthPicker('Toggle'); - + assert.ok(menu.is(':visible'), 'The menu was again'); - - field.MonthPicker('Close'); + + field.MonthPicker('Close'); }); QUnit.module("Button option"); QUnit.test('Plain HTML Button test', function (assert) { - // Creats a month picker with a button similar to Datepicker's default button. + // Creats a month picker with a button similar to Datepicker's default button. $(PlainButtonField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. Button: '' }); - + // Make the button was properly construted and is visible in the expected location. assert.ok($(PlainButton).is(':visible'), 'The plain button is present in the DOM and is visible.'); assert.equal($(PlainButton).prev()[0], PlainButtonField, 'The button was placed near the associated input field'); assert.equal(PlainButton.tagName, 'BUTTON', 'PlainButton is a button tag'); assert.equal($(PlainButton).text(), '...', 'The button has the correct label'); - + // Click the button and make sure the menu opens. $(PlainButton).trigger('click'); assert.ok($(MonthPicker_PlainButtonField).is(':visible'), 'Clicking the plain button opened the correct menu.'); assert.equal($('.month-picker').filter(':visible').length, 1, 'There is only one menu opened.'); - - // Disable the field (which implicitly closes the menu) + + // Disable the field (which implicitly closes the menu) // and make sure the button is also disabled. $(PlainButtonField).MonthPicker('Disable'); @@ -696,15 +694,15 @@ QUnit.test('Plain HTML Button test', function (assert) { assert.ok($(PlainButton).is(':disabled'), 'The button was disabled.'); assert.ok($(MonthPicker_PlainButtonField).is(':hidden'), 'The menu was closed.'); assert.equal($('.PlainButton').length, 1, "There's only one plain button in the DOM."); - + // Make sure clicking the button doesn't open the menu. $(PlainButton).trigger('click'); assert.ok($(MonthPicker_PlainButtonField).is(':hidden'), "Clicking the button didn't open the menu."); - - $(PlainButtonField).MonthPicker({ + + $(PlainButtonField).MonthPicker({ Button: '' }); - + assert.ok($(InputBtn).is(':disabled'), 'The new button is disabled'); }); @@ -713,25 +711,25 @@ QUnit.test('Img tag tests', function (assert) { // The image should change according to the Disabled state. $(ImgButtonField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + Button: function (options) { var src = 'calendar' + (options.Disabled ? '-disabled' : '') + '.gif'; return ''; } }); - + // Make the image was properly construted and is visible in the expected location. // NOTE: We don't check that the image is visible because it isn't visible // until it was loaded. assert.equal($(ImgButton).prev()[0], ImgButtonField, 'The image button was placed near the associated input field.'); assert.equal($(ImgButton).attr('src'), 'calendar.gif', 'The button has the enabled image.'); - + // Click the image and make sure the menu opens. $(ImgButton).trigger('click'); assert.ok($(MonthPicker_ImgButtonField).is(":visible"), 'Clicking the plain button opened the correct menu.'); assert.equal($('.month-picker').filter(':visible').length, 1, 'There is only one menu opened.'); - - // Disable the field (which implicitly closes the menu) + + // Disable the field (which implicitly closes the menu) // and make sure the button is also disabled. $(ImgButtonField).MonthPicker('Disable'); @@ -741,7 +739,7 @@ QUnit.test('Img tag tests', function (assert) { assert.equal($(ImgButton).attr('src'), 'calendar-disabled.gif', 'The button has the disabled image.'); assert.equal($('.ImgButton').length, 1, "There's only one image button in the DOM."); - + // Make sure clicking the button doesn't open the menu. $(ImgButton).trigger('click'); assert.ok($(MonthPicker_ImgButtonField).is(':hidden'), "Clicking the button didn't open the menu."); @@ -756,7 +754,7 @@ QUnit.test('Existing element tests', function (assert) { // Creats a month picker with an existing external element as a button. $(ExistingButtonField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + Button: function (options) { var enabledButton = $(this).next().hide(); var disabledButton = $(enabledButton).next().hide(); @@ -764,17 +762,17 @@ QUnit.test('Existing element tests', function (assert) { return options.Disabled ? disabledButton.show() : enabledButton.show(); } }); - + // Make sure only the enabled element is visible. assert.ok($(ExistingButton).is(':visible'), 'The enabled element is visible.'); assert.ok($(DisabledExistingButton).is(':hidden'), 'The disabled element is hidden.'); - + // Click the element and make sure the menu opens. $(ExistingButton).trigger('click'); assert.ok($(MonthPicker_ExistingButtonField).is(":visible"), 'Clicking the plain button opened the correct menu.'); assert.equal($('.month-picker').filter(':visible').length, 1, 'There is only one menu opened.'); - - // Disable the field (which implicitly closes the menu) + + // Disable the field (which implicitly closes the menu) // and make sure the button is also disabled. $(ExistingButtonField).MonthPicker('Disable'); assert.ok($(ExistingButtonField).is(':disabled'), 'The input field was disabled.'); @@ -782,66 +780,66 @@ QUnit.test('Existing element tests', function (assert) { assert.ok($(DisabledExistingButton).is(':visible'), 'The disabled element is visible.'); assert.ok($(MonthPicker_ExistingButtonField).is(':hidden'), 'The menu was closed.'); - + // Make sure clicking the disabled element doesn't open the menu. $(DisabledExistingButton).trigger('click'); assert.ok($(MonthPicker_ExistingButtonField).is(':hidden'), "Clicking the disabled element didn't open the menu."); - + // Re-enable the menu and make sure it opens when you click on the fit $(ExistingButtonField).MonthPicker('Enable'); $(ExistingButton).trigger('click'); assert.ok($(MonthPicker_ExistingButtonField).is(':visible'), "Clicking the enabled element after re-enabling opend the menu"); - + // Close the menu to make sure that clicking the button the click event. // In case it wasen't removed triggering a click should throw an error. $(ExistingButtonField).MonthPicker('Close'); - - // Make sure we don't remove existing elements when the plugin is destroyed. + + // Make sure we don't remove existing elements when the plugin is destroyed. $(ExistingButtonField).MonthPicker('destroy'); assert.equal($("#MonthPicker_ExistingButtonField").length, 0, 'The meun was removed from the DOM'); assert.ok(ExistingButton, 'The existing button was not removed from the DOM'); - + // Make sure that clicking the existing element after destroying - // the plugin doesn't thorw an error. + // the plugin doesn't thorw an error. $(ExistingButton).trigger('click'); }); QUnit.test('Change selector after init', function (assert) { - // In this test we are going to change the Button option to a jQuery selector + // In this test we are going to change the Button option to a jQuery selector // aftet the plugin was initialized. $(SelectorButtonField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + Button: '#SelectorButton' }); - + // Click the element and make sure the menu opens. $(SelectorButton).trigger('click'); assert.ok($(MonthPicker_SelectorButtonField).is(":visible"), 'Clicking the button opened the correct menu.'); assert.equal($('.month-picker').filter(':visible').length, 1, 'There is only one menu opened.'); - + // Close the menu and change the button after initialization. $(SelectorButtonField).MonthPicker('Close'); $(SelectorButtonField).MonthPicker('option', 'Button', '#OtherSelectorButton'); - + // Make sure the buttons remain untouched. assert.ok($(SelectorButton).is(':visible'), 'The enabled element was not touched.'); - + // Make sure clicking the old button doesn't open the menu (the event listeners were removed). $(SelectorButton).trigger('click'); assert.ok($(MonthPicker_SelectorButtonField).is(":hidden"), "Clicking the old button didn't open the menu"); - + // Make sure clicking the new button opens the menu. $(OtherSelectorButton).trigger('click'); assert.ok($(MonthPicker_SelectorButtonField).is(":visible"), 'Clicking the other button opened the correct menu.'); - + // Close the menu to make sure that clicking the button the click event. // In case it wasen't removed triggering a click should throw an error. $(SelectorButtonField).MonthPicker('Close'); - + // Destroy the plugin and make sure the event listeners were removed. $(SelectorButtonField).MonthPicker('destroy'); @@ -853,7 +851,7 @@ QUnit.test('Disable button', function (assert) { // Create a month picker and make sure that clicking the input field opens the menu. var field = $(NoButtonField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + Button: false }); @@ -868,34 +866,34 @@ QUnit.test('Disable button', function (assert) { // Make pressing tab closes the menu. field.trigger($.Event( "keydown", { keyCode: $.ui.keyCode.TAB } )); assert.notOk(menu.is(':visible'), 'The menu was closed by pressing tab'); - + // Make sure that clicking the input field opens the menu. $(NoButtonField).trigger('click'); assert.ok(menu.is(':visible'), 'Clicking the input field opened the correct menu.'); - + // Don't leave the menu open (not really necessary). $(NoButtonField).MonthPicker('Disable'); - + // Make sure clicking the input field when it's disabled doesn't open the menu. $(NoButtonField).trigger('click'); assert.ok(menu.is(':hidden'), 'Clicking the input field did not open the menu.'); - + // Don't leave the menu open (not really necessary). $(NoButtonField).MonthPicker('Enable'); - + // Fails the test if the menu was closed after clicking the input field again. $(NoButtonField).MonthPicker({ OnBeforeMenuClose: function () { assert.notOk(true, "The menu shouldn't closed after clicking the input field again."); } }); - + // Make sure that clicking the input field still opens the menu. $(NoButtonField).trigger('click'); assert.ok(menu.is(':visible'), 'Clicking the input field still openes the correct menu.'); $(NoButtonField).trigger('click'); - + // Don't leave the menu open (not really necessary). $(NoButtonField).MonthPicker('ClearAllCallbacks'); $(NoButtonField).MonthPicker('Close'); @@ -907,20 +905,20 @@ QUnit.test('ShowOn both', function (assert) { Button: '', ShowOn: 'both' }); - + field.trigger('click'); - + var menu = $(MonthPicker_ShowOnBothField); - + assert.ok(menu.is(':visible'), 'The menu was opened by clicking on the input field'); - + field.MonthPicker('Close'); - + assert.ok(!menu.is(':visible'), 'The menu was closed'); - + $(ShowOnBtn).trigger('click'); assert.ok(menu.is(':visible'), 'The menu was opened by clicking on the button'); - + field.MonthPicker('Close'); assert.notOk(menu.is(':visible'), 'The menu was closed'); @@ -938,69 +936,69 @@ QUnit.module("Min/MaxMonth"); QUnit.test('Month buttons are disabled', function (assert) { var field = $(RistrictMonthField).val('12/2015').MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MinMonth: '10/2015' }); - + field.MonthPicker('Open'); - + var menu = $(MonthPicker_RistrictMonthField); var previousYearButton = menu.find('.previous-year>a'); var nextYearButton = menu.find('.next-year>a'); - + // Try to click the disabled buttons. var buttons = menu.find('.month-picker-month-table button'); $(buttons.slice(0, 8)).trigger('click'); - + assert.ok(previousYearButton.is('.ui-button-disabled'), 'The previous year button is disabled'); - - // Make sure that the date didn't change as a + + // Make sure that the date didn't change as a // result of clicking the disabled button. var selectedMonth = field.MonthPicker('GetSelectedDate'); assert.equal( selectedMonth.getFullYear(), 2015, 'The selected year is still 2015'); assert.equal( selectedMonth.getMonth() + 1, 12, 'The selected month is still December'); assert.equal( field.val(), '12/2015', 'The input field still has the value 12/2015' ); - + // Make sure we can still go to the next year. nextYearButton.trigger('click'); var pickerYear = parseInt(menu.find('.year').text(), 10); assert.equal(pickerYear, 2016, 'Clicking next year changed the year to 2016'); - + // Make none of the buttons are disabled. assert.ok( !menu.find('button').is('.ui-button-disabled'), 'None of the buttons are disabled'); - + // Make sure clicking the first button selected January 2016. menu.find('.button-1').trigger('click'); var selectedMonth = field.MonthPicker('GetSelectedDate'); assert.equal( selectedMonth.getFullYear(), 2016, 'The selected year is still 2016'); assert.equal( selectedMonth.getMonth() + 1, 1, 'The selected month is still January'); assert.equal( field.val(), '01/2016', 'The input field has the value 01/2016' ); - + // Make sure we can only go back to 2015 a.k.a the minimum year. previousYearButton.trigger('click'); previousYearButton.trigger('click'); - + var pickerYear = parseInt(menu.find('.year').text(), 10); assert.equal(pickerYear, 2015, 'clicking previous year tweice keept the year at 2015'); - + // Make sure that month buttons before October (the minimum month) // are still disabled after navigating back to 2015 - // by clicking the buttons and checking that the + // by clicking the buttons and checking that the // selected date didn't change. $(buttons.slice(0, 8)).trigger('click'); - + var selectedMonth = field.MonthPicker('GetSelectedDate'); assert.equal( selectedMonth.getFullYear(), 2016, "Clciking the buttons didn't change the selected year"); assert.equal( selectedMonth.getMonth() + 1, 1, "Clciking the buttons didn't change the selected month"); assert.equal( field.val(), '01/2016', "Clciking the buttons didn't change the fields value" ); - + // Make sure the buttons after October (the minumum month) are enabled. var buttonsDisabled = $( buttons.slice(9) ).is('.ui-button-disabled'); assert.notOk(buttonsDisabled, 'All buttons after the minumum month are enabled'); // Make sure clicking October (the minumum month) works as expected. $(buttons[9]).trigger('click'); - + var selectedMonth = field.MonthPicker('GetSelectedDate'); assert.equal( selectedMonth.getFullYear(), 2015, 'Clciking the minimum month chose the correct year'); assert.equal( selectedMonth.getMonth() + 1, 10, 'Clciking the minimum month chose the correct month'); @@ -1014,10 +1012,10 @@ QUnit.test('Month buttons are disabled', function (assert) { QUnit.test('Year buttons are disabled', function (assert) { var field = $(RistrictMonthField).val('02/2015').MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MaxMonth: '10/2015' }); - + field.MonthPicker('Open'); var menu = $(MonthPicker_RistrictMonthField); @@ -1082,7 +1080,7 @@ QUnit.test('Year buttons are disabled', function (assert) { // Check if we still have diabled button. if (!buttons.is('.ui-button-disabled')) { - // We don't have disabled buttons, make sure both next and previous + // We don't have disabled buttons, make sure both next and previous // years buttons are enabled. assert.ok(!previousYearsButton.is('.ui-button-disabled'), 'previous year button is enabled'); assert.ok(!nextYearsButton.is('.ui-button-disabled'), 'next year button is enabled'); @@ -1090,7 +1088,7 @@ QUnit.test('Year buttons are disabled', function (assert) { } } - // Make sure we didn't click back 10 times and we + // Make sure we didn't click back 10 times and we // still have disabled buttons. assert.ok(!buttons.is('.ui-button-disabled'), 'All year buttons are enabled after clicking previous years ' + i + ' times'); @@ -1141,74 +1139,74 @@ QUnit.test('Year buttons are disabled', function (assert) { // Here we make sure that if the user types in a year // that is outside the restricted range the menu will // open in the closest year that is within range, for example: -// +// // If the MinMonth is: 10/2015 and the user types in 11/2020 // the menu will open and show the year 2015. // // This test purposely juggles between types to ensure // that passing in different types before and after init works -// as expected. +// as expected. QUnit.test('Menu opens within range', function (assert) { var field = $(RistrictMonthField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MinMonth: '01/2013', MaxMonth: new Date(2016, 11 - 1) }); - + var menu = $(MonthPicker_RistrictMonthField); - - // Make sure the menu opens in the year 2013 even if the user + + // Make sure the menu opens in the year 2013 even if the user // types in 02/2010. field.val('02/2010'); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2013, 'The menu opend at the minimum year (2013) and not 2010' ); - + field.MonthPicker('Close'); - - // Make sure the menu opens in the year 2016 even if the user + + // Make sure the menu opens in the year 2016 even if the user // types in 02/2020. field.val('12/2020'); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2016, 'The menu opend at the maximum year (2016) and not 2020' ); - + field.MonthPicker('Close'); - + // Make sure that the menu will open at the year 2018 // If we change the MaxMonth option. field.MonthPicker('option', 'MaxMonth', '12/2018'); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2018, 'The menu opend at the year 2018 after changing the MaxMonth option' ); - + field.MonthPicker('Close'); - - // Make sure the menu opens at the the selected year if the MaxMonth + + // Make sure the menu opens at the the selected year if the MaxMonth // is greater than the selected month. field.MonthPicker('option', 'MaxMonth', new Date(2021, 12 - 1)); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2020, 'The menu opend at the the selected year 2020 after' ); - + field.MonthPicker('Close'); - + field.MonthPicker('option', 'MinMonth', new Date(2010, 12 - 1)); field.val('02/2009'); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2010, 'The menu opend at the year 2010 after chagnig the MinMonth option' ); - + field.MonthPicker('Close'); - + // Make sure the menu opens at the selected year the MinMonth option // to soemthing smaller than the selected month. field.MonthPicker('option', 'MinMonth', new Date(2008, 04)); field.MonthPicker('Open'); - + assert.equal(menu.find('.year').text(), 2009, 'The menu opend at the selected year after changing the MinMonth option again' ); - + // Destroy the plugin so we can use the field over again // in another Min/MaxMonth test. field.MonthPicker('destroy'); @@ -1218,55 +1216,55 @@ QUnit.test('Today and selected months are highlighted', function (assert) { var field = $(highlightedField).MonthPicker({ Animation: 'none' // Disable animation to make sure opening and closing the menu is synchronous. }); - + field.val('05/' + _today.getFullYear()); - + field.MonthPicker('Open'); var menu = $(MonthPicker_highlightedField); - + var buttons = menu.find('.month-picker-month-table button'); - + var todaysButton = $(buttons[new Date().getMonth()]); var nextYearButton = menu.find('.next-year>a'); var previousYearButton = menu.find('.previous-year>a'); - + assert.ok(todaysButton.is('.ui-state-highlight'), "Today's month is highlighted"); - + var selectedButton = buttons.filter('.ui-state-active'); assert.equal( selectedButton.length, 1, 'There is one selected button'); assert.equal( selectedButton[0], buttons[4], 'The selected month is highlighted'); - + nextYearButton.trigger('click'); - + assert.notOk(todaysButton.is('.ui-state-highlight'), 'Going to the next year removed highlighting'); - + var selectedButton = buttons.filter('.ui-state-active'); assert.equal( selectedButton.length, 0, 'Going to the next year removed the selected highlighting'); - + previousYearButton.trigger('click'); - + assert.ok(todaysButton.is('.ui-state-highlight'), 'Returning to this year returnd the highlighting'); - + var selectedButton = buttons.filter('.ui-state-active'); assert.equal( selectedButton.length, 1, 'There is one selected button'); assert.equal( selectedButton[0], buttons[4], 'The selected month is highlighted'); - + menu.find('.year').trigger('click'); - + var selectdBtn = buttons.filter('.ui-state-active'); assert.equal( selectdBtn.button( "option", "label" ), _today.getFullYear(), 'The selected year is highlighted'); - + var todayBtn = buttons.filter('.ui-state-highlight'); assert.equal( todayBtn.button( "option", "label" ), _today.getFullYear(), "Today's year is highlighted"); - + field.MonthPicker('Close'); field.MonthPicker({MinMonth: 1}); - + field.MonthPicker('Open'); - + var selectedButton = buttons.filter('.ui-state-highlight'); assert.equal( selectedButton.length, 0, "Today is not highlighted because it's before the min month"); - + var selectedButton = buttons.filter('.ui-state-active'); assert.equal( selectedButton.length, 0, 'The selected mont is also not heighlighted'); }); @@ -1274,27 +1272,27 @@ QUnit.test('Today and selected months are highlighted', function (assert) { QUnit.test('Number of months from today', function (assert) { var field = $(RistrictMonthField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - - MinMonth: 0, + + MinMonth: 0, MaxMonth: 16 }); - + // Make sure the menu will open on the current month. field.val($.datepicker.formatDate('mm/yy', new Date)); - + field.MonthPicker('Open'); - + var menu = $(MonthPicker_RistrictMonthField); // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); var nextYearButton = menu.find('.next-year>a'); var previousYearButton = menu.find('.previous-year>a'); - + var enabledMonths = 0; - + // Make sure that 16 buttons + 1 for today are disabled. - // + // // Keep clicking next until the next year button is disabled // We count to 10 to avoid an infinite loop in case there's // a bug where the next button is not disabled. @@ -1305,23 +1303,23 @@ QUnit.test('Number of months from today', function (assert) { nextYearButton.trigger('click'); } assert.equal(enabledMonths, 17, 'Today + 16 month buttons are enabled'); - + field.MonthPicker('Close'); - + // Make sure that 20 buttons + 1 for today are disabled. field.MonthPicker({MinMonth: -20, MaxMonth: 0}); field.MonthPicker('Open'); enabledMonths = 0; - + hasNext = previousYearButton.is(':not(.ui-button-disabled)'); - + for (var i = 0; hasNext && i < 10; i++) { hasNext = previousYearButton.is(':not(.ui-button-disabled)'); enabledMonths += buttons.not('.ui-button-disabled').length; previousYearButton.trigger('click'); } assert.equal(enabledMonths, 21, 'Today + 20 month buttons are enabled'); - + // Destroy the plugin so we can use the field over again // in another Min/MaxMonth test. field.MonthPicker('destroy'); @@ -1330,16 +1328,16 @@ QUnit.test('Number of months from today', function (assert) { QUnit.test('Relative month periods', function (assert) { var field = $(RistrictMonthField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MinMonth: '+1Y -12m', // a.k.a 0 months (this month). MaxMonth: '6M +1y' // a.k.a 18 months. }); - + // Make sure the menu will open on the current month. field.val($.datepicker.formatDate('mm/yy', new Date)); - + field.MonthPicker('Open'); - + var menu = $(MonthPicker_RistrictMonthField); // Make sure we are in years view. @@ -1347,9 +1345,9 @@ QUnit.test('Relative month periods', function (assert) { var nextYearButton = menu.find('.next-year>a'); var previousYearButton = menu.find('.previous-year>a'); var enabledMonths = 0; - + // Make sure that 18 buttons + 1 for today are disabled. - // + // // Keep clicking next until the next year button is disabled // We count to 10 to avoid an infinite loop in case there's // a bug where the next button is not disabled. @@ -1360,23 +1358,23 @@ QUnit.test('Relative month periods', function (assert) { nextYearButton.trigger('click'); } assert.equal(enabledMonths, 19, 'Today + 18 month buttons are enabled'); - + field.MonthPicker('Close'); - + // Make sure that 24 buttons + 1 for today are disabled. field.MonthPicker({MinMonth: '-2y', MaxMonth: '0M'}); field.MonthPicker('Open'); enabledMonths = 0; - + hasNext = previousYearButton.is(':not(.ui-button-disabled)'); - + for (var i = 0; hasNext && i < 10; i++) { hasNext = previousYearButton.is(':not(.ui-button-disabled)'); enabledMonths += buttons.not('.ui-button-disabled').length; previousYearButton.trigger('click'); } assert.equal(enabledMonths, 25, 'Today + 24 month buttons are enabled'); - + // Destroy the plugin so we can use the field over again // in another Min/MaxMonth test. field.MonthPicker('destroy'); @@ -1385,27 +1383,27 @@ QUnit.test('Relative month periods', function (assert) { QUnit.test('JavaScript Date objects', function (assert) { var field = $(RistrictMonthField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. - + MinMonth: new Date(2015, 2 - 1), MaxMonth: new Date(2015, 11 - 1) }); - + field.val('05/2015'); - + var menu = $(MonthPicker_RistrictMonthField); var buttons = menu.find('.month-picker-month-table button'); - + field.MonthPicker('Open'); assert.equal(buttons.not('.ui-button-disabled').length, 10, '10 month buttons are enabled'); - + field.MonthPicker('Close'); field.MonthPicker('option', 'MinMonth', new Date(2016, 1 - 1)); field.MonthPicker('option', 'MaxMonth', new Date(2016, 6 - 1)); - + field.MonthPicker('Open'); assert.equal(menu.find('.year').text(), 2016, 'The menu opend at the expected year 2015'); assert.equal(buttons.not('.ui-button-disabled').length, 6, '12 month buttons are enabled'); - + // Destroy the plugin so we can use the field over again // in another Min/MaxMonth test. field.MonthPicker('destroy'); From dcbb7301739ccacb20aefc04874b12f22e53e831 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 17:00:38 +0200 Subject: [PATCH 15/48] Ajusts Events and context + year buttons are disabled tests to the new jump years buttton structure --- test/test.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/test.js b/test/test.js index 0ac59a3..577f9e8 100644 --- a/test/test.js +++ b/test/test.js @@ -16,6 +16,10 @@ var _today = new Date(); // the tests. $.KidSysco.MonthPicker.prototype.options.Duration = 1; +function _getPickerYear(_pickerMenu) { + return parseInt($('.jump-years span', _pickerMenu).text().replace(/\D/g, ''), 10); +} + QUnit.module("Installation"); /***** Test basic the installation for the pre-requisite objects and namespaces *****/ @@ -197,7 +201,7 @@ QUnit.test('Start Year Option Tests', function (assert) { assert.equal(_pickerMenu.css('display'), 'block', '#StartYearDemo responded to a text input click event and showed the menu.'); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2025, '#StartYearDemo defaulted to 2025, the year specified in the textbox.'); _picker.MonthPicker('option', 'StartYear', 2095); - assert.equal(parseInt($('.jump-years span', _pickerMenu).text().replace(/\D/g, ''), 10), 2095, '#StartYearDemo switched the year to 2095 after init.'); + assert.equal(_getPickerYear(_pickerMenu), 2095, '#StartYearDemo switched the year to 2095 after init.'); $('.button-1', _pickerMenu).trigger($.Event('click')); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2095, '#StartYearDemo selected the correct year, 2095, upon choosing a month.'); done(); @@ -498,7 +502,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterChooseYears was called in the right context' ); }); - var showYearsButton = menu.find('.year-container-all'); + var showYearsButton = menu.find('.jump-years a'); showYearsButton.trigger('click'); assert.ok(OnAfterChooseYearsTriggerd, 'Clicking the show years button triggered OnAfterChooseYears'); @@ -948,7 +952,7 @@ QUnit.test('Month buttons are disabled', function (assert) { // Try to click the disabled buttons. var buttons = menu.find('.month-picker-month-table button'); - $(buttons.slice(0, 8)).trigger('click'); + $(buttons.slice(0, 8)).trigger('click'); assert.ok(previousYearButton.is('.ui-button-disabled'), 'The previous year button is disabled'); @@ -961,7 +965,7 @@ QUnit.test('Month buttons are disabled', function (assert) { // Make sure we can still go to the next year. nextYearButton.trigger('click'); - var pickerYear = parseInt(menu.find('.year').text(), 10); + var pickerYear = _getPickerYear(menu); assert.equal(pickerYear, 2016, 'Clicking next year changed the year to 2016'); // Make none of the buttons are disabled. @@ -978,7 +982,7 @@ QUnit.test('Month buttons are disabled', function (assert) { previousYearButton.trigger('click'); previousYearButton.trigger('click'); - var pickerYear = parseInt(menu.find('.year').text(), 10); + var pickerYear = _getPickerYear(menu); assert.equal(pickerYear, 2015, 'clicking previous year tweice keept the year at 2015'); // Make sure that month buttons before October (the minimum month) @@ -1021,7 +1025,7 @@ QUnit.test('Year buttons are disabled', function (assert) { var menu = $(MonthPicker_RistrictMonthField); // Click the year title to show the years. - menu.find('.year-title').trigger('click'); + menu.find('.jump-years a').trigger('click'); // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); @@ -1103,7 +1107,7 @@ QUnit.test('Year buttons are disabled', function (assert) { assert.ok(!hasDidabledButtons, 'All buttons are enabled'); // Click the year title to show the years menu. - menu.find('.year-title').trigger('click'); + menu.find('.jump-years a').trigger('click'); // Keeps clicking next years until we reach the disabled years. for (var i = 1; !buttons.is('.ui-button-disabled') && i <= 10; i++) { From 22b94c88c9ebdddecd2a086e17069e783965c598 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 17:40:47 +0200 Subject: [PATCH 16/48] Ajusts the rest of the tests to the new jump years button structure --- MonthPicker.min.js | 2 +- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.js | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 2974124..33b5583 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha3",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus();var c=this;setTimeout(function(){var b=a>0?c._nextButton:c._prevButton;b.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default");var m,n=null,p=125,q=l[0],r=this;a(q).mouseover(function(b){var c=this;n=setTimeout(function(){n=null,a("span",c).animate({opacity:.45},{duration:p,complete:function(){m=a("span",c).text(),a("span",c).animate({opacity:1},p).text(r._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(n)return clearTimeout(n);var c=this;a("span",c).animate({opacity:.45},{duration:p,complete:function(){a("span",c).text(m).animate({opacity:1},p)}})}),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var s=".ui-button-icon-primary";a(s,this._nextButton).text(this._i18n("nextLabel")),a(s,this._prevButton).text(this._i18n("prevLabel"));for(var t=a(".month-picker-month-table",i),u=0;12>u;u++){var v=u%3?v:a("").appendTo(t);v.append('')}this._buttons=a("button",t).button(),i.on(H,function(a){return!1});var A=this,D="Month";a.each(["Min","Max"],function(a,b){A["_set"+b+D]=function(a){(A["_"+b+D]=j(A,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},A._setOption(b+D,A.options[b+D])});var E=e.SelectedMonth;if(void 0!==E){var G=j(this,E);b.val(this._formatMonth(new d(f(G),G%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.css b/demo/Demo.min.css index d66cfad..24ba688 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker .year-container-all,.option-link{cursor:pointer}.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .year-container-all{text-align:center}.month-picker-year-table .year-container{margin:0 auto}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .year-container{width:50px;text-align:center}.month-picker-year-table .previous-year>a{float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table td{padding:0}.month-picker-year-table a{border:1px solid transparent;margin:0;width:1.5em;height:1.5em;text-align:center;cursor:pointer}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .previous-year>a{float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table td{padding:0}.month-picker-year-table a{border:1px solid transparent;margin:0;width:1.5em;height:1.5em;text-align:center;cursor:pointer}.jump-years a{width:100%}.month-picker-year-table .jump-years span{padding:inherit}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 5eccb6f..7b44fa5 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha3",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),a(".year-title",i).text(this._i18n("year")),this._yearContainerAll=a(".year-container-all",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)),this._createValidationMessage(),this._yearContainer=a(".year",i),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).button(),i.on(H,function(a){return!1});var q=this,r="Month";a.each(["Min","Max"],function(a,b){q["_set"+b+r]=function(a){(q["_"+b+r]=j(q,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},q._setOption(b+r,q.options[b+r])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return parseInt(this._yearContainer.text(),10)},_setPickerYear:function(a){this._yearContainer.text(a||(new d).getFullYear())},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._yearContainerAll.css("cursor","pointer"),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._yearContainerAll.css("cursor","default"),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this.element.focus();var c=this;setTimeout(function(){var b=a>0?c._nextButton:c._prevButton;b.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){var b=this._yearContainer;b.text(parseInt(b.text())+a,10),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default");var m,n=null,p=125,q=l[0],r=this;a(q).mouseover(function(b){var c=this;n=setTimeout(function(){n=null,a("span",c).animate({opacity:.45},{duration:p,complete:function(){m=a("span",c).text(),a("span",c).animate({opacity:1},p).text(r._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(n)return clearTimeout(n);var c=this;a("span",c).animate({opacity:.45},{duration:p,complete:function(){a("span",c).text(m).animate({opacity:1},p)}})}),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var s=".ui-button-icon-primary";a(s,this._nextButton).text(this._i18n("nextLabel")),a(s,this._prevButton).text(this._i18n("prevLabel"));for(var t=a(".month-picker-month-table",i),u=0;12>u;u++){var v=u%3?v:a("").appendTo(t);v.append('')}this._buttons=a("button",t).button(),i.on(H,function(a){return!1});var A=this,D="Month";a.each(["Min","Max"],function(a,b){A["_set"+b+D]=function(a){(A["_"+b+D]=j(A,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},A._setOption(b+D,A.options[b+D])});var E=e.SelectedMonth;if(void 0!==E){var G=j(this,E);b.val(this._formatMonth(new d(f(G),G%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 577f9e8..822616d 100644 --- a/test/test.js +++ b/test/test.js @@ -1165,7 +1165,7 @@ QUnit.test('Menu opens within range', function (assert) { field.val('02/2010'); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2013, 'The menu opend at the minimum year (2013) and not 2010' ); + assert.equal(_getPickerYear(menu), 2013, 'The menu opend at the minimum year (2013) and not 2010' ); field.MonthPicker('Close'); @@ -1174,7 +1174,7 @@ QUnit.test('Menu opens within range', function (assert) { field.val('12/2020'); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2016, 'The menu opend at the maximum year (2016) and not 2020' ); + assert.equal(_getPickerYear(menu), 2016, 'The menu opend at the maximum year (2016) and not 2020' ); field.MonthPicker('Close'); @@ -1183,7 +1183,7 @@ QUnit.test('Menu opens within range', function (assert) { field.MonthPicker('option', 'MaxMonth', '12/2018'); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2018, 'The menu opend at the year 2018 after changing the MaxMonth option' ); + assert.equal(_getPickerYear(menu), 2018, 'The menu opend at the year 2018 after changing the MaxMonth option' ); field.MonthPicker('Close'); @@ -1192,7 +1192,7 @@ QUnit.test('Menu opens within range', function (assert) { field.MonthPicker('option', 'MaxMonth', new Date(2021, 12 - 1)); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2020, 'The menu opend at the the selected year 2020 after' ); + assert.equal(_getPickerYear(menu), 2020, 'The menu opend at the the selected year 2020 after' ); field.MonthPicker('Close'); @@ -1200,7 +1200,7 @@ QUnit.test('Menu opens within range', function (assert) { field.val('02/2009'); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2010, 'The menu opend at the year 2010 after chagnig the MinMonth option' ); + assert.equal(_getPickerYear(menu), 2010, 'The menu opend at the year 2010 after chagnig the MinMonth option' ); field.MonthPicker('Close'); @@ -1209,7 +1209,7 @@ QUnit.test('Menu opens within range', function (assert) { field.MonthPicker('option', 'MinMonth', new Date(2008, 04)); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2009, 'The menu opend at the selected year after changing the MinMonth option again' ); + assert.equal(_getPickerYear(menu), 2009, 'The menu opend at the selected year after changing the MinMonth option again' ); // Destroy the plugin so we can use the field over again // in another Min/MaxMonth test. @@ -1253,7 +1253,7 @@ QUnit.test('Today and selected months are highlighted', function (assert) { assert.equal( selectedButton.length, 1, 'There is one selected button'); assert.equal( selectedButton[0], buttons[4], 'The selected month is highlighted'); - menu.find('.year').trigger('click'); + menu.find('.jump-years a').trigger('click'); var selectdBtn = buttons.filter('.ui-state-active'); assert.equal( selectdBtn.button( "option", "label" ), _today.getFullYear(), 'The selected year is highlighted'); @@ -1405,7 +1405,7 @@ QUnit.test('JavaScript Date objects', function (assert) { field.MonthPicker('option', 'MaxMonth', new Date(2016, 6 - 1)); field.MonthPicker('Open'); - assert.equal(menu.find('.year').text(), 2016, 'The menu opend at the expected year 2015'); + assert.equal(_getPickerYear(menu), 2016, 'The menu opend at the expected year 2015'); assert.equal(buttons.not('.ui-button-disabled').length, 6, '12 month buttons are enabled'); // Destroy the plugin so we can use the field over again From 622428924c7646622ae8c47fa0a724f7e94ae15b Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 20:48:08 +0200 Subject: [PATCH 17/48] Extracts the new jump years button code into its own function --- MonthPicker.js | 80 ++++++++++++++++++++++------------------------ MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 635314a..276f1fc 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -153,6 +153,40 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return !elem.is('input'); } + function _applyFadeShowYears(jumpYears) { + var tOut = null, speed = 125; + var _prevText; + var that = this; + + jumpYears.mouseover(function(e) { + var me = this; + tOut = setTimeout(function() { + tOut = null; + + $("span", me).animate({ opacity: .45 }, { + duration: speed, + complete: function() { + _prevText=$("span", me).text(); + $("span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); + } + }); + }, 175); + }).mouseout(function(e) { + if (tOut) { + return clearTimeout(tOut); + } else { + var me = this; + + $("span", me).animate({ opacity: .45 },{ + duration: speed, + complete: function() { + $("span", me).text(_prevText).animate({opacity: 1}, speed); + } + }); + } + }); + } + $.MonthPicker = { VERSION: '3.0-alpha4', // Added in version 2.4; i18n: { @@ -174,16 +208,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
' + '' + '' + - '' + + '' + '' + '' + '
' + - /* - '
' + - '' + - '' + - '
' + */ - - ''+ - - '
' + @@ -330,43 +355,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $(_markup).appendTo(_menu); (_menu).appendTo( isInline ? _el : document.body ); - //$('.year-title', _menu).text(this._i18n('year')); - var jumpYears = $('.jump-years', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)); - this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); - - - var tOut = null, speed = 125, _yca = jumpYears[0]; - var _prevText; - var that = this; -/*_menu.find('.month-picker-year-table').*/$(_yca).mouseover(function(e) { - var me = this; - //if ($.contains(_yca, e.target)) { -tOut = setTimeout(function() { - tOut = null; - /*$(".year-container-all span", me)*/$("span", me).animate({ opacity: .45 },{ - duration: speed, - complete: function() { - _prevText=$(/*".year-container-all*/"span", me).text(); - $(/*".year-container-all*/"span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); - } - }); -}, 175); //} else $("a", me).addClass('ui-state-default') ; -}).mouseout(function(e) { -if (tOut) return clearTimeout(tOut); -var me = this; -//if ($.contains(_yca, e.target)) { - $(/*".year-container-all*/ "span", me).animate({ opacity: .45 },{ - duration: speed, - complete: function() { - $("span", me).text(_prevText).animate({opacity: 1}, speed); - } - }); //} else $("a", me).removeClass('ui-state-default') ; -}); + this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); + + _applyFadeShowYears.call(this, jumpYears); this._createValidationMessage(); diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 33b5583..b426e10 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default");var m,n=null,p=125,q=l[0],r=this;a(q).mouseover(function(b){var c=this;n=setTimeout(function(){n=null,a("span",c).animate({opacity:.45},{duration:p,complete:function(){m=a("span",c).text(),a("span",c).animate({opacity:1},p).text(r._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(n)return clearTimeout(n);var c=this;a("span",c).animate({opacity:.45},{duration:p,complete:function(){a("span",c).text(m).animate({opacity:1},p)}})}),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var s=".ui-button-icon-primary";a(s,this._nextButton).text(this._i18n("nextLabel")),a(s,this._prevButton).text(this._i18n("prevLabel"));for(var t=a(".month-picker-month-table",i),u=0;12>u;u++){var v=u%3?v:a("").appendTo(t);v.append('')}this._buttons=a("button",t).button(),i.on(H,function(a){return!1});var A=this,D="Month";a.each(["Min","Max"],function(a,b){A["_set"+b+D]=function(a){(A["_"+b+D]=j(A,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},A._setOption(b+D,A.options[b+D])});var E=e.SelectedMonth;if(void 0!==E){var G=j(this,E);b.val(this._formatMonth(new d(f(G),G%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 7b44fa5..60b11f8 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===C[b].indexOf(c)?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default");var m,n=null,p=125,q=l[0],r=this;a(q).mouseover(function(b){var c=this;n=setTimeout(function(){n=null,a("span",c).animate({opacity:.45},{duration:p,complete:function(){m=a("span",c).text(),a("span",c).animate({opacity:1},p).text(r._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(n)return clearTimeout(n);var c=this;a("span",c).animate({opacity:.45},{duration:p,complete:function(){a("span",c).text(m).animate({opacity:1},p)}})}),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var s=".ui-button-icon-primary";a(s,this._nextButton).text(this._i18n("nextLabel")),a(s,this._prevButton).text(this._i18n("prevLabel"));for(var t=a(".month-picker-month-table",i),u=0;12>u;u++){var v=u%3?v:a("").appendTo(t);v.append('')}this._buttons=a("button",t).button(),i.on(H,function(a){return!1});var A=this,D="Month";a.each(["Min","Max"],function(a,b){A["_set"+b+D]=function(a){(A["_"+b+D]=j(A,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},A._setOption(b+D,A.options[b+D])});var E=e.SelectedMonth;if(void 0!==E){var G=j(this,E);b.val(this._formatMonth(new d(f(G),G%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From 3dc868aa0bd9e2cfabc9c1c685ce75bd2c9fa534 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 19 Dec 2015 21:20:23 +0200 Subject: [PATCH 18/48] Makes moving forward and backwards through the years jump 12 year instead of 5 yearss --- MonthPicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MonthPicker.js b/MonthPicker.js index 276f1fc..de908f2 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -834,7 +834,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _currYear = this._getPickerYear(), _yearDifferential = -4, _firstYear = (_currYear + _yearDifferential), - AMOUNT_TO_ADD = 5, + AMOUNT_TO_ADD = 12, _thisYear = new Date().getFullYear(); var _minDate = this._MinMonth; From 14dd33400a2b265664df216edc4860bc83be5d8c Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sun, 20 Dec 2015 22:27:27 +0200 Subject: [PATCH 19/48] Fixes an issue that prevented test from passing in IE. The new menu's display is inline-block so that inline menus won't take up all the space of their parent. This caused tests that check that the menus topmost div's display is block to fails in Internet Explorer, because jQuery's .fadeIn() method didn't apply the display:block; css to the menu's div. This commit fixes the tests by checking visibility using the :visible psudo instead. --- MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- test/test.js | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/MonthPicker.min.js b/MonthPicker.min.js index b426e10..b18b6ed 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 60b11f8..2c01719 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=5,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 822616d..f2a084b 100644 --- a/test/test.js +++ b/test/test.js @@ -87,13 +87,13 @@ QUnit.test('HTML 5 & Formatting Tests', function (assert) { ShowIcon: false, StartYear: 2027, OnAfterMenuOpen: function () { - assert.equal(_pickerMenu.css('display'), 'block', '#Html5 responded to a text input click event and showed the menu.'); + assert.ok(_pickerMenu.is(':visible'), '#Html5 responded to a text input click event and showed the menu.'); $('.button-1', _pickerMenu).trigger($.Event('click')); done(); done = assert.async(); }, OnAfterMenuClose: function () { - assert.equal(_pickerMenu.css('display'), 'none', '#Html5 responded to a button click event by closing the menu.'); + assert.notOk(_pickerMenu.is(':visible'), '#Html5 responded to a button click event by closing the menu.'); assert.equal(_picker.MonthPicker('GetSelectedYear'), '2027', '#Html5 showed and selected the correct override start year of 2027.'); assert.equal(_picker.MonthPicker('GetSelectedMonth'), '01', '#Html5 showed and selected the correct month of 01.'); // destroy the monthpicker and re-create it so it doesnt fire anymore qunit events upon being used. @@ -129,7 +129,7 @@ if ($.ui.position) { var _meun = $(MonthPicker_PositionDemo); var _lastPointFullyVisibleX = _windowWidth - _meun.width(); var _lastPointFullyVisibleY = _windowHeight - _pickerMenu.height(); - assert.equal(_pickerMenu.css('display'), 'block', '#PositionDemo responded to a text input click event and showed the menu.'); + assert.ok(_pickerMenu.is(":visible"), '#PositionDemo responded to a text input click event and showed the menu.'); assert.ok(_pickerMenu.position().left <= _lastPointFullyVisibleX, "#PositionDemo does not overlap the right window boundary on the X axis."); assert.ok(_pickerMenu.position().left > 0, "#PositionDemo does not overlap the left window boundary on the X axis."); assert.ok(_pickerMenu.position().top <= _lastPointFullyVisibleY, "#PositionDemo does not overlap the bottom window boundary on the Y axis."); @@ -139,7 +139,7 @@ if ($.ui.position) { done = assert.async(); }, OnAfterMenuClose: function () { - assert.equal(_pickerMenu.css('display'), 'none', '#PositionDemo responded to a button click event by closing the menu.'); + assert.notOk(_pickerMenu.is(':visible'), '#PositionDemo responded to a button click event by closing the menu.'); // destroy the monthpicker and re-create it so it doesnt fire anymore qunit events upon being used. $('#PositionDemo').MonthPicker('destroy'); assert.ok($('#MonthPicker_PositionDemo').length === 0, "#PositionDemo has been destroyed."); @@ -168,7 +168,7 @@ QUnit.test('Override Start Year Tests', function (assert) { ShowIcon: false, StartYear: 2023, OnAfterMenuOpen: function () { - assert.equal(_pickerMenu.css('display'), 'block', '#OverrideStartYear responded to a text input click event and showed the menu.'); + assert.ok(_pickerMenu.is(':visible'), '#OverrideStartYear responded to a text input click event and showed the menu.'); $('.button-1', _pickerMenu).trigger($.Event('click')); done(); done = assert.async(); @@ -187,7 +187,6 @@ QUnit.test('Override Start Year Tests', function (assert) { } }); - assert.ok($('#MonthPicker_OverrideStartYear').length === 1, "#OverrideStartYear has been initialized for demo purposes."); var _pickerMenu = $('#MonthPicker_OverrideStartYear'); _picker.trigger($.Event('click')); done = assert.async(); @@ -198,7 +197,7 @@ QUnit.test('Start Year Option Tests', function (assert) { var _picker = $('#StartYearDemo').MonthPicker({ ShowIcon: false, OnAfterMenuOpen: function () { - assert.equal(_pickerMenu.css('display'), 'block', '#StartYearDemo responded to a text input click event and showed the menu.'); + assert.ok(_pickerMenu.is(':visible'), '#StartYearDemo responded to a text input click event and showed the menu.'); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2025, '#StartYearDemo defaulted to 2025, the year specified in the textbox.'); _picker.MonthPicker('option', 'StartYear', 2095); assert.equal(_getPickerYear(_pickerMenu), 2095, '#StartYearDemo switched the year to 2095 after init.'); @@ -208,23 +207,22 @@ QUnit.test('Start Year Option Tests', function (assert) { done = assert.async(); }, OnAfterMenuClose: function () { - assert.equal(_pickerMenu.css('display'), 'none', '#StartYearDemo responded to a button click event by closing the menu.'); + assert.notOk(_pickerMenu.is(':visible'), '#StartYearDemo responded to a button click event by closing the menu.'); $('#StartYearDemo').MonthPicker('destroy'); assert.ok($('#MonthPicker_StartYearDemo').length === 0, "#StartYearDemo has been destroyed."); $('#StartYearDemo').val('1/2025').MonthPicker({ ShowIcon: false, OnAfterMenuOpen: function () { - // get the picker menu again because it was removed from the dom upon destroying StartYearDemo. _pickerMenu = $('#MonthPicker_StartYearDemo'); - assert.equal(_pickerMenu.css('display'), 'block', '#StartYearDemo responded to a text input click event and showed the menu.'); + assert.ok(_pickerMenu.is(':visible'), '#StartYearDemo responded to a text input click event and showed the menu.'); assert.equal(parseInt(_picker.MonthPicker('GetSelectedYear'), 10), 2025, '#StartYearDemo defaulted to 2025, the year specified in the textbox.'); _picker.MonthPicker('Close'); done(); done = assert.async(); }, OnAfterMenuClose: function () { - assert.equal(_pickerMenu.css('display'), 'none', '#StartYearDemo responded to a button click event by closing the menu.'); + assert.notOk(_pickerMenu.is(':visible'), '#StartYearDemo responded to a button click event by closing the menu.'); _picker.MonthPicker('destroy'); // get the picker menu again because it was removed from the dom upon destroying StartYearDemo. assert.ok($('#MonthPicker_StartYearDemo').length === 0, "#StartYearDemo has been destroyed again."); @@ -310,7 +308,7 @@ QUnit.test('Digital Bush Tests', function (assert) { assert.equal($('#MonthPicker_Validation_DigitalBushBoth').css('display'), 'inline', '#DigitalBushBoth showed a validation message about a bad date.'); $('#DigitalBushBoth').MonthPicker('Clear'); - assert.equal($('#MonthPicker_Validation_DigitalBushBoth').css('display'), 'none', '#DigitalBushBoth cleared the validation error message using the Clear() API call.'); + assert.ok($('#MonthPicker_Validation_DigitalBushBoth').is(':hidden'), '#DigitalBushBoth cleared the validation error message using the Clear() API call.'); }); QUnit.test('Only one open menu', function (assert) { From f013d7fd108ccdf087d265960467eccd8334f987 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sun, 20 Dec 2015 23:07:58 +0200 Subject: [PATCH 20/48] IE 8 support: Replaces use of .indexOf() with $.inArray() in _setOption() --- MonthPicker.js | 2 +- MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- test/test.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index de908f2..67f477d 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -294,7 +294,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } // Make sure the user passed in a valid Animation, ShowAnim and HideAnim options values. - if (key in _animVals && _animVals[key].indexOf(value) === -1) { + if (key in _animVals && $.inArray(value, _animVals[key]) === -1) { alert(_badOptValErr.replace(/%/, key) + _animVals[key]); return; } diff --git a/MonthPicker.min.js b/MonthPicker.min.js index b18b6ed..bf4654b 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===a.inArray(c,D[b])?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 2c01719..0bbb020 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===D[b].indexOf(c)?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===a.inArray(c,D[b])?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.js b/test/test.js index f2a084b..53d805a 100644 --- a/test/test.js +++ b/test/test.js @@ -404,7 +404,7 @@ QUnit.test('Inline menu', function(assert) { assert.notOk($("#MonthPicker_Button_InlineMenuDiv").length, 'The default button was not created'); - //field.MonthPicker('destroy'); + field.MonthPicker('destroy'); }); QUnit.test('SelectedMonth option', function(assert) { From 5bfcc700c77aaea6ff32f8d93236ed9cc48b6544 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 2 Jan 2016 17:36:18 +0200 Subject: [PATCH 21/48] Makes the jump years button turn into Back to 2016 when button clicked + version bump --- MonthPicker.js | 34 +++++++-- README.md | 198 ++++++++++++++++++++++++------------------------- 2 files changed, 124 insertions(+), 108 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 67f477d..609ff66 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -1,7 +1,7 @@ /* https://github.com/KidSysco/jquery-ui-month-picker/ -Version 3.0-alpha4 +Version 3.0-alpha5 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -158,7 +158,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _prevText; var that = this; - jumpYears.mouseover(function(e) { + jumpYears.on('mouseenter' + _eventsNs + '-j', function(e) { var me = this; tOut = setTimeout(function() { tOut = null; @@ -171,7 +171,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }); }, 175); - }).mouseout(function(e) { + }).on('mouseleave' + _eventsNs + '-j', function(e) { if (tOut) { return clearTimeout(tOut); } else { @@ -188,7 +188,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } $.MonthPicker = { - VERSION: '3.0-alpha4', // Added in version 2.4; + VERSION: '3.0-alpha5', // Added in version 2.4; i18n: { year: "Year", prevYear: "Previous Year", @@ -362,7 +362,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); - _applyFadeShowYears.call(this, jumpYears); + _applyFadeShowYears.call(this, this._jumpYearsButton); this._createValidationMessage(); @@ -780,17 +780,21 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _chooseMonth: function (month) { - var date = new Date(this._getPickerYear(), month-1); + var _year = this._getPickerYear(); + var date = new Date(_year, month-1); this.element.val(this._formatMonth( date )).blur(); this._updateAlt(0, date); _setActive( this._selectedBtn, false ); this._selectedBtn = _setActive( $(this._buttons[month-1]), true ); + this._jumpYearsButton.button({label: 'Year ' + _year}); + _event('OnAfterChooseMonth', this)(date); }, _chooseYear: function (year) { + this._backToYear = 0; this._setPickerYear(year); this._buttons.removeClass(_todayClass); this._showMonths(); @@ -827,7 +831,20 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._buttons.removeClass(_todayClass); this._showYears(); - _event('OnAfterChooseYears', this)(); + if (!this._backToYear) { + this._jumpYearsButton.off(_eventsNs + '-j'); + this._jumpYearsButton/*.addClass('ui-state-hover')*/.button({label: 'Back to ' + this._getPickerYear()}); + + this._backToYear = this._getPickerYear(); + + _event('OnAfterChooseYears', this)(); + } else { + //this._jumpYearsButton/*.addClass('ui-state-hover')*/.button({label: 'Year ' + this._getPickerYear()}); + this._setPickerYear(this._backToYear); + _applyFadeShowYears.call(this, this._jumpYearsButton); + this._showMonths(); + this._backToYear = 0; + } }, _showYears: function () { @@ -910,7 +927,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _addToYears: function(amount) { //var _year = this._yearContainer; //_year.text(parseInt(_year.text()) + amount, 10); - this._setPickerYear( this._getPickerYear() + amount ); + //this._setPickerYear( this._getPickerYear() + amount ); + this._pickerYear = this._getPickerYear() + amount; this._showYears(); this.element.focus(); diff --git a/README.md b/README.md index 524f075..ac024dc 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -

The jQuery UI Month Picker Version 3.0-alpha4

+

The jQuery UI Month Picker Version 3.0-alpha5

[![Build Status](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker.svg?branch=3.0_prototype)](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) -

The jQuery UI Month Picker Plugin is designed to allow user input for only a month and year when only that input is -required. Clicking on the year, allows the user to jump ahead or back 5 years at a time. Clicking anywhere on the -page, except on the month picker menu itself, will cause the month picker to hide. The Month Picker has lots of options +

The jQuery UI Month Picker Plugin is designed to allow user input for only a month and year when only that input is +required. Clicking on the year, allows the user to jump ahead or back 5 years at a time. Clicking anywhere on the +page, except on the month picker menu itself, will cause the month picker to hide. The Month Picker has lots of options for date validation, setting the start year, using an icon button, input masking, internationalization and localization and more.

- + -See a demo on jsFiddle at... --http://jsfiddle.net/kidsysco/JeZap/ +-http://jsfiddle.net/kidsysco/JeZap/

Prerequisites

This plugin has been tested using the following configuration.

@@ -27,7 +27,7 @@ for date validation, setting the start year, using an icon button, input masking

Installation

-

Attach all required css and js files to the web page as follows...

+

Attach all required css and js files to the web page as follows...

 <link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" media="all" rel="stylesheet" type="text/css" />
 <link href="css/MonthPicker.css" media="all" rel="stylesheet" type="text/css" />
@@ -39,7 +39,7 @@ for date validation, setting the start year, using an icon button, input masking
 

Source Code Example

-

This plugin can only be called on the text or the HTML 5 Month Input Types as follows.

+

This plugin can only be called on the text or the HTML 5 Month Input Types as follows.

 $('#TextBox1').MonthPicker({ StartYear: 2020, ShowIcon: false });
 $('input[type=month]').MonthPicker().css('backgroundColor', 'lightyellow');
@@ -72,7 +72,7 @@ You can create an inline month picker menu by calling the month picker function
 $('div').MonthPicker({
 	SelectedMonth: '+1y -3M', // Set the selected month.
 	AltField: '#hiddenInput' // Populate a hidden field and send to send the selected value to the server.
-	
+
 	OnAfterChooseMonth: function(selectedDate) {
 		// Do something with selected JavaScript date.
         // console.log(selectedDate);
@@ -128,7 +128,7 @@ NOTE: This method is not affected by the MonthForm
 The menu will immediately close itself, you can prevent the menu from closing using the
 OnBeforeMenuClose event (example included) and calling event.preventDefault() for the element triggering the event.
 
-

NOTE: It might be possible to prevent the menu from closing by calling event.stopPropagation() in the click event that called the Open method. +

NOTE: It might be possible to prevent the menu from closing by calling event.stopPropagation() in the click event that called the Open method. However this is not supported and might stop working in future releases if we change the way the plugin handles events. To prevent the menu from hideing use the OnBeforeMenuClose event (example included) and call event.preventDefault() for the element triggering the event. @@ -162,8 +162,8 @@ However this is not supported and might stop working in future releases i

Set the option upon init.

$('.selector').MonthPicker({ Disabled: true });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'Disabled');
@@ -193,8 +193,8 @@ $('.selector').MonthPicker('option', 'Disabled', true );
 

Disables past months upon init.

$('.selector').MonthPicker({ MinMonth: 0 });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var minMonth = $('.selector').MonthPicker('option', 'MinMonth');
@@ -225,8 +225,8 @@ $('.selector').MonthPicker('option', 'MinMonth', '+1y +3m');
 

Disables future months upon init.

$('.selector').MonthPicker({ MaxMonth: 0 });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var minMonth = $('.selector').MonthPicker('option', 'MaxMonth');
@@ -239,7 +239,7 @@ $('.selector').MonthPicker('option', 'MaxMonth', '+1y +3m');
 
 

Button

- Types: + Types:
  • Function that returns jQuery
  • HTML string
  • @@ -247,7 +247,7 @@ $('.selector').MonthPicker('option', 'MaxMonth', '+1y +3m');
  • DOM element.
Since: 2.5
- Default: + Default:
 // Creates the default button.
 Button: function(options) {
@@ -272,14 +272,14 @@ If you just want to use a different showOn: 'both' option.
 
-$('.selector').MonthPicker({ 
+$('.selector').MonthPicker({
     Button: '<button type="button" class="ui-datepicker-trigger">...</button>'
 });
 
Create a button out of an image.
-$('.selector').MonthPicker({ 
+$('.selector').MonthPicker({
     Button: '<img src="images/calendar.gif" title="Select date" />'
 });
 
@@ -300,7 +300,7 @@ $('.selector').MonthPicker({ <img src="images/{{ButtonIcon}}{{#if Disabled}}-disabled{{/if}}.gif" title="{{i18n.buttonText}}" /> </script> <script> -$('.selector').MonthPicker({ +$('.selector').MonthPicker({ Button: Handlebars.compile( $('#template').html() ) }); </script> @@ -309,7 +309,7 @@ $('.selector').MonthPicker({ Assign an existing element with a class of button that immediately follows the associated input field as a button.
-$('.selector').MonthPicker({ 
+$('.selector').MonthPicker({
     Button: function() {
         return $(this).next('.button');
     }
@@ -318,12 +318,12 @@ $('.selector').MonthPicker({
 
     Assign a specific element with the class button.
 
-$('.selector').MonthPicker({ 
+$('.selector').MonthPicker({
     Button: '.button'
 });
 
- Get or set the option, after init. + Get or set the option, after init.
 //getter
 var button = $('.selector').MonthPicker('option', 'Button');
@@ -364,8 +364,8 @@ If the button is not one of the elements above then you have to disable the elem
 Set the option upon init.
 

$('.selector').MonthPicker({ SelectedMonth: 0 });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var minMonth = $('.selector').MonthPicker('option', 'SelectedMonth');
@@ -384,8 +384,8 @@ $('.selector').MonthPicker('option', 'SelectedMonth', '+1y -3m');
 

Set the option upon init.

$('.selector').MonthPicker({ ShowIcon: true });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'ShowIcon');
@@ -399,14 +399,14 @@ $('.selector').MonthPicker('option', 'ShowIcon', false );
     

ButtonIcon

Type: String
Default: ui-icon-calculator
- + Allows setting a different primary icon class name for the default icon. Feel free to use this option in your custom buttons as show in the Button option examples.

Set the option upon init.

$('.selector').MonthPicker({ ButtonIcon: 'ui-icon-clock' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var image = $('.selector').MonthPicker('option', 'ButtonIcon');
@@ -426,8 +426,8 @@ $('.selector').MonthPicker('option', 'ButtonIcon', false );
 

Set the option upon init.

$('.selector').MonthPicker({ ShowOn: 'both' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var ShowOn = $('.selector').MonthPicker('option', 'ShowOn');
@@ -451,8 +451,8 @@ $('.selector').MonthPicker('option', 'ShowOn', 'both' );
 

Set the option upon init.

$('.selector').MonthPicker({ IsRTL: true });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var IsRTL = $('.selector').MonthPicker('option', 'IsRTL');
@@ -471,8 +471,8 @@ $('.selector').MonthPicker('option', 'IsRTL', true );
 

Set the option upon init.

$('.selector').MonthPicker({ StartYear: 2023 });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'StartYear');
@@ -491,8 +491,8 @@ $('.selector').MonthPicker('option', 'StartYear', false );
 

Set the option upon init.

$('.selector').MonthPicker({ ValidationErrorMessage: 'Invalid Date!' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'ValidationErrorMessage');
@@ -511,11 +511,11 @@ $('.selector').MonthPicker('option', 'ValidationErrorMessage', null );
 

Set the option upon init. - +

// Results in December, 2015
 $('.selector').MonthPicker({ MonthFormat: 'MM, yy' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'MonthFormat');
@@ -528,30 +528,30 @@ The following example shows how to use the popular 
 $.widget('MyOrg.MomentMonthPicker', $.KidSysco.MonthPicker, {
-	
+
 	// Set the default format.
 	options: {
 		MonthFormat: 'MM/YYYY',
 	},
-	
+
 	// Set the format to use with the HTML 5 month input.
 	MonthInputFormat: 'YYYY-MM',
-	
+
     /**
      * @param str		{String} A string representing a date in the given format.
      * @param format	{String} The format used to parse the str argument.
-     * 
+     *
      * @returns	{Date}	 A JavaScript date.
      */
     ParseMonth: function(str, format) {
         var wrapper = moment(str, format);
         return wrapper.isValid() ? wrapper.toDate() : null;
     },
-    
+
     /**
      * @param date		{Date} A string representing a date in the given format.
      * @param format	{String} The format to use to convert the date to a string.
-     * 
+     *
      * @returns	{String}  A string representing a date in the given format.
      */
     FormatMonth: function(date, format) {
@@ -581,11 +581,11 @@ $('.selector').MomentMonthPicker({
 

Set the option upon init. - +

 $('.selector').MonthPicker({ AltField: '#field' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'AltField');
@@ -603,11 +603,11 @@ $('.selector').MonthPicker('option', 'AltField': '#OtherField' );
 

Set the option upon init. - +

 $('.selector').MonthPicker({ AltFormat: "yy-mm" });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'AltFormat');
@@ -632,8 +632,8 @@ In version 2.4 and later the mask is constructed according to the 
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var disabled = $('.selector').MonthPicker('option', 'UseInputMask');
@@ -659,8 +659,8 @@ $('.selector').MonthPicker('option', 'UseInputMask', false );
 

Set the option upon init.

$('.selector').MonthPicker({ Animation: 'slideToggle' });
- - Get or set the option, after init. + + Get or set the option, after init.
 //getter
 var Animation = $('.selector').MonthPicker('option', 'Animation');
@@ -685,14 +685,14 @@ $('.selector').MonthPicker('option', 'Animation', 'slideToggle' );
 	
  • fast 200ms
  • slow 600ms
  • - + Or you can specify the speed in milliseconds by passing in a number.

    Set the option upon init.

    $('.selector').MonthPicker({ Duration: 'fast' });
    - - Get or set the option, after init. + + Get or set the option, after init.
     //getter
     var Duration = $('.selector').MonthPicker('option', 'Duration');
    @@ -714,7 +714,7 @@ $('.selector').MonthPicker('option', 'Duration', 'fast' );
         If you want to have the same animation for both opening and closing the menu use
         the Animation option instead.
         

    - +

    To set the animation for closing the menu see the HideAnim option.

    @@ -722,8 +722,8 @@ $('.selector').MonthPicker('option', 'Duration', 'fast' );

    Set the option upon init.

    $('.selector').MonthPicker({ ShowAnim: 'slideDown' });
    - - Get or set the option, after init. + + Get or set the option, after init.
     //getter
     var ShowAnim = $('.selector').MonthPicker('option', 'ShowAnim');
    @@ -745,7 +745,7 @@ $('.selector').MonthPicker('option', 'ShowAnim', 'slideDown' );
         If you want to have the same animation for both opening and closing the menu use
         the Animation option instead.
         

    - +

    To set the animation for opening the menu see the ShowAnim option.

    @@ -753,8 +753,8 @@ $('.selector').MonthPicker('option', 'ShowAnim', 'slideDown' );

    Set the option upon init.

    $('.selector').MonthPicker({ HideAnim: 'slideUp' });
    - - Get or set the option, after init. + + Get or set the option, after init.
     //getter
     var HideAnim = $('.selector').MonthPicker('option', 'HideAnim');
    @@ -791,8 +791,8 @@ $('.selector').MonthPicker({
      }
     });
     
    - - Get or set the option, after init. + + Get or set the option, after init.
     //getter
     var position = $('.selector').MonthPicker('option', 'Position');
    @@ -822,8 +822,8 @@ $('.selector').MonthPicker({
     	}
     });
     
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var callback = $('.selector').MonthPicker('option', 'OnBeforeMenuOpen');
    @@ -842,8 +842,8 @@ $('.selector').MonthPicker('option', 'OnBeforeMenuOpen', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterMenuOpen: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterMenuOpen');
    @@ -864,10 +864,10 @@ $('.selector').MonthPicker('option', 'OnAfterMenuOpen', function(){ ... } );
         
     $('.selector').MonthPicker({
     	OnBeforeMenuClose: function(event){
    -		// Prevent the menu from closing when clicking on 
    +		// Prevent the menu from closing when clicking on
     		// the external button or one of it's child nodes.
     		//
    -		// Note: The first argument of $.contains() must be a DOM element, 
    +		// Note: The first argument of $.contains() must be a DOM element,
     		// not a jQuery object or plain JavaScript object.
     		if ( $.contains($('#extarnal_button')[0], event.target) ) {
     			event.preventDefault();
    @@ -875,8 +875,8 @@ $('.selector').MonthPicker({
     	}
     });
     
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var callback = $('.selector').MonthPicker('option', 'OnBeforeMenuClose');
    @@ -895,8 +895,8 @@ $('.selector').MonthPicker('option', 'OnBeforeMenuClose', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterMenuClose: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterMenuClose');
    @@ -917,12 +917,12 @@ $('.selector').MonthPicker('option', 'OnAfterNextYear', function(){ ... } );
         
     $('.selector').MonthPicker({
     	OnAfterSetDisabled: function(isDisabled){
    -		
    +
     	}
     });
     
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var callback = $('.selector').MonthPicker('option', 'OnAfterSetDisabled');
    @@ -941,8 +941,8 @@ $('.selector').MonthPicker('option', 'OnAfterSetDisabled', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterNextYear: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterNextYear');
    @@ -961,8 +961,8 @@ $('.selector').MonthPicker('option', 'OnAfterNextYear', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterNextYears: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterNextYears');
    @@ -981,8 +981,8 @@ $('.selector').MonthPicker('option', 'OnAfterNextYears', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterPreviousYear: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterPreviousYear');
    @@ -1001,8 +1001,8 @@ $('.selector').MonthPicker('option', 'OnAfterPreviousYear', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterPreviousYears: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterPreviousYears');
    @@ -1021,8 +1021,8 @@ $('.selector').MonthPicker('option', 'OnAfterPreviousYears', function(){ ... } )
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterChooseMonth: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterChooseMonth');
    @@ -1041,8 +1041,8 @@ $('.selector').MonthPicker('option', 'OnAfterChooseMonth', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterChooseMonths: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterChooseMonths');
    @@ -1061,8 +1061,8 @@ $('.selector').MonthPicker('option', 'OnAfterChooseMonths', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterChooseYear: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterChooseYear');
    @@ -1081,8 +1081,8 @@ $('.selector').MonthPicker('option', 'OnAfterChooseYear', function(){ ... } );
     

    Supply a callback function to handle the event as an init option.

    $('.selector').MonthPicker({ OnAfterChooseYears: function(){ ... } });
    - - Get or set the callback function, after init. + + Get or set the callback function, after init.
     //getter
     var disabled = $('.selector').MonthPicker('option', 'OnAfterChooseYears');
    @@ -1106,5 +1106,3 @@ If the value is undefined you are using an old version (2.3 and under).
     

    npm install
    This command will install all required dependencies including all resources needed from Bower.

    grunt
    This command will re-compile minified versions of the .js and .css codes before running both through the QUnit tests tests in a headless PhantomJS instance.

    grunt test
    This command will simply re-run all QUnit tests in a headless PhantomJS instance.

    - - From 7b5305f23108ed266b8fab0cc335c1ee6a722185 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 2 Jan 2016 20:02:31 +0200 Subject: [PATCH 22/48] Makes sure the Jump Years label won't show if the user clicks the button while the label is animating --- MonthPicker.js | 77 ++++++++++++++++++++++++---------------------- MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 609ff66..c4ddada 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -153,40 +153,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return !elem.is('input'); } - function _applyFadeShowYears(jumpYears) { - var tOut = null, speed = 125; - var _prevText; - var that = this; - - jumpYears.on('mouseenter' + _eventsNs + '-j', function(e) { - var me = this; - tOut = setTimeout(function() { - tOut = null; - - $("span", me).animate({ opacity: .45 }, { - duration: speed, - complete: function() { - _prevText=$("span", me).text(); - $("span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); - } - }); - }, 175); - }).on('mouseleave' + _eventsNs + '-j', function(e) { - if (tOut) { - return clearTimeout(tOut); - } else { - var me = this; - - $("span", me).animate({ opacity: .45 },{ - duration: speed, - complete: function() { - $("span", me).text(_prevText).animate({opacity: 1}, speed); - } - }); - } - }); - } - $.MonthPicker = { VERSION: '3.0-alpha5', // Added in version 2.4; i18n: { @@ -362,7 +328,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).button().removeClass('ui-state-default'); - _applyFadeShowYears.call(this, this._jumpYearsButton); + this._applyFadeShowYears(); this._createValidationMessage(); @@ -597,6 +563,43 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._showMonths(); }, + _applyFadeShowYears: function(jumpYears) { + var speed = 125; + var _prevText; + var that = this; + + this._jumpYearsButton.on('mouseenter' + _eventsNs + '-j', function(e) { + var me = this; + that.tOut = setTimeout(function() { + that.tOut = null; + + $("span", me).animate({ opacity: .45 }, { + duration: speed, + complete: function() { + if (!that._backToYear) { + _prevText=$("span", me).text(); + $("span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); + } + } + + }); + }, 175); + }).on('mouseleave' + _eventsNs + '-j', function(e) { + if (that.tOut) { + return clearTimeout(that.tOut); + } else { + var me = this; + + $("span", me).animate({ opacity: .45 },{ + duration: speed, + complete: function() { + $("span", me).text(_prevText).animate({opacity: 1}, speed); + } + }); + } + }); + }, + _i18n: function(str) { return this.options.i18n[str] || $.MonthPicker.i18n[str]; }, @@ -832,8 +835,10 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._showYears(); if (!this._backToYear) { + clearTimeout(this.tOut); this._jumpYearsButton.off(_eventsNs + '-j'); this._jumpYearsButton/*.addClass('ui-state-hover')*/.button({label: 'Back to ' + this._getPickerYear()}); + this._jumpYearsButton.find('span').stop().css({ opacity: 1 }); this._backToYear = this._getPickerYear(); @@ -841,7 +846,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else { //this._jumpYearsButton/*.addClass('ui-state-hover')*/.button({label: 'Year ' + this._getPickerYear()}); this._setPickerYear(this._backToYear); - _applyFadeShowYears.call(this, this._jumpYearsButton); + this._applyFadeShowYears(); this._showMonths(); this._backToYear = 0; } diff --git a/MonthPicker.min.js b/MonthPicker.min.js index bf4654b..3b771df 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===a.inArray(c,D[b])?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha5",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).button(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.button({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.button({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 0bbb020..efbaccb 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return G(b.options[a]||F,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b){var c,d=null,e=125,f=this;b.mouseover(function(b){var g=this;d=setTimeout(function(){d=null,a("span",g).animate({opacity:.45},{duration:e,complete:function(){c=a("span",g).text(),a("span",g).animate({opacity:1},e).text(f._i18n("jumpYears"))}})},175)}).mouseout(function(b){if(d)return clearTimeout(d);var f=this;a("span",f).animate({opacity:.45},{duration:e,complete:function(){a("span",f).text(c).animate({opacity:1},e)}})})}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(x+"The jQuery UI button and datepicker plug-ins must be loaded.");var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x="MonthPicker Error: ",y=x+"The jQuery UI position plug-in must be loaded.",z=x+"Unsupported % option value, supported values are: ",A=x+'"_" is not a valid %Month value.',B=null,C=!!a.ui.position,D={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},E={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},F=a.noop,G=a.proxy,H=a.datepicker,I="click"+r;a.MonthPicker={VERSION:"3.0-alpha4",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var J='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(I);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!C)return void alert(y);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in D&&-1===a.inArray(c,D[b])?void alert(z.replace(/%/,b)+D[b]):(this._super(b,c),void(E[b]?this[E[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=x+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(x+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!C)return alert(y),!1;for(var h in D)if(null!==e[h]&&-1===a.inArray(e[h],D[h]))return alert(z.replace(/%/,h)+D[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(J).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(G(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),p.call(this,l),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),q=0;12>q;q++){var r=q%3?r:a("").appendTo(n);r.append('')}this._buttons=a("button",n).button(),i.on(I,function(a){return!1});var s=this,t="Month";a.each(["Min","Max"],function(a,b){s["_set"+b+t]=function(a){(s["_"+b+t]=j(s,a))===!1&&alert(A.replace(/%/,b).replace(/_/,a))},s._setOption(b+t,s.options[b+t])});var u=e.SelectedMonth;if(void 0!==u){var v=j(this,u);b.val(this._formatMonth(new d(f(v),v%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(G(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=F)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{B&&B.Close(b),B=this,a(c).on(I+this.uuid,G(this.Close,this)).on("keydown"+r+this.uuid,G(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:G(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,B=null,a(c).off("keydown"+r+this.uuid).off(I+this.uuid),this.Validate(),d.on("blur"+r,G(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return H.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return H.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(I,G(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=I+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,G(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,G(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:C?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=new d(this._getPickerYear(),b-1);this.element.val(this._formatMonth(c)).blur(),this._updateAlt(0,c),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(c)},_chooseYear:function(a){this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(I).on(I,G(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(I).on(I,G(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=G(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(I,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),k("OnAfterChooseYears",this)()},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(I).on(I,G(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(I).on(I,G(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=G(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(I,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._setPickerYear(this._getPickerYear()+a),this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").button({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.button("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha5",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).button().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).button({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).button(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.button("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.button({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.button({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).button("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.button({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).button("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).button("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).button({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.button("option","disabled",g&&b==f(g)),this._nextButton.button("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).button({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From 236da1af4e3574ea84b50e9251fb966d92eb331e Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Wed, 6 Jan 2016 09:57:16 +0200 Subject: [PATCH 23/48] Adds MonthPicker.css to the main files in bower.json --- bower.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index e947905..dddb01a 100644 --- a/bower.json +++ b/bower.json @@ -7,7 +7,10 @@ "Benjamin Albert " ], "description": "jQuery UI Month Picker plugin", - "main": "MonthPicker.js", + "main": [ + "MonthPicker.js", + "css/MonthPicker.css" + ], "license": "MIT", "ignore": [ "**/.*", From a119ac243c1f152acd3b632e7421acb5d1e3b414 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 12 Jan 2016 12:15:34 +0200 Subject: [PATCH 24/48] Improves CSS layout and adds comments. Switches the use of the px unit with em, which makes the menu better handle other users CSS which might have a different font-size. --- MonthPicker.js | 15 ++++--- css/MonthPicker.css | 101 ++++++++++++++++++++++++++++++-------------- 2 files changed, 78 insertions(+), 38 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 712e0af..dacd1f9 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -183,7 +183,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '' + '
    ' + '
    ' + - '
    ' + + '
    ' + '' + ''; @@ -319,7 +319,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _el.css('width', 'auto'); } - var _menu = this._monthPickerMenu = $('
    ').hide(); + var _menu = this._monthPickerMenu = $('
    ').hide(); var isInline = _isInline(_el); $(_markup).appendTo(_menu); @@ -577,7 +577,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. that.tOut = setTimeout(function() { that.tOut = null; - $("span", me).animate({ opacity: .45 }, { + $("span", me).animate({ opacity: 0.45 }, { duration: speed, complete: function() { if (!that._backToYear) { @@ -594,7 +594,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else { var me = this; - $("span", me).animate({ opacity: .45 },{ + $("span", me).animate({ opacity: 0.45 },{ duration: speed, complete: function() { $("span", me).text(_prevText).animate({opacity: 1}, speed); @@ -921,12 +921,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._setPickerYear( this._getPickerYear() + amount ); //_year.text(parseInt(_year.text()) + amount, 10); this.element.focus(); - + // var me = this; +// var _btn = amount > 0 ? me._nextButton : me._prevButton; + // _btn.jqueryUIButton({label: ""}); +/* var me = this; setTimeout(function() { var _btn = amount > 0 ? me._nextButton : me._prevButton; _btn.addClass('ui-state-hover'); - }, 1); + }, 1);*/ this._decorateButtons(); diff --git a/css/MonthPicker.css b/css/MonthPicker.css index ae6a59e..9b1857e 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -26,27 +26,60 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. border-spacing: 2px 2px; } +.month-picker td { + padding: 0px; +} + +/* +Prevents the button labels from maving sligtly to the left +when applying the width CSS property to the buttons. +See: .month-picker-month-table button { width: 4.3em; } +*/ +.month-picker .ui-button-text { + padding: .4em 0; +} + .month-picker-header { margin: 3px 3px 0px 3px; } + +.month-picker-year-table { + width: 100%; +} .month-picker-year-table .jump-years { text-align: center; } + +/* +The plugin uses buttons with a transparent background in the year-table +(aka header) in order to look consistent with jQuery UI datepicker and to +make the year title a button that blends into the heading in the default state. + +The plugin does this by removing the .ui-state-default class from (in MonthPicker.js) +the a tags (buttons) which also ends up removing the 1px border that it applies. + +To prevent the button from resizing and moving everything around when you hover +in and out, we use a carefully constructed selector, which gets overroden by the +more specific .ui-state-hover/actove class selectors in the jquery-ui.css +that apply the visible borders that we want. + +This selector applies a 1px transparent border that keeps the button +in the same size, but it doesen't hide the borders that .ui-state-hover/actove give us. +*/ .month-picker-year-table a { border: 1px solid transparent; } -.month-picker-year-table .year-title { - margin: 3px; - font-size: 12px; - font-family: Verdana, Arial, sans-serif; -} -.month-picker-year-table .year { - margin: 3px; - font-size: 12px; - font-family: Verdana, Arial, sans-serif; -} -.month-picker-year-table { - width: 100%; + +/* +Sets the size of the next/previous buttons, +and makes the buttons in the heading (year-table) sligtly bigger, +and removes the pointer cursor from the buttons in the heading (year-table). +*/ +.month-picker-year-table a.ui-button { + font-size: 1.1em; + width: 1.5em; + height: 1.5em; + cursor: default; } .month-picker-year-table .previous-year>a { @@ -57,51 +90,55 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. /*text-align: left;*/ float: left; } + .month-picker-year-table .next-year>a { - /*text-align: right;*/ float: right; } -.month-picker-year-table td { - padding: 0px; +.month-picker-year-table .jump-years a.ui-button { + width: 100%; } -.month-picker-year-table /*button*/ a { - /*width: 28px;*/ - margin: 0px; - width: 1.5em; - height: 1.5em; - text-align: center; - cursor: pointer; -} +/* +The buttons in the heading (year-table) are slightly shrinked, but because jQuery ui and +the .month-picker .ui-button-text rule at the top of this CSS file apply some +padding which results in the button text being moved to the bottom of +the button. -.jump-years a { - width: 100%; +This rule removes the unnecessary padding so the text in +the jump years button will be vericaly centred. +*/ +.month-picker-year-table .ui-button-text { + padding: 0; } -.month-picker-year-table .jump-years span { - padding: inherit; /*padding-bottom: 0 inherit;*/ - } - .month-picker-month-table td { - padding: 0; height: 35px; text-align: center; - font-size: 12px; } + +/* +Makes sure the buttons stay in the same size when swithching +to the Jump years menu. +this also ensures that the entire menu dosen't resize itself +in response to the slightly bigger buttons in the Jump years menu. + */ .month-picker-month-table button { - width: 55px; + width: 4.3em; margin: 3px; } + .month-picker-open-button { height: 20px; width: 20px; vertical-align: bottom; } + .month-picker-invalid-message { display: none; background-color: Yellow; } + .month-picker-disabled { background-color: #e1e1e1; } From 124ec3b3f1c665b550c5e9a2579860576ae5cb82 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 12 Jan 2016 12:27:15 +0200 Subject: [PATCH 25/48] Bumps version to 3.0-beta1 --- MonthPicker.js | 4 ++-- MonthPicker.min.js | 2 +- README.md | 2 +- bower.json | 2 +- css/MonthPicker.css | 2 +- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- package.json | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index dacd1f9..4dffa3b 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -1,7 +1,7 @@ /* https://github.com/KidSysco/jquery-ui-month-picker/ -Version 3.0-alpha6 +Version 3.0-beta1 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -158,7 +158,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } $.MonthPicker = { - VERSION: '3.0-alpha6', // Added in version 2.4; + VERSION: '3.0-beta1', // Added in version 2.4; i18n: { year: "Year", prevYear: "Previous Year", diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 8532f77..6fb9676 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha6",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/README.md b/README.md index 1c71e29..701d05c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

    The jQuery UI Month Picker Version 3.0-alpha6

    +

    The jQuery UI Month Picker Version 3.0-beta1

    [![Build Status](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker.svg?branch=3.0_prototype)](https://travis-ci.org/benjamin-albert/jquery-ui-month-picker) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) diff --git a/bower.json b/bower.json index dddb01a..334bd90 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-ui-month-picker", - "version": "2.8.3", + "version": "3.0-beta1", "homepage": "https://github.com/KidSysco/jquery-ui-month-picker", "authors": [ "Ryan Segura ", diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 9b1857e..22520e0 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -1,5 +1,5 @@ /* -The jQuery UI Month Picker Version 3.0-alpha6 +The jQuery UI Month Picker Version 3.0-beta1 https://github.com/KidSysco/jquery-ui-month-picker/ diff --git a/demo/Demo.min.css b/demo/Demo.min.css index add40b3..310f347 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker-header{margin:3px 3px 0}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table .year,.month-picker-year-table .year-title{margin:3px;font-size:12px;font-family:Verdana,Arial,sans-serif}.month-picker-year-table{width:100%}.month-picker-year-table .previous-year>a{width:35px;float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table td{padding:0}.month-picker-year-table a{border:1px solid transparent;margin:0;width:1.5em;height:1.5em;text-align:center;cursor:pointer}.jump-years a{width:100%}.month-picker-year-table .jump-years span{padding:inherit}.month-picker-month-table td{padding:0;height:35px;text-align:center;font-size:12px}.month-picker-month-table button{width:55px;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .previous-year>a{float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table .jump-years a.ui-button{width:100%}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index fc6f68a..ee1ebca 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-alpha6",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus();var b=this;setTimeout(function(){var c=a>0?b._nextButton:b._prevButton;c.addClass("ui-state-hover")},1),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/package.json b/package.json index efebb29..5fefab6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jquery-ui-month-picker", "description": "jQuery UI Month Picker Plugin", - "version": "2.8.3", + "version": "3.0.0-beta1", "scripts": { "postinstall" : "bower install" From 70f724eb96d23215ec5054a70cff0a88a2f2b76f Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 12 Jan 2016 13:55:48 +0200 Subject: [PATCH 26/48] Renames next/prev5Years i18n properties to next/prev12Years and updates README.md. --- MonthPicker.js | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 4dffa3b..0b9e8ce 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -163,8 +163,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. year: "Year", prevYear: "Previous Year", nextYear: "Next Year", - next5Years: 'Jump Forward 5 Years', - prev5Years: 'Jump Back 5 Years', + next12Years: 'Jump Forward 12 Years', + prev12Years: 'Jump Back 12 Years', nextLabel: "Next", prevLabel: "Prev", buttonText: "Open Month Chooser", @@ -868,13 +868,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _minYear = _minDate ? _toYear(_minDate) : 0; var _maxYear = _maxDate ? _toYear(_maxDate) : 0; this._prevButton - .attr('title', this._i18n('prev5Years')) + .attr('title', this._i18n('prev12Years')) .off(click) .on(click, $proxy(this._addToYears, this, -AMOUNT_TO_ADD)) .jqueryUIButton('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); this._nextButton - .attr('title', this._i18n('next5Years')) + .attr('title', this._i18n('next12Years')) .off(click) .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)) .jqueryUIButton('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); diff --git a/README.md b/README.md index 701d05c..5a8c1cf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)

    The jQuery UI Month Picker Plugin is designed to allow user input for only a month and year when only that input is -required. Clicking on the year, allows the user to jump ahead or back 5 years at a time. Clicking anywhere on the +required. Clicking on the year, allows the user to jump ahead or back 12 years at a time. Clicking anywhere on the page, except on the month picker menu itself, will cause the month picker to hide. The Month Picker has lots of options for date validation, setting the start year, using an icon button, input masking, internationalization and localization and more.

    From a3bbb04ea0ec79f18341ce63bd1ebf1f56405d5c Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 12 Jan 2016 15:36:07 +0200 Subject: [PATCH 27/48] Adds MonthPickerButton and makes all buttons in the header use it --- MonthPicker.js | 60 ++++++++++++++++++++++----------------------- css/MonthPicker.css | 1 + test/test.js | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 31 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 0b9e8ce..8726ac2 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -146,7 +146,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } function _applyArrowButton($el, dir) { - $el.jqueryUIButton('option', { + $el.MonthPickerButton('option', { icons: { primary: 'ui-icon-circle-triangle-' + (dir ? 'w' : 'e') } @@ -187,6 +187,22 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
    ' + ''; + $.widget("KidSysco.MonthPickerButton", $.ui.button, { + _create: function() { + this.widgetFullName = 'ui-button'; + this._superApply(arguments); + this.element.removeClass('ui-state-default'); + }, + + _setOption: function(key, value) { + if (key === 'disabled' && this.options[key] === value) { + return; + } + + this._super(key, value); + } + }); + $.widget("KidSysco.MonthPicker", { /******* Properties *******/ @@ -325,20 +341,17 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $(_markup).appendTo(_menu); (_menu).appendTo( isInline ? _el : document.body ); - var jumpYears = + this._jumpYearsButton = $('.jump-years', _menu) .attr('title', this._i18n('jumpYears')) - .click($proxy(this._showYearsClickHandler, this)); - - this._jumpYearsButton = jumpYears.find('a').css({'cursor': 'default','fontWeight':'bold'}).jqueryUIButton().removeClass('ui-state-default'); + .click($proxy(this._showYearsClickHandler, this)) + .find('a').MonthPickerButton(); this._applyFadeShowYears(); - this._createValidationMessage(); - this._prevButton = $('.previous-year a', _menu); - this._prevButton.jqueryUIButton({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); - this._nextButton = $('.next-year a', _menu).jqueryUIButton({ text: false }).removeClass('ui-state-default').css('cursor', 'default'); + this._prevButton = $('.previous-year a', _menu).MonthPickerButton({ text: false }); + this._nextButton = $('.next-year a', _menu).MonthPickerButton({ text: false }); this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. @@ -774,7 +787,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); - this._jumpYearsButton.jqueryUIButton({ label: this._i18n('year') + ' ' + this._pickerYear }) + this._jumpYearsButton.MonthPickerButton({ label: this._i18n('year') + ' ' + this._pickerYear }); //this._yearContainer.text(year || new Date().getFullYear()); }, @@ -795,7 +808,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setActive( this._selectedBtn, false ); this._selectedBtn = _setActive( $(this._buttons[month-1]), true ); - this._jumpYearsButton.jqueryUIButton({label: 'Year ' + _year}); + this._jumpYearsButton.MonthPickerButton({label: 'Year ' + _year}); _event('OnAfterChooseMonth', this)(date); }, @@ -841,7 +854,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (!this._backToYear) { clearTimeout(this.tOut); this._jumpYearsButton.off(_eventsNs + '-j'); - this._jumpYearsButton/*.addClass('ui-state-hover')*/.jqueryUIButton({label: 'Back to ' + this._getPickerYear()}); + this._jumpYearsButton.MonthPickerButton({label: 'Back to ' + this._getPickerYear()}); this._jumpYearsButton.find('span').stop().css({ opacity: 1 }); this._backToYear = this._getPickerYear(); @@ -871,13 +884,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .attr('title', this._i18n('prev12Years')) .off(click) .on(click, $proxy(this._addToYears, this, -AMOUNT_TO_ADD)) - .jqueryUIButton('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); + .MonthPickerButton('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); this._nextButton .attr('title', this._i18n('next12Years')) .off(click) .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)) - .jqueryUIButton('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); + .MonthPickerButton('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); this._buttons.off(_eventsNs); @@ -917,29 +930,14 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _addToYear: function(amount) { - //var _year = this._yearContainer; this._setPickerYear( this._getPickerYear() + amount ); - //_year.text(parseInt(_year.text()) + amount, 10); this.element.focus(); - // var me = this; -// var _btn = amount > 0 ? me._nextButton : me._prevButton; - // _btn.jqueryUIButton({label: ""}); -/* - var me = this; - setTimeout(function() { - var _btn = amount > 0 ? me._nextButton : me._prevButton; - _btn.addClass('ui-state-hover'); - }, 1);*/ - this._decorateButtons(); _event('OnAfter' + (amount > 0 ? 'Next' : 'Previous') + 'Year', this)(); }, _addToYears: function(amount) { - //var _year = this._yearContainer; - //_year.text(parseInt(_year.text()) + amount, 10); - //this._setPickerYear( this._getPickerYear() + amount ); this._pickerYear = this._getPickerYear() + amount; this._showYears(); this.element.focus(); @@ -973,8 +971,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } // Disable the next/prev button if we've reached the min/max year. - this._prevButton.jqueryUIButton('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); - this._nextButton.jqueryUIButton('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); + this._prevButton.MonthPickerButton('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); + this._nextButton.MonthPickerButton('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); for (var i = 0; i < 12; i++) { // Disable the button if the month is not between the diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 22520e0..165c4e6 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -97,6 +97,7 @@ and removes the pointer cursor from the buttons in the heading (year-table). .month-picker-year-table .jump-years a.ui-button { width: 100%; + font-weight: bold; } /* diff --git a/test/test.js b/test/test.js index c7d1564..94a72c7 100644 --- a/test/test.js +++ b/test/test.js @@ -1058,6 +1058,8 @@ QUnit.test('Year buttons are disabled', function (assert) { .trigger('click') .is('.ui-button-disabled'); + console.log(nextYearsButton[0].className); + assert.ok(isDisabled, 'The next year button is disabled'); var newFirstYrar = parseInt($(buttons[0]).text(), 10); assert.equal(newFirstYrar, firstVisibleYear, "Clicking next year didn't change the year"); @@ -1422,3 +1424,46 @@ QUnit.test('JavaScript Date objects', function (assert) { // in another Min/MaxMonth test. field.MonthPicker('destroy'); }); + +QUnit.module('Version 3.0'); + +QUnit.test('Title buttons', function (assert) { + var field = $(RistrictMonthField).MonthPicker({ + MaxMonth: '+2Y' + }); + + var menu = $(MonthPicker_RistrictMonthField); + var nextButton = menu.find('.next-year .ui-button'); + field.MonthPicker('Open'); + + assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class"); + + nextButton.trigger('mouseover'); + assert.ok(nextButton.is('.ui-state-hover'), 'The next button has the .ui-state-hover class'); + + nextButton.trigger('mousedown'); + assert.ok(nextButton.is('.ui-state-active'), 'The next button has the .ui-state-active class'); + + nextButton.trigger('click'); + nextButton.trigger('mouseup'); + assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class after clicking it"); + assert.notOk(nextButton.is('.ui-state-active'), "The next button doesn't have the .ui-state-active class after clicking it"); + assert.ok(nextButton.is('.ui-state-hover'), 'The next button has the .ui-state-hover class after clicking it'); + + nextButton.trigger('mouseleave'); + assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class after mouseleave"); + assert.notOk(nextButton.is('.ui-state-hover'), "The next button doesn't have .ui-state-hover class after mouseleave"); + assert.notOk(nextButton.is('.ui-state-active'), "The next button doesn't have the .ui-state-active class after mouseleave"); + + nextButton.trigger('mouseover'); + assert.ok(nextButton.is('.ui-state-hover'), 'The next button has the .ui-state-hover class'); + + nextButton.trigger('click'); + nextButton.trigger('mouseup'); + assert.ok(nextButton.is('.ui-button-disabled'), 'Navigating to the last year allowd (+2Y) disabled the next button'); + assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class when disabled"); + assert.notOk(nextButton.is('.ui-state-hover'), "The next button doesn't have .ui-state-hover class when disabled"); + assert.notOk(nextButton.is('.ui-state-active'), "The next button doesn't have the .ui-state-active class when disabled"); + + field.MonthPicker('destroy'); +}); From 079649d7dcbb8b0196ee5970d1642c4694cfb8c2 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 12 Jan 2016 17:36:29 +0200 Subject: [PATCH 28/48] Makes MonthPickerButton a private widget named _headerButton --- MonthPicker.js | 27 ++++++++++++++------------- test/test.js | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 8726ac2..e20a8fb 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -17,6 +17,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. (function ($, window, document, Date) { 'use strict'; + var _setupErr = 'MonthPicker Error: '; // This test must be run before any rererence is made to jQuery. // In case the user didn't load jQuery or jQuery UI the plugin // will fail before it get's to this test + there is no reason @@ -37,7 +38,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _selectedClass = 'ui-state-active'; var _defaultPos = { my: 'left top+1', at: 'left bottom' }; var _RTL_defaultPos = { my: 'right top+1', at: 'right bottom' }; - var _setupErr = 'MonthPicker Error: '; var _posErr = _setupErr + 'The jQuery UI position plug-in must be loaded.'; var _badOptValErr = _setupErr + 'Unsupported % option value, supported values are: '; var _badMinMaxVal = _setupErr + '"_" is not a valid %Month value.'; @@ -146,7 +146,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } function _applyArrowButton($el, dir) { - $el.MonthPickerButton('option', { + $el[ _headerButton ]('option', { icons: { primary: 'ui-icon-circle-triangle-' + (dir ? 'w' : 'e') } @@ -187,7 +187,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
    ' + ''; - $.widget("KidSysco.MonthPickerButton", $.ui.button, { + var _headerButton = Date(); + $.widget("KidSysco." + _headerButton, $.ui.button, { _create: function() { this.widgetFullName = 'ui-button'; this._superApply(arguments); @@ -345,13 +346,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $('.jump-years', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)) - .find('a').MonthPickerButton(); + .find('a')[ _headerButton ](); this._applyFadeShowYears(); this._createValidationMessage(); - this._prevButton = $('.previous-year a', _menu).MonthPickerButton({ text: false }); - this._nextButton = $('.next-year a', _menu).MonthPickerButton({ text: false }); + this._prevButton = $('.previous-year a', _menu)[ _headerButton ]({ text: false }); + this._nextButton = $('.next-year a', _menu)[ _headerButton ]({ text: false }); this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. @@ -787,7 +788,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); - this._jumpYearsButton.MonthPickerButton({ label: this._i18n('year') + ' ' + this._pickerYear }); + this._jumpYearsButton[ _headerButton ]({ label: this._i18n('year') + ' ' + this._pickerYear }); //this._yearContainer.text(year || new Date().getFullYear()); }, @@ -808,7 +809,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setActive( this._selectedBtn, false ); this._selectedBtn = _setActive( $(this._buttons[month-1]), true ); - this._jumpYearsButton.MonthPickerButton({label: 'Year ' + _year}); + this._jumpYearsButton[ _headerButton ]({label: 'Year ' + _year}); _event('OnAfterChooseMonth', this)(date); }, @@ -854,7 +855,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (!this._backToYear) { clearTimeout(this.tOut); this._jumpYearsButton.off(_eventsNs + '-j'); - this._jumpYearsButton.MonthPickerButton({label: 'Back to ' + this._getPickerYear()}); + this._jumpYearsButton[ _headerButton ]({label: 'Back to ' + this._getPickerYear()}); this._jumpYearsButton.find('span').stop().css({ opacity: 1 }); this._backToYear = this._getPickerYear(); @@ -884,13 +885,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .attr('title', this._i18n('prev12Years')) .off(click) .on(click, $proxy(this._addToYears, this, -AMOUNT_TO_ADD)) - .MonthPickerButton('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); + [ _headerButton ]('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); this._nextButton .attr('title', this._i18n('next12Years')) .off(click) .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)) - .MonthPickerButton('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); + [ _headerButton ]('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); this._buttons.off(_eventsNs); @@ -971,8 +972,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } // Disable the next/prev button if we've reached the min/max year. - this._prevButton.MonthPickerButton('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); - this._nextButton.MonthPickerButton('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); + this._prevButton[ _headerButton ]('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); + this._nextButton[ _headerButton ]('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); for (var i = 0; i < 12; i++) { // Disable the button if the month is not between the diff --git a/test/test.js b/test/test.js index 94a72c7..5572ac4 100644 --- a/test/test.js +++ b/test/test.js @@ -1428,11 +1428,11 @@ QUnit.test('JavaScript Date objects', function (assert) { QUnit.module('Version 3.0'); QUnit.test('Title buttons', function (assert) { - var field = $(RistrictMonthField).MonthPicker({ + var field = $("").prependTo(document.body).MonthPicker({ MaxMonth: '+2Y' }); - var menu = $(MonthPicker_RistrictMonthField); + var menu = $(MonthPicker_TitleButton); var nextButton = menu.find('.next-year .ui-button'); field.MonthPicker('Open'); From fca9ef3dcbe87359977130a1be804e09365ab82a Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Wed, 13 Jan 2016 15:59:13 +0200 Subject: [PATCH 29/48] Fixes rare memory leak + renames _event() argument 1. Makes _destory() clear the _openedInstance var if plugin is destroyed while the menu is still opened. 2. The _event() function had an argument which was also called _event. This commit renames the _event argument to _name to avoid confusion. --- MonthPicker.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 7e4bea1..0f8086b 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -105,8 +105,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return _parsePeriod(_val); } - function _event(_event, _inst) { - return $proxy(_inst.options[_event] || $noop, _inst.element[0]); + function _event(_name, _inst) { + return $proxy(_inst.options[_name] || $noop, _inst.element[0]); } function _parsePeriod(_val, _initDate) { @@ -247,6 +247,10 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } this._validationMessage.remove(); + + if (_openedInstance === this) { + _openedInstance = null; + } }, _setOption: function (key, value) { From df3eb04529a4d8494dcff32a991d05efcaeb3588 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Wed, 13 Jan 2016 16:27:36 +0200 Subject: [PATCH 30/48] Makes the Title buttons test use an existing --- test/test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index 5572ac4..644360d 100644 --- a/test/test.js +++ b/test/test.js @@ -1058,8 +1058,6 @@ QUnit.test('Year buttons are disabled', function (assert) { .trigger('click') .is('.ui-button-disabled'); - console.log(nextYearsButton[0].className); - assert.ok(isDisabled, 'The next year button is disabled'); var newFirstYrar = parseInt($(buttons[0]).text(), 10); assert.equal(newFirstYrar, firstVisibleYear, "Clicking next year didn't change the year"); @@ -1428,11 +1426,12 @@ QUnit.test('JavaScript Date objects', function (assert) { QUnit.module('Version 3.0'); QUnit.test('Title buttons', function (assert) { - var field = $("").prependTo(document.body).MonthPicker({ + var field = $(RistrictMonthField).val('').MonthPicker({ + Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. MaxMonth: '+2Y' }); - var menu = $(MonthPicker_TitleButton); + var menu = $(MonthPicker_RistrictMonthField); var nextButton = menu.find('.next-year .ui-button'); field.MonthPicker('Open'); @@ -1460,6 +1459,7 @@ QUnit.test('Title buttons', function (assert) { nextButton.trigger('click'); nextButton.trigger('mouseup'); + assert.ok(nextButton.is('.ui-button-disabled'), 'Navigating to the last year allowd (+2Y) disabled the next button'); assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class when disabled"); assert.notOk(nextButton.is('.ui-state-hover'), "The next button doesn't have .ui-state-hover class when disabled"); From a5b18e5c42cab096c6891c1180ddde9c766be6c2 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 09:45:25 +0200 Subject: [PATCH 31/48] Adds the Back to 2015 button test --- MonthPicker.js | 19 ++++++++------ test/test.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 3a30cce..211c628 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -160,15 +160,16 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $.MonthPicker = { VERSION: '3.0-beta1', // Added in version 2.4; i18n: { - year: "Year", - prevYear: "Previous Year", - nextYear: "Next Year", + year: 'Year', + prevYear: 'Previous Year', + nextYear: 'Next Year', next12Years: 'Jump Forward 12 Years', prev12Years: 'Jump Back 12 Years', - nextLabel: "Next", - prevLabel: "Prev", - buttonText: "Open Month Chooser", - jumpYears: "Jump Years", + nextLabel: 'Next', + prevLabel: 'Prev', + buttonText: 'Open Month Chooser', + jumpYears: 'Jump Years', + backTo: 'Back to', months: ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'June', 'July', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'] } }; @@ -859,7 +860,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (!this._backToYear) { clearTimeout(this.tOut); this._jumpYearsButton.off(_eventsNs + '-j'); - this._jumpYearsButton[ _headerButton ]({label: 'Back to ' + this._getPickerYear()}); + this._jumpYearsButton[ _headerButton ]({ + label: this._i18n('backTo') + ' ' + this._getPickerYear() + }); this._jumpYearsButton.find('span').stop().css({ opacity: 1 }); this._backToYear = this._getPickerYear(); diff --git a/test/test.js b/test/test.js index 644360d..6d16026 100644 --- a/test/test.js +++ b/test/test.js @@ -1467,3 +1467,71 @@ QUnit.test('Title buttons', function (assert) { field.MonthPicker('destroy'); }); + +/* +Here we make sure that clicling the jump years button +when in jump years mode will return the user to the year +they were when they clicked Jump years. +*/ +QUnit.test('Back to 2015 button', function (assert) { + var field = $(RistrictMonthField).val('').MonthPicker({ + Animation: 'none' // Disable animation to make sure opening and closing the menu is synchronous. + }); + + field.MonthPicker('Open'); + var menu = $(MonthPicker_RistrictMonthField); + var titleButton = menu.find('.jump-years .ui-button'); + var nextButton = menu.find('.next-year .ui-button'); + var backButton = menu.find('.previous-year .ui-button'); + + nextButton.trigger('click'); + var nextYear = _today.getFullYear() + 1; + assert.equal(_getPickerYear(menu), nextYear, 'Clicking next took us to the next year (' + nextYear + ')'); + + titleButton.trigger('click'); + var expectedTitle = $.MonthPicker.i18n.backTo + ' ' + nextYear; + + assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'The title button has the expected label' ); + + /* + Here we simulate the user jumping back and forth in + the jump years menu. + The point is to make sure the button will still return + the user to the expected year. + */ + + // Keep clicking next until today's year is not visible. + // We count to 10 to avoid an infinite loop in case there's + // a bug where the next button is not going to the next year. + var buttons = menu.find('.month-picker-month-table button'); + var hasNext = buttons.is('.ui-state-highlight'); + assert.ok( hasNext, "Today's year is highlighted" ); + var i = 0; + for (; hasNext && i < 10; i++) { + nextButton.trigger('click'); + hasNext = buttons.is('.ui-state-highlight'); + } + var nextClickCount = i; + + assert.notOk( hasNext, "Today's year is not visible after clicking next" ); + assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'Clicking next did not change the button label' ); + + for (var p = 0; p < nextClickCount * 2; p++) { + backButton.trigger('click'); + } + + hasNext = buttons.is('.ui-state-highlight'); + assert.notOk( hasNext, "Today's year is not visible after clicking previous" ); + assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'Clicking previous did not change the button label' ); + + // Click the title button and make sure it returnd us to the expected year. + titleButton.trigger('click'); + assert.equal(_getPickerYear(menu), nextYear, 'Clicking next took us to the next year (' + nextYear + ')'); + + $(buttons[0]).trigger('click'); + var selectedDate = field.MonthPicker('GetSelectedDate'); + assert.equal( selectedDate.getFullYear(), nextYear, 'Clicking the first month selected the expected year' ); + assert.equal( selectedDate.getMonth() + 1, 1, 'Clicking the first month selected the expected month' ); + + field.MonthPicker('Destroy'); +}); From 4fd4eff40c31f39a9d18d6523d5fbe8c49a8d8ac Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 10:13:14 +0200 Subject: [PATCH 32/48] Ajusts RTL support for the new designs CSS --- MonthPicker.js | 8 ++------ css/MonthPicker.css | 13 ------------- test/test.js | 7 +++++-- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 211c628..b552634 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -707,8 +707,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _setRTL: function(value) { - _applyArrowButton(this._prevButton, !value); - _applyArrowButton(this._nextButton, value); + _applyArrowButton( this._prevButton.css('float', value ? 'right' : 'left'), !value ); + _applyArrowButton( this._nextButton.css('float', value ? 'left' : 'right'), value ); }, _keyDown: function (event) { @@ -787,14 +787,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _getPickerYear: function () { - //return parseInt(this._yearContainer.text(), 10); return this._pickerYear; }, _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); this._jumpYearsButton[ _headerButton ]({ label: this._i18n('year') + ' ' + this._pickerYear }); - //this._yearContainer.text(year || new Date().getFullYear()); }, _updateAlt: function (noop, date) { @@ -814,8 +812,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setActive( this._selectedBtn, false ); this._selectedBtn = _setActive( $(this._buttons[month-1]), true ); - this._jumpYearsButton[ _headerButton ]({label: 'Year ' + _year}); - _event('OnAfterChooseMonth', this)(date); }, diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 165c4e6..2fde3af 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -82,19 +82,6 @@ and removes the pointer cursor from the buttons in the heading (year-table). cursor: default; } -.month-picker-year-table .previous-year>a { - /* - In case the user's css reset the user agent stylesheet - this is often done in RTL pages. - */ - /*text-align: left;*/ - float: left; -} - -.month-picker-year-table .next-year>a { - float: right; -} - .month-picker-year-table .jump-years a.ui-button { width: 100%; font-weight: bold; diff --git a/test/test.js b/test/test.js index 6d16026..a2c09c9 100644 --- a/test/test.js +++ b/test/test.js @@ -640,8 +640,8 @@ QUnit.test('Right to left', function (assert) { var menu = $(MonthPicker_RTLField); - var nextYearButton = menu.find('.next-year>a'); - var previousYearButton = menu.find('.previous-year>a'); + var nextYearButton = menu.find('.next-year .ui-button'); + var previousYearButton = menu.find('.previous-year .ui-button'); // Make sure the buttons are pointing in the right (opposite) direction. assert.ok(previousYearButton.find('span.ui-icon-circle-triangle-e').length, 'Previous button is pointed east'); @@ -651,6 +651,9 @@ QUnit.test('Right to left', function (assert) { var opendToTheRight = (field.position().left - menu.position().left) > 5; assert.ok(opendToTheRight, 'The menu opened to the right of the field'); + assert.equal(nextYearButton.css('float'), 'left', 'The next year button has the expected alignment for RTL documents'); + assert.equal(previousYearButton.css('float'), 'right', 'The previous year button has the expected alignment for RTL documents'); + field.MonthPicker('Close'); }); From 116d71dedbbc8ae458e9d89da34b817cd228eed3 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 10:46:25 +0200 Subject: [PATCH 33/48] Makes the month buttons margin use em instead of px --- MonthPicker.js | 4 ++-- MonthPicker.min.js | 2 +- css/MonthPicker.css | 2 +- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.css | 5 ++--- test/test.html | 2 ++ test/test.js | 20 +++++++++++++++++++- 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index b552634..8bf247d 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -664,7 +664,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _btnOpt = _opts.ShowIcon ? _opts.Button : false; if ($.isFunction(_btnOpt)) { - _btnOpt = _btnOpt.call(_elem[0], $.extend(true, {i18n: $.MonthPicker.i18n}, this.options)); + var _params = $.extend(true, {i18n: $.extend(true, $.MonthPicker.i18n)}, this.options); + _btnOpt = _btnOpt.call(_elem[0], _params); } var _removeOldBtn = false; @@ -865,7 +866,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _event('OnAfterChooseYears', this)(); } else { - //this._jumpYearsButton/*.addClass('ui-state-hover')*/.button({label: 'Year ' + this._getPickerYear()}); this._setPickerYear(this._backToYear); this._applyFadeShowYears(); this._showMonths(); diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 6fb9676..ce33630 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[J]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}var p="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(p+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x=p+"The jQuery UI position plug-in must be loaded.",y=p+"Unsupported % option value, supported values are: ",z=p+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+r;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ',J=d();a.widget("KidSysco."+J,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),A===this&&(A=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=p+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(p+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)).find("a")[J](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[J]({text:!1}),this._nextButton=a(".next-year a",i)[J]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var q=n%3?q:a("").appendTo(m);q.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+r+this.uuid,F(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+r+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+r,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+r+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+r+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=H+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:B?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[J]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(r+"-j"),this._jumpYearsButton[J]({label:this._i18n("backTo")+" "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(H).on(H,F(this._addToYears,this,-g))[J]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(H).on(H,F(this._addToYears,this,g))[J]("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(H,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[J]("option","disabled",g&&b==f(g)),this._nextButton[J]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 2fde3af..3880dd5 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -113,7 +113,7 @@ in response to the slightly bigger buttons in the Jump years menu. */ .month-picker-month-table button { width: 4.3em; - margin: 3px; + margin: .2em; } .month-picker-open-button { diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 310f347..29429c9 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .previous-year>a{float:left}.month-picker-year-table .next-year>a{float:right}.month-picker-year-table .jump-years a.ui-button{width:100%}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:3px}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .jump-years a.ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index ee1ebca..ce535f9 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(t)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(t,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(w+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var p=a.fx.speeds,q=".MonthPicker",r="month-picker-disabled",s="ui-state-highlight",t="ui-state-active",u={my:"left top+1",at:"left bottom"},v={my:"right top+1",at:"right bottom"},w="MonthPicker Error: ",x=w+"The jQuery UI position plug-in must be loaded.",y=w+"Unsupported % option value, supported values are: ",z=w+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+q;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next5Years:"Jump Forward 5 Years",prev5Years:"Jump Back 5 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(q),a(c).off(q+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove()},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=w+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(w+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body);var l=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this));this._jumpYearsButton=l.find("a").css({cursor:"default",fontWeight:"bold"}).jqueryUIButton().removeClass("ui-state-default"),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i),this._prevButton.jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass("ui-state-default").css("cursor","default"),this._setRTL(e.IsRTL);var m=".ui-button-icon-primary";a(m,this._nextButton).text(this._i18n("nextLabel")),a(m,this._prevButton).text(this._i18n("prevLabel"));for(var n=a(".month-picker-month-table",i),p=0;12>p;p++){var q=p%3?q:a("").appendTo(n);q.append('')}this._buttons=a("button",n).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+q+this.uuid,F(this._keyDown,this)),d.off("blur"+q).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+q+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+q,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+q+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+q+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(q),f=d.ShowIcon?d.Button:!1;a.isFunction(f)&&(f=f.call(b[0],a.extend(!0,{i18n:a.MonthPicker.i18n},this.options)));var g=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(g=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=g}},_updateFieldEvents:function(){var a=H+" focus"+q;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+q,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton,!a),n(this._nextButton,a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in p?p[b]:p._default},_position:B?function(b){var c=this.options.IsRTL?v:u,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(r,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),this._jumpYearsButton.jqueryUIButton({label:"Year "+c}),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(s),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(q);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(s),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(q+"-j"),this._jumpYearsButton.jqueryUIButton({label:"Back to "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev5Years")).off(H).on(H,F(this._addToYears,this,-g)).jqueryUIButton("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next5Years")).off(H).on(H,F(this._addToYears,this,g)).jqueryUIButton("option","disabled",n&&e+12-1>n),this._buttons.off(q),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),r=i(j,m,n),t=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(s,v===j&&r).on(H,{year:v},p);t&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton.jqueryUIButton("option","disabled",g&&b==f(g)),this._nextButton.jqueryUIButton("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(s,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[J]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}var p="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(p+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x=p+"The jQuery UI position plug-in must be loaded.",y=p+"Unsupported % option value, supported values are: ",z=p+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+r;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ',J=d();a.widget("KidSysco."+J,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),A===this&&(A=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=p+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(p+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)).find("a")[J](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[J]({text:!1}),this._nextButton=a(".next-year a",i)[J]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var q=n%3?q:a("").appendTo(m);q.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+r+this.uuid,F(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+r+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+r,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+r+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+r+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=H+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:B?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[J]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(r+"-j"),this._jumpYearsButton[J]({label:this._i18n("backTo")+" "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(H).on(H,F(this._addToYears,this,-g))[J]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(H).on(H,F(this._addToYears,this,g))[J]("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(H,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[J]("option","disabled",g&&b==f(g)),this._nextButton[J]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.css b/test/test.css index 62121e2..d6bd559 100644 --- a/test/test.css +++ b/test/test.css @@ -30,7 +30,7 @@ .option-type { margin: 0 25px; } -.demo { +.demo { background-color: #e1e1e1; padding: 8px; border: solid 1px Gray; @@ -43,6 +43,5 @@ width:100%; } .text-right{ - text-align: right; + text-align: right; } - diff --git a/test/test.html b/test/test.html index 505504c..08cb43f 100644 --- a/test/test.html +++ b/test/test.html @@ -3,6 +3,8 @@ jQuery UI Month Picker tests + + diff --git a/test/test.js b/test/test.js index a2c09c9..b15647f 100644 --- a/test/test.js +++ b/test/test.js @@ -398,6 +398,11 @@ QUnit.test('Inline menu', function(assert) { }); var menu = $(MonthPicker_InlineMenuDiv); + var nextYearButton = menu.find('.next-year .ui-button'); + var previousYearButton = menu.find('.previous-year .ui-button'); + + assert.equal(nextYearButton.css('float'), 'right', 'The next year button has the expected alignment for RTL documents'); + assert.equal(previousYearButton.css('float'), 'left', 'The previous year button has the expected alignment for RTL documents'); assert.ok(menu.width() <= 200, 'The menu is visible and has the expected width'); @@ -633,7 +638,20 @@ QUnit.test('Right to left', function (assert) { var field = $(RTLField).MonthPicker({ Animation: 'none', // Disable animation to make sure opening and closing the menu is synchronous. Position: {collision: 'none'}, // Ensure the menu opens to the right. - IsRTL: true + IsRTL: true, + i18n: { + year: 'שנת', + buttonText: 'פתח תפריט', + prevYear: "שנה קודמת", + nextYear: "שנה הבאה", + next12Years: 'עבור 12 שנים קדימה', + prev12Years: 'עבור 12 שנים אחורה', + nextLabel: "הבא", + prevLabel: "הקודם", + jumpYears: "בכר שנה", + backTo: "חזור ל", + months: ["ינו'", "פבר'", "מרץ", "אפר'", "מאי", "יוני", "יולי", "אוג'", "ספט'", "אוק'", "נוב'", "דצמ'"] + } }); field.MonthPicker('Open'); From 7a7bd71545bdd086af2829ca8b31e4efae23a3ae Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 13:55:40 +0200 Subject: [PATCH 34/48] Adds the _applyButtonHint function --- MonthPicker.js | 90 ++++++++++++++++++++++++---------------------- MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 8bf247d..d90330c 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -33,6 +33,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _speeds = $.fx.speeds; var _eventsNs = '.MonthPicker'; + var _clearHint = 'month-picker-clear-hint'; var _disabledClass = 'month-picker-disabled'; var _todayClass = 'ui-state-highlight'; var _selectedClass = 'ui-state-active'; @@ -205,6 +206,46 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } }); + function _applyButtonHint(_button, _hintLabel) { + var _speed = 125, _currentLabel, _startTimeout, _labelElem = $(); + + function _fadeInHint() { + _currentLabel = _labelElem.text(); + _labelElem.animate({ opacity: 1 }, _speed).text(_hintLabel); + } + + function _fadeOutLabel() { + _startTimeout = null; + _labelElem = $("span", _button).animate({ opacity: 0.45 }, _speed, _fadeInHint); + } + + function _prepareToStart() { + _startTimeout = setTimeout(_fadeOutLabel, 175); + } + + function _fadeInLabel() { + _labelElem.text( _currentLabel ).animate({opacity: 1}, _speed); + } + + function _fadeOutHint() { + if (_startTimeout) { + clearTimeout(_startTimeout); + } else { + _labelElem = $("span", _button).animate({ opacity: 0.45 }, _speed, _fadeInLabel); + } + } + + _button.data(_clearHint, function() { + clearTimeout(_startTimeout); + _labelElem.stop().css({ opacity: 1 }); + _button.off(_eventsNs + 'h'); + }); + + _button + .on('mouseenter' + _eventsNs + 'h', _prepareToStart) + .on('mouseleave' + _eventsNs + 'h', _fadeOutHint); + } + $.widget("KidSysco.MonthPicker", { /******* Properties *******/ @@ -353,7 +394,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .click($proxy(this._showYearsClickHandler, this)) .find('a')[ _headerButton ](); - this._applyFadeShowYears(); + this._applyJumpYearsHint(); this._createValidationMessage(); this._prevButton = $('.previous-year a', _menu)[ _headerButton ]({ text: false }); @@ -586,41 +627,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._showMonths(); }, - _applyFadeShowYears: function(jumpYears) { - var speed = 125; - var _prevText; - var that = this; - - this._jumpYearsButton.on('mouseenter' + _eventsNs + '-j', function(e) { - var me = this; - that.tOut = setTimeout(function() { - that.tOut = null; - - $("span", me).animate({ opacity: 0.45 }, { - duration: speed, - complete: function() { - if (!that._backToYear) { - _prevText=$("span", me).text(); - $("span", me).animate({opacity: 1}, speed).text(that._i18n('jumpYears')); - } - } - - }); - }, 175); - }).on('mouseleave' + _eventsNs + '-j', function(e) { - if (that.tOut) { - return clearTimeout(that.tOut); - } else { - var me = this; - - $("span", me).animate({ opacity: 0.45 },{ - duration: speed, - complete: function() { - $("span", me).text(_prevText).animate({opacity: 1}, speed); - } - }); - } - }); + _applyJumpYearsHint: function() { + _applyButtonHint(this._jumpYearsButton, this._i18n('jumpYears')); }, _i18n: function(str) { @@ -855,19 +863,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._showYears(); if (!this._backToYear) { - clearTimeout(this.tOut); - this._jumpYearsButton.off(_eventsNs + '-j'); - this._jumpYearsButton[ _headerButton ]({ - label: this._i18n('backTo') + ' ' + this._getPickerYear() - }); - this._jumpYearsButton.find('span').stop().css({ opacity: 1 }); + var _label = this._i18n('backTo') + ' ' + this._getPickerYear(); + this._jumpYearsButton[ _headerButton ]({ label: _label }).data( _clearHint )(); this._backToYear = this._getPickerYear(); _event('OnAfterChooseYears', this)(); } else { this._setPickerYear(this._backToYear); - this._applyFadeShowYears(); + this._applyJumpYearsHint(); this._showMonths(); this._backToYear = 0; } diff --git a/MonthPicker.min.js b/MonthPicker.min.js index ce33630..ac81c8c 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[J]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}var p="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(p+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x=p+"The jQuery UI position plug-in must be loaded.",y=p+"Unsupported % option value, supported values are: ",z=p+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+r;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ',J=d();a.widget("KidSysco."+J,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),A===this&&(A=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=p+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(p+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)).find("a")[J](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[J]({text:!1}),this._nextButton=a(".next-year a",i)[J]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var q=n%3?q:a("").appendTo(m);q.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+r+this.uuid,F(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+r+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+r,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+r+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+r+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=H+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:B?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[J]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(r+"-j"),this._jumpYearsButton[J]({label:this._i18n("backTo")+" "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(H).on(H,F(this._addToYears,this,-g))[J]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(H).on(H,F(this._addToYears,this,g))[J]("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(H,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[J]("option","disabled",g&&b==f(g)),this._nextButton[J]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(w)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(w,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return H(b.options[a]||G,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[L]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(t,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(s+"h")}),b.on("mouseenter"+s+"h",f).on("mouseleave"+s+"h",h)}var q="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(q+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var r=a.fx.speeds,s=".MonthPicker",t="month-picker-clear-hint",u="month-picker-disabled",v="ui-state-highlight",w="ui-state-active",x={my:"left top+1",at:"left bottom"},y={my:"right top+1",at:"right bottom"},z=q+"The jQuery UI position plug-in must be loaded.",A=q+"Unsupported % option value, supported values are: ",B=q+'"_" is not a valid %Month value.',C=null,D=!!a.ui.position,E={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},F={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},G=a.noop,H=a.proxy,I=a.datepicker,J="click"+s;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var K='
    ',L=d();a.widget("KidSysco."+L,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(s),a(c).off(s+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(J);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),C===this&&(C=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!D)return void alert(z);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in E&&-1===a.inArray(c,E[b])?void alert(A.replace(/%/,b)+E[b]):(this._super(b,c),void(F[b]?this[F[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=q+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(q+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!D)return alert(z),!1;for(var h in E)if(null!==e[h]&&-1===a.inArray(e[h],E[h]))return alert(A.replace(/%/,h)+E[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(K).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(H(this._showYearsClickHandler,this)).find("a")[L](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[L]({text:!1}),this._nextButton=a(".next-year a",i)[L]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(J,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(B.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(H(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=G)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{C&&C.Close(b),C=this,a(c).on(J+this.uuid,H(this.Close,this)).on("keydown"+s+this.uuid,H(this._keyDown,this)),d.off("blur"+s).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:H(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,C=null,a(c).off("keydown"+s+this.uuid).off(J+this.uuid),this.Validate(),d.on("blur"+s,H(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return I.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return I.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(s),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(J,H(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=J+" focus"+s;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,H(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+s,H(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in r?r[b]:r._default},_position:D?function(b){var c=this.options.IsRTL?y:x,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(u,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[L]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(v),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(J).on(J,H(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(J).on(J,H(this._addToYear,this,1)),this._buttons.off(s);var c=this,d=H(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(J,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(v),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton[L]({label:a}).data(t)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(J).on(J,H(this._addToYears,this,-g))[L]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(J).on(J,H(this._addToYears,this,g))[L]("option","disabled",n&&e+12-1>n),this._buttons.off(s),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=H(this._onYearClick,this),q=i(j,m,n),r=i(o,m,n),t=0;12>t;t++){var u=b+c,w=a(this._buttons[t]).jqueryUIButton({disabled:!i(u,m,n),label:u}).toggleClass(v,u===j&&q).on(J,{year:u},p);r&&o&&o===u&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[L]("option","disabled",g&&b==f(g)),this._nextButton[L]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(v,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index ce535f9..8661f90 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(u)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(u,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return F(b.options[a]||E,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[J]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}var p="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(p+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var q=a.fx.speeds,r=".MonthPicker",s="month-picker-disabled",t="ui-state-highlight",u="ui-state-active",v={my:"left top+1",at:"left bottom"},w={my:"right top+1",at:"right bottom"},x=p+"The jQuery UI position plug-in must be loaded.",y=p+"Unsupported % option value, supported values are: ",z=p+'"_" is not a valid %Month value.',A=null,B=!!a.ui.position,C={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},D={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},E=a.noop,F=a.proxy,G=a.datepicker,H="click"+r;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var I='
    ',J=d();a.widget("KidSysco."+J,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(r),a(c).off(r+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(H);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),A===this&&(A=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!B)return void alert(x);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in C&&-1===a.inArray(c,C[b])?void alert(y.replace(/%/,b)+C[b]):(this._super(b,c),void(D[b]?this[D[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=p+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(p+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!B)return alert(x),!1;for(var h in C)if(null!==e[h]&&-1===a.inArray(e[h],C[h]))return alert(y.replace(/%/,h)+C[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(I).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(F(this._showYearsClickHandler,this)).find("a")[J](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[J]({text:!1}),this._nextButton=a(".next-year a",i)[J]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var q=n%3?q:a("").appendTo(m);q.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(H,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(z.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(F(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=E)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{A&&A.Close(b),A=this,a(c).on(H+this.uuid,F(this.Close,this)).on("keydown"+r+this.uuid,F(this._keyDown,this)),d.off("blur"+r).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:F(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,A=null,a(c).off("keydown"+r+this.uuid).off(H+this.uuid),this.Validate(),d.on("blur"+r,F(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return G.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return G.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(b){var c,d=125,e=this;this._jumpYearsButton.on("mouseenter"+r+"-j",function(b){var f=this;e.tOut=setTimeout(function(){e.tOut=null,a("span",f).animate({opacity:.45},{duration:d,complete:function(){e._backToYear||(c=a("span",f).text(),a("span",f).animate({opacity:1},d).text(e._i18n("jumpYears")))}})},175)}).on("mouseleave"+r+"-j",function(b){if(e.tOut)return clearTimeout(e.tOut);var f=this;a("span",f).animate({opacity:.45},{duration:d,complete:function(){a("span",f).text(c).animate({opacity:1},d)}})})},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(r),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(H,F(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=H+" focus"+r;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,F(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+r,F(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in q?q[b]:q._default},_position:B?function(b){var c=this.options.IsRTL?w:v,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(s,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[J]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(t),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(H).on(H,F(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(H).on(H,F(this._addToYear,this,1)),this._buttons.off(r);var c=this,d=F(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(H,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){this._buttons.removeClass(t),this._showYears(),this._backToYear?(this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0):(clearTimeout(this.tOut),this._jumpYearsButton.off(r+"-j"),this._jumpYearsButton[J]({label:this._i18n("backTo")+" "+this._getPickerYear()}),this._jumpYearsButton.find("span").stop().css({opacity:1}),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)())},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(H).on(H,F(this._addToYears,this,-g))[J]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(H).on(H,F(this._addToYears,this,g))[J]("option","disabled",n&&e+12-1>n),this._buttons.off(r),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=F(this._onYearClick,this),q=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(t,v===j&&q).on(H,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[J]("option","disabled",g&&b==f(g)),this._nextButton[J]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(t,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(w)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(w,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return H(b.options[a]||G,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[L]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(t,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(s+"h")}),b.on("mouseenter"+s+"h",f).on("mouseleave"+s+"h",h)}var q="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(q+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var r=a.fx.speeds,s=".MonthPicker",t="month-picker-clear-hint",u="month-picker-disabled",v="ui-state-highlight",w="ui-state-active",x={my:"left top+1",at:"left bottom"},y={my:"right top+1",at:"right bottom"},z=q+"The jQuery UI position plug-in must be loaded.",A=q+"Unsupported % option value, supported values are: ",B=q+'"_" is not a valid %Month value.',C=null,D=!!a.ui.position,E={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},F={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},G=a.noop,H=a.proxy,I=a.datepicker,J="click"+s;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var K='
    ',L=d();a.widget("KidSysco."+L,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(s),a(c).off(s+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(J);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),C===this&&(C=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!D)return void alert(z);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in E&&-1===a.inArray(c,E[b])?void alert(A.replace(/%/,b)+E[b]):(this._super(b,c),void(F[b]?this[F[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=q+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(q+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!D)return alert(z),!1;for(var h in E)if(null!==e[h]&&-1===a.inArray(e[h],E[h]))return alert(A.replace(/%/,h)+E[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(K).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(H(this._showYearsClickHandler,this)).find("a")[L](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[L]({text:!1}),this._nextButton=a(".next-year a",i)[L]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(J,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(B.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(H(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=G)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{C&&C.Close(b),C=this,a(c).on(J+this.uuid,H(this.Close,this)).on("keydown"+s+this.uuid,H(this._keyDown,this)),d.off("blur"+s).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:H(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,C=null,a(c).off("keydown"+s+this.uuid).off(J+this.uuid),this.Validate(),d.on("blur"+s,H(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return I.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return I.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(s),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(J,H(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=J+" focus"+s;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,H(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+s,H(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in r?r[b]:r._default},_position:D?function(b){var c=this.options.IsRTL?y:x,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(u,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[L]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(v),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(J).on(J,H(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(J).on(J,H(this._addToYear,this,1)),this._buttons.off(s);var c=this,d=H(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(J,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(v),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton[L]({label:a}).data(t)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(J).on(J,H(this._addToYears,this,-g))[L]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(J).on(J,H(this._addToYears,this,g))[L]("option","disabled",n&&e+12-1>n),this._buttons.off(s),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=H(this._onYearClick,this),q=i(j,m,n),r=i(o,m,n),t=0;12>t;t++){var u=b+c,w=a(this._buttons[t]).jqueryUIButton({disabled:!i(u,m,n),label:u}).toggleClass(v,u===j&&q).on(J,{year:u},p);r&&o&&o===u&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[L]("option","disabled",g&&b==f(g)),this._nextButton[L]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(v,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From af6dee740c60c4609ec97b1a9f66c1c70850b12c Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 14:41:03 +0200 Subject: [PATCH 35/48] Removes _headerButton --- MonthPicker.js | 63 ++++++++++++++++++++++------------------------ MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index d90330c..4c3c6cc 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -34,9 +34,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _speeds = $.fx.speeds; var _eventsNs = '.MonthPicker'; var _clearHint = 'month-picker-clear-hint'; + var _iconClass = '.ui-button-icon-primary'; var _disabledClass = 'month-picker-disabled'; var _todayClass = 'ui-state-highlight'; var _selectedClass = 'ui-state-active'; + var _defaultClass = 'ui-state-default'; var _defaultPos = { my: 'left top+1', at: 'left bottom' }; var _RTL_defaultPos = { my: 'right top+1', at: 'right bottom' }; var _posErr = _setupErr + 'The jQuery UI position plug-in must be loaded.'; @@ -147,7 +149,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } function _applyArrowButton($el, dir) { - $el[ _headerButton ]('option', { + $el.jqueryUIButton('option', { icons: { primary: 'ui-icon-circle-triangle-' + (dir ? 'w' : 'e') } @@ -189,23 +191,6 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
    ' + ''; - var _headerButton = Date(); - $.widget("KidSysco." + _headerButton, $.ui.button, { - _create: function() { - this.widgetFullName = 'ui-button'; - this._superApply(arguments); - this.element.removeClass('ui-state-default'); - }, - - _setOption: function(key, value) { - if (key === 'disabled' && this.options[key] === value) { - return; - } - - this._super(key, value); - } - }); - function _applyButtonHint(_button, _hintLabel) { var _speed = 125, _currentLabel, _startTimeout, _labelElem = $(); @@ -246,6 +231,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. .on('mouseleave' + _eventsNs + 'h', _fadeOutHint); } + function _setDisabled(_button, _value) { + var _btnWidget = _button.data('ui-button'); + if (_btnWidget.option('disabled') !== _value) { + _btnWidget.option('disabled', _value); + } + } + $.widget("KidSysco.MonthPicker", { /******* Properties *******/ @@ -272,9 +264,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _monthPickerButton: $(), - _validationMessage: $(), - _selectedBtn: $(), /******* jQuery UI Widget Factory Overrides ********/ @@ -318,6 +308,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. alert(_posErr); return; } + break; case 'MonthFormat': var date = this.GetSelectedDate(); if (date) { @@ -386,23 +377,28 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var isInline = _isInline(_el); $(_markup).appendTo(_menu); - (_menu).appendTo( isInline ? _el : document.body ); + _menu.appendTo( isInline ? _el : document.body ); this._jumpYearsButton = $('.jump-years', _menu) .attr('title', this._i18n('jumpYears')) .click($proxy(this._showYearsClickHandler, this)) - .find('a')[ _headerButton ](); + .find('a').jqueryUIButton() + .removeClass(_defaultClass); this._applyJumpYearsHint(); this._createValidationMessage(); - this._prevButton = $('.previous-year a', _menu)[ _headerButton ]({ text: false }); - this._nextButton = $('.next-year a', _menu)[ _headerButton ]({ text: false }); + this._prevButton = $('.previous-year a', _menu) + .jqueryUIButton({ text: false }) + .removeClass(_defaultClass); + + this._nextButton = $('.next-year a', _menu) + .jqueryUIButton({ text: false }) + .removeClass(_defaultClass); this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. - var _iconClass = '.ui-button-icon-primary'; $(_iconClass, this._nextButton).text(this._i18n('nextLabel')); $(_iconClass, this._prevButton).text(this._i18n('prevLabel')); @@ -801,7 +797,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); - this._jumpYearsButton[ _headerButton ]({ label: this._i18n('year') + ' ' + this._pickerYear }); + this._jumpYearsButton.jqueryUIButton({ label: this._i18n('year') + ' ' + this._pickerYear }); }, _updateAlt: function (noop, date) { @@ -864,7 +860,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (!this._backToYear) { var _label = this._i18n('backTo') + ' ' + this._getPickerYear(); - this._jumpYearsButton[ _headerButton ]({ label: _label }).data( _clearHint )(); + this._jumpYearsButton.jqueryUIButton({ label: _label }).data( _clearHint )(); this._backToYear = this._getPickerYear(); @@ -891,14 +887,15 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._prevButton .attr('title', this._i18n('prev12Years')) .off(click) - .on(click, $proxy(this._addToYears, this, -AMOUNT_TO_ADD)) - [ _headerButton ]('option', 'disabled', _minYear && (_firstYear - 1) < _minYear); + .on(click, $proxy(this._addToYears, this, -AMOUNT_TO_ADD)); this._nextButton .attr('title', this._i18n('next12Years')) .off(click) - .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)) - [ _headerButton ]('option', 'disabled', _maxYear && (_firstYear + 12) -1 > _maxYear); + .on(click, $proxy(this._addToYears, this, AMOUNT_TO_ADD)); + + _setDisabled(this._prevButton, _minYear && (_firstYear - 1) < _minYear); + _setDisabled(this._nextButton, _maxYear && (_firstYear + 12) -1 > _maxYear); this._buttons.off(_eventsNs); @@ -979,8 +976,8 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } // Disable the next/prev button if we've reached the min/max year. - this._prevButton[ _headerButton ]('option', 'disabled', _minDate && _curYear == _toYear(_minDate)); - this._nextButton[ _headerButton ]('option', 'disabled', _maxDate && _curYear == _toYear(_maxDate)); + _setDisabled(this._prevButton, _minDate && _curYear == _toYear(_minDate)); + _setDisabled(this._nextButton, _maxDate && _curYear == _toYear(_maxDate)); for (var i = 0; i < 12; i++) { // Disable the button if the month is not between the diff --git a/MonthPicker.min.js b/MonthPicker.min.js index ac81c8c..09b35e6 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(w)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(w,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return H(b.options[a]||G,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[L]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(t,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(s+"h")}),b.on("mouseenter"+s+"h",f).on("mouseleave"+s+"h",h)}var q="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(q+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var r=a.fx.speeds,s=".MonthPicker",t="month-picker-clear-hint",u="month-picker-disabled",v="ui-state-highlight",w="ui-state-active",x={my:"left top+1",at:"left bottom"},y={my:"right top+1",at:"right bottom"},z=q+"The jQuery UI position plug-in must be loaded.",A=q+"Unsupported % option value, supported values are: ",B=q+'"_" is not a valid %Month value.',C=null,D=!!a.ui.position,E={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},F={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},G=a.noop,H=a.proxy,I=a.datepicker,J="click"+s;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var K='
    ',L=d();a.widget("KidSysco."+L,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(s),a(c).off(s+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(J);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),C===this&&(C=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!D)return void alert(z);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in E&&-1===a.inArray(c,E[b])?void alert(A.replace(/%/,b)+E[b]):(this._super(b,c),void(F[b]?this[F[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=q+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(q+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!D)return alert(z),!1;for(var h in E)if(null!==e[h]&&-1===a.inArray(e[h],E[h]))return alert(A.replace(/%/,h)+E[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(K).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(H(this._showYearsClickHandler,this)).find("a")[L](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[L]({text:!1}),this._nextButton=a(".next-year a",i)[L]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(J,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(B.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(H(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=G)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{C&&C.Close(b),C=this,a(c).on(J+this.uuid,H(this.Close,this)).on("keydown"+s+this.uuid,H(this._keyDown,this)),d.off("blur"+s).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:H(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,C=null,a(c).off("keydown"+s+this.uuid).off(J+this.uuid),this.Validate(),d.on("blur"+s,H(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return I.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return I.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(s),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(J,H(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=J+" focus"+s;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,H(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+s,H(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in r?r[b]:r._default},_position:D?function(b){var c=this.options.IsRTL?y:x,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(u,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[L]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(v),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(J).on(J,H(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(J).on(J,H(this._addToYear,this,1)),this._buttons.off(s);var c=this,d=H(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(J,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(v),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton[L]({label:a}).data(t)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(J).on(J,H(this._addToYears,this,-g))[L]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(J).on(J,H(this._addToYears,this,g))[L]("option","disabled",n&&e+12-1>n),this._buttons.off(s),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=H(this._onYearClick,this),q=i(j,m,n),r=i(o,m,n),t=0;12>t;t++){var u=b+c,w=a(this._buttons[t]).jqueryUIButton({disabled:!i(u,m,n),label:u}).toggleClass(v,u===j&&q).on(J,{year:u},p);r&&o&&o===u&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[L]("option","disabled",g&&b==f(g)),this._nextButton[L]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(v,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(y)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(y,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return K(b.options[a]||J,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(u,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-picker-clear-hint",v=".ui-button-icon-primary",w="month-picker-disabled",x="ui-state-highlight",y="ui-state-active",z="ui-state-default",A={my:"left top+1",at:"left bottom"},B={my:"right top+1",at:"right bottom"},C=r+"The jQuery UI position plug-in must be loaded.",D=r+"Unsupported % option value, supported values are: ",E=r+'"_" is not a valid %Month value.',F=null,G=!!a.ui.position,H={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},I={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},J=a.noop,K=a.proxy,L=a.datepicker,M="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var N='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(M);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),F===this&&(F=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!G)return void alert(C);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in H&&-1===a.inArray(c,H[b])?void alert(D.replace(/%/,b)+H[b]):(this._super(b,c),void(I[b]?this[I[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!G)return alert(C),!1;for(var h in H)if(null!==e[h]&&-1===a.inArray(e[h],H[h]))return alert(D.replace(/%/,h)+H[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(N).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(K(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(z),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._setRTL(e.IsRTL),a(v,this._nextButton).text(this._i18n("nextLabel")),a(v,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(M,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(E.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(K(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=J)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{F&&F.Close(b),F=this,a(c).on(M+this.uuid,K(this.Close,this)).on("keydown"+t+this.uuid,K(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:K(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,F=null,a(c).off("keydown"+t+this.uuid).off(M+this.uuid),this.Validate(),d.on("blur"+t,K(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return L.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return L.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(M,K(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=M+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,K(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,K(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:G?function(b){var c=this.options.IsRTL?B:A,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){this._isMonthInputType||(this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask())},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(w,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(x),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(M).on(M,K(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(M).on(M,K(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=K(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(M,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(x),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(u)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(M).on(M,K(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(M).on(M,K(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=K(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(x,v===j&&r).on(M,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(x,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 8661f90..d3abf09 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(w)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(w,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return H(b.options[a]||G,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a[L]("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(t,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(s+"h")}),b.on("mouseenter"+s+"h",f).on("mouseleave"+s+"h",h)}var q="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(q+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var r=a.fx.speeds,s=".MonthPicker",t="month-picker-clear-hint",u="month-picker-disabled",v="ui-state-highlight",w="ui-state-active",x={my:"left top+1",at:"left bottom"},y={my:"right top+1",at:"right bottom"},z=q+"The jQuery UI position plug-in must be loaded.",A=q+"Unsupported % option value, supported values are: ",B=q+'"_" is not a valid %Month value.',C=null,D=!!a.ui.position,E={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},F={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},G=a.noop,H=a.proxy,I=a.datepicker,J="click"+s;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var K='
    ',L=d();a.widget("KidSysco."+L,a.ui.button,{_create:function(){this.widgetFullName="ui-button",this._superApply(arguments),this.element.removeClass("ui-state-default")},_setOption:function(a,b){("disabled"!==a||this.options[a]!==b)&&this._super(a,b)}}),a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(s),a(c).off(s+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(J);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),C===this&&(C=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!D)return void alert(z);case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in E&&-1===a.inArray(c,E[b])?void alert(A.replace(/%/,b)+E[b]):(this._super(b,c),void(F[b]?this[F[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=q+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(q+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!D)return alert(z),!1;for(var h in E)if(null!==e[h]&&-1===a.inArray(e[h],E[h]))return alert(A.replace(/%/,h)+E[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(K).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(H(this._showYearsClickHandler,this)).find("a")[L](),this._applyFadeShowYears(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i)[L]({text:!1}),this._nextButton=a(".next-year a",i)[L]({text:!1}),this._setRTL(e.IsRTL);var l=".ui-button-icon-primary";a(l,this._nextButton).text(this._i18n("nextLabel")),a(l,this._prevButton).text(this._i18n("prevLabel"));for(var m=a(".month-picker-month-table",i),n=0;12>n;n++){var p=n%3?p:a("").appendTo(m);p.append('')}this._buttons=a("button",m).jqueryUIButton(),i.on(J,function(a){return!1});var r=this,s="Month";a.each(["Min","Max"],function(a,b){r["_set"+b+s]=function(a){(r["_"+b+s]=j(r,a))===!1&&alert(B.replace(/%/,b).replace(/_/,a))},r._setOption(b+s,r.options[b+s])});var t=e.SelectedMonth;if(void 0!==t){var u=j(this,t);b.val(this._formatMonth(new d(f(u),u%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(H(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=G)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{C&&C.Close(b),C=this,a(c).on(J+this.uuid,H(this.Close,this)).on("keydown"+s+this.uuid,H(this._keyDown,this)),d.off("blur"+s).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:H(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,C=null,a(c).off("keydown"+s+this.uuid).off(J+this.uuid),this.Validate(),d.on("blur"+s,H(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return I.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return I.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyFadeShowYears:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(s),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(J,H(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=J+" focus"+s;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,H(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+s,H(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in r?r[b]:r._default},_position:D?function(b){var c=this.options.IsRTL?y:x,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(u,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton[L]({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(v),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(J).on(J,H(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(J).on(J,H(this._addToYear,this,1)),this._buttons.off(s);var c=this,d=H(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(J,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(v),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyFadeShowYears(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton[L]({label:a}).data(t)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(J).on(J,H(this._addToYears,this,-g))[L]("option","disabled",m&&m>e-1),this._nextButton.attr("title",this._i18n("next12Years")).off(J).on(J,H(this._addToYears,this,g))[L]("option","disabled",n&&e+12-1>n),this._buttons.off(s),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=H(this._onYearClick,this),q=i(j,m,n),r=i(o,m,n),t=0;12>t;t++){var u=b+c,w=a(this._buttons[t]).jqueryUIButton({disabled:!i(u,m,n),label:u}).toggleClass(v,u===j&&q).on(J,{year:u},p);r&&o&&o===u&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),this._prevButton[L]("option","disabled",g&&b==f(g)),this._nextButton[L]("option","disabled",j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(v,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(y)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(y,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return K(b.options[a]||J,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(u,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-picker-clear-hint",v=".ui-button-icon-primary",w="month-picker-disabled",x="ui-state-highlight",y="ui-state-active",z="ui-state-default",A={my:"left top+1",at:"left bottom"},B={my:"right top+1",at:"right bottom"},C=r+"The jQuery UI position plug-in must be loaded.",D=r+"Unsupported % option value, supported values are: ",E=r+'"_" is not a valid %Month value.',F=null,G=!!a.ui.position,H={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},I={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},J=a.noop,K=a.proxy,L=a.datepicker,M="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var N='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(M);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),F===this&&(F=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!G)return void alert(C);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in H&&-1===a.inArray(c,H[b])?void alert(D.replace(/%/,b)+H[b]):(this._super(b,c),void(I[b]?this[I[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!G)return alert(C),!1;for(var h in H)if(null!==e[h]&&-1===a.inArray(e[h],H[h]))return alert(D.replace(/%/,h)+H[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(N).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(K(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(z),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._setRTL(e.IsRTL),a(v,this._nextButton).text(this._i18n("nextLabel")),a(v,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(M,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(E.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(K(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=J)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{F&&F.Close(b),F=this,a(c).on(M+this.uuid,K(this.Close,this)).on("keydown"+t+this.uuid,K(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:K(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,F=null,a(c).off("keydown"+t+this.uuid).off(M+this.uuid),this.Validate(),d.on("blur"+t,K(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return L.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return L.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(M,K(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=M+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,K(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,K(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:G?function(b){var c=this.options.IsRTL?B:A,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){this._isMonthInputType||(this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask())},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(w,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(x),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(M).on(M,K(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(M).on(M,K(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=K(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(M,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(x),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(u)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(M).on(M,K(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(M).on(M,K(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=K(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(x,v===j&&r).on(M,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(x,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From b182dbf7b541476a78c9cb63b0a626e3d9e39333 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 15:30:13 +0200 Subject: [PATCH 36/48] Disables user selection on the year table (header) --- MonthPicker.js | 11 ++++++----- MonthPicker.min.js | 2 +- css/MonthPicker.css | 9 +++++++++ demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 4c3c6cc..83c01dd 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -33,6 +33,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. var _speeds = $.fx.speeds; var _eventsNs = '.MonthPicker'; + var _textfieldClass = 'month-year-input'; var _clearHint = 'month-picker-clear-hint'; var _iconClass = '.ui-button-icon-primary'; var _disabledClass = 'month-picker-disabled'; @@ -201,7 +202,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. function _fadeOutLabel() { _startTimeout = null; - _labelElem = $("span", _button).animate({ opacity: 0.45 }, _speed, _fadeInHint); + _labelElem = $('span', _button).animate({ opacity: 0.45 }, _speed, _fadeInHint); } function _prepareToStart() { @@ -216,7 +217,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. if (_startTimeout) { clearTimeout(_startTimeout); } else { - _labelElem = $("span", _button).animate({ opacity: 0.45 }, _speed, _fadeInLabel); + _labelElem = $('span', _button).animate({ opacity: 0.45 }, _speed, _fadeInLabel); } } @@ -271,7 +272,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _destroy: function () { var _elem = this.element; - if (jQuery.mask && this.options.UseInputMask) { + if ($.mask && this.options.UseInputMask) { _elem.unmask(); if (!this.GetSelectedDate()) { @@ -279,7 +280,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } } - _elem.removeClass('month-year-input').off(_eventsNs); + _elem.removeClass(_textfieldClass).off(_eventsNs); $(document).off(_eventsNs + this.uuid); @@ -444,7 +445,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. } else { // Update the alt field if the user manually changes // the input field. - _el.addClass('month-year-input'); + _el.addClass(_textfieldClass); _el.change($proxy(this._updateAlt, this)); } }, diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 09b35e6..13641f3 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(y)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(y,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return K(b.options[a]||J,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(u,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-picker-clear-hint",v=".ui-button-icon-primary",w="month-picker-disabled",x="ui-state-highlight",y="ui-state-active",z="ui-state-default",A={my:"left top+1",at:"left bottom"},B={my:"right top+1",at:"right bottom"},C=r+"The jQuery UI position plug-in must be loaded.",D=r+"Unsupported % option value, supported values are: ",E=r+'"_" is not a valid %Month value.',F=null,G=!!a.ui.position,H={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},I={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},J=a.noop,K=a.proxy,L=a.datepicker,M="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var N='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(M);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),F===this&&(F=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!G)return void alert(C);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in H&&-1===a.inArray(c,H[b])?void alert(D.replace(/%/,b)+H[b]):(this._super(b,c),void(I[b]?this[I[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!G)return alert(C),!1;for(var h in H)if(null!==e[h]&&-1===a.inArray(e[h],H[h]))return alert(D.replace(/%/,h)+H[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(N).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(K(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(z),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._setRTL(e.IsRTL),a(v,this._nextButton).text(this._i18n("nextLabel")),a(v,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(M,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(E.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(K(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=J)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{F&&F.Close(b),F=this,a(c).on(M+this.uuid,K(this.Close,this)).on("keydown"+t+this.uuid,K(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:K(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,F=null,a(c).off("keydown"+t+this.uuid).off(M+this.uuid),this.Validate(),d.on("blur"+t,K(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return L.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return L.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(M,K(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=M+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,K(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,K(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:G?function(b){var c=this.options.IsRTL?B:A,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){this._isMonthInputType||(this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask())},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(w,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(x),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(M).on(M,K(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(M).on(M,K(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=K(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(M,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(x),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(u)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(M).on(M,K(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(M).on(M,K(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=K(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(x,v===j&&r).on(M,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(x,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/css/MonthPicker.css b/css/MonthPicker.css index 3880dd5..ee9255c 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -45,6 +45,15 @@ See: .month-picker-month-table button { width: 4.3em; } .month-picker-year-table { width: 100%; + /* + Makes sure the next/previous/jump years buttons are not unnecessarily + selected if the user clicks them a couple of times fast. + */ + -ms-user-select: none; /* IE 10+ */ + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + user-select: none; } .month-picker-year-table .jump-years { text-align: center; diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 29429c9..73d1da1 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .jump-years a.ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .jump-years a.ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index d3abf09..9284839 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(y)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(y,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return K(b.options[a]||J,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(u,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-picker-clear-hint",v=".ui-button-icon-primary",w="month-picker-disabled",x="ui-state-highlight",y="ui-state-active",z="ui-state-default",A={my:"left top+1",at:"left bottom"},B={my:"right top+1",at:"right bottom"},C=r+"The jQuery UI position plug-in must be loaded.",D=r+"Unsupported % option value, supported values are: ",E=r+'"_" is not a valid %Month value.',F=null,G=!!a.ui.position,H={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},I={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},J=a.noop,K=a.proxy,L=a.datepicker,M="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var N='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;jQuery.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass("month-year-input").off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(M);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),F===this&&(F=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!G)return void alert(C);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in H&&-1===a.inArray(c,H[b])?void alert(D.replace(/%/,b)+H[b]):(this._super(b,c),void(I[b]?this[I[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!G)return alert(C),!1;for(var h in H)if(null!==e[h]&&-1===a.inArray(e[h],H[h]))return alert(D.replace(/%/,h)+H[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(N).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(K(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(z),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(z),this._setRTL(e.IsRTL),a(v,this._nextButton).text(this._i18n("nextLabel")),a(v,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(M,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(E.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass("month-year-input"),b.change(K(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=J)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{F&&F.Close(b),F=this,a(c).on(M+this.uuid,K(this.Close,this)).on("keydown"+t+this.uuid,K(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:K(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,F=null,a(c).off("keydown"+t+this.uuid).off(M+this.uuid),this.Validate(),d.on("blur"+t,K(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return L.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return L.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(M,K(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=M+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,K(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,K(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:G?function(b){var c=this.options.IsRTL?B:A,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){this._isMonthInputType||(this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask())},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(w,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(x),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(M).on(M,K(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(M).on(M,K(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=K(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(M,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(x),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(u)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(M).on(M,K(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(M).on(M,K(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=K(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(x,v===j&&r).on(M,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(x,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From be0aea48114759cfc37d455b84b93d1eb05b6784 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 16:08:59 +0200 Subject: [PATCH 37/48] Restores the jump years hint if the user closed the menu in jump years mode. --- MonthPicker.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 83c01dd..9c8f981 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -569,6 +569,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. return; } + // If the menu is closed while in jump years mode, bring back + // the jump years hint. + if (this._backToYear) { + this._applyJumpYearsHint(); + this._backToYear = 0; + } + this._visible = false; _openedInstance = null; $(document).off('keydown' + _eventsNs + this.uuid) @@ -857,13 +864,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _showYearsClickHandler: function () { this._buttons.removeClass(_todayClass); - this._showYears(); - if (!this._backToYear) { - var _label = this._i18n('backTo') + ' ' + this._getPickerYear(); - this._jumpYearsButton.jqueryUIButton({ label: _label }).data( _clearHint )(); - this._backToYear = this._getPickerYear(); + this._showYears(); + + var _label = this._i18n('backTo') + ' ' + this._getPickerYear(); + this._jumpYearsButton.jqueryUIButton({ label: _label }).data( _clearHint )(); _event('OnAfterChooseYears', this)(); } else { From 3cbb69fe11baee6ebde3d8bcdaad91df3e61f072 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Thu, 14 Jan 2016 17:23:49 +0200 Subject: [PATCH 38/48] Adds comments to the _applyButtonHint function --- MonthPicker.js | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 9c8f981..ad31392 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -192,44 +192,62 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
    ' + ''; - function _applyButtonHint(_button, _hintLabel) { + // Groups state and functionallity to fade in the jump years hint + // when the user mouses over the Year 2016 text. + // NOTE: An invocation of this function: + // 1: Is an independent instance with it's own unique state. + // 2: Assumes that there is no previous hint applied to the + // button (it dosen't the existing hint). + function _applyButtonHint(_button, _hintText) { var _speed = 125, _currentLabel, _startTimeout, _labelElem = $(); - function _fadeInHint() { - _currentLabel = _labelElem.text(); - _labelElem.animate({ opacity: 1 }, _speed).text(_hintLabel); + _button.on('mouseenter' + _eventsNs + 'h', _prepareToStart); + + // Setp 1: Wait to make sure the user isn't just mousing over and + // away from the button. + // NOTE: If _fadeOutHint() is triggered on mouseleave before the + // timeout is triggered the animation is canceled. + function _prepareToStart() { + _startTimeout = setTimeout(_fadeOutLabel, 175); } + // Setp 2: Fade out the label (Year 2016) text to 45%. function _fadeOutLabel() { _startTimeout = null; _labelElem = $('span', _button).animate({ opacity: 0.45 }, _speed, _fadeInHint); } - function _prepareToStart() { - _startTimeout = setTimeout(_fadeOutLabel, 175); + // Setp 3: Fade in the hint text (Jump years). + function _fadeInHint() { + _currentLabel = _labelElem.text(); + _labelElem.animate({ opacity: 1 }, _speed).text(_hintText); } - function _fadeInLabel() { - _labelElem.text( _currentLabel ).animate({opacity: 1}, _speed); - } + _button.on('mouseleave' + _eventsNs + 'h', _fadeOutHint); function _fadeOutHint() { if (_startTimeout) { + // If the user is just moving over and away from the button, cancel + // the animation completely. clearTimeout(_startTimeout); } else { + // Setp 4: Fade out the hint text (Jump years) to 45%. _labelElem = $('span', _button).animate({ opacity: 0.45 }, _speed, _fadeInLabel); } } + // Setp 5: Fade in the label (Year 2016) text. + function _fadeInLabel() { + _labelElem.text( _currentLabel ).animate({opacity: 1}, _speed); + } + + // Adds a function to the button elemene which is called when the + // user clicks the button (the hint needs to be removed). _button.data(_clearHint, function() { clearTimeout(_startTimeout); _labelElem.stop().css({ opacity: 1 }); _button.off(_eventsNs + 'h'); }); - - _button - .on('mouseenter' + _eventsNs + 'h', _prepareToStart) - .on('mouseleave' + _eventsNs + 'h', _fadeOutHint); } function _setDisabled(_button, _value) { From 23634731c10eca62a951d91ca4cf682f80e9fc75 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Fri, 15 Jan 2016 13:17:09 +0200 Subject: [PATCH 39/48] Removes unnecessary margin from the year table buttons --- MonthPicker.min.js | 2 +- css/MonthPicker.css | 6 ++++-- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.css | 2 +- test/test.html | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 13641f3..c1ec0cb 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/css/MonthPicker.css b/css/MonthPicker.css index ee9255c..8623362 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -55,6 +55,7 @@ See: .month-picker-month-table button { width: 4.3em; } -webkit-user-select: none; user-select: none; } + .month-picker-year-table .jump-years { text-align: center; } @@ -84,14 +85,15 @@ Sets the size of the next/previous buttons, and makes the buttons in the heading (year-table) sligtly bigger, and removes the pointer cursor from the buttons in the heading (year-table). */ -.month-picker-year-table a.ui-button { +.month-picker-year-table .ui-button { font-size: 1.1em; width: 1.5em; height: 1.5em; cursor: default; + margin: 0; } -.month-picker-year-table .jump-years a.ui-button { +.month-picker-year-table .jump-years .ui-button { width: 100%; font-weight: bold; } diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 73d1da1..3bbbf0b 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table a.ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default}.month-picker-year-table .jump-years a.ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table .ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default;margin:0}.month-picker-year-table .jump-years .ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 9284839..c3e1b94 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){i=l.text(),l.animate({opacity:1},k).text(c)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,d)}function f(){j=setTimeout(e,175)}function g(){l.text(i).animate({opacity:1},k)}function h(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,g)}var i,j,k=125,l=a();b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")}),b.on("mouseenter"+t+"h",f).on("mouseleave"+t+"h",h)}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._showYears(),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),this._backToYear=this._getPickerYear(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.css b/test/test.css index d6bd559..64d55dc 100644 --- a/test/test.css +++ b/test/test.css @@ -1,6 +1,6 @@ /******* ***************** ********/ -/* Unit Testing CSS */ +/* Unit Testing and demo aon JSFiddle CSS */ /******* ***************** ********/ body { diff --git a/test/test.html b/test/test.html index 08cb43f..8a6056d 100644 --- a/test/test.html +++ b/test/test.html @@ -7,7 +7,7 @@ - + @@ -16,7 +16,7 @@ - + - + + if (typeof $ === 'undefined' || !$.ui || typeof QUnit === 'undefnied') { diff --git a/test/test.js b/test/test.js index b15647f..48be8be 100644 --- a/test/test.js +++ b/test/test.js @@ -962,6 +962,17 @@ QUnit.test('ShowOn both', function (assert) { assert.notOk(menu.is(':visible'), 'The menu was closed by pressing tab'); }); +QUnit.test('i18n', function (assert) { + assert.expect(2); + + $("").MonthPicker({ + Button: function(options) { + assert.ok(options.i18n.buttonText, 'The button callback received the buttonText i18n property'); + assert.ok(options.i18n.nextYear, 'The button callback received the nextYear i18n property'); + } + }).MonthPicker('destroy'); +}); + QUnit.module("Min/MaxMonth"); QUnit.test('Month buttons are disabled', function (assert) { From 7589c326d0be882182fa2b12c16c61aca4ba73e9 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Sat, 16 Jan 2016 17:31:01 +0200 Subject: [PATCH 43/48] Gives new class names to
    s in the month-picker-year-table The renaming is done to avoid conflicts with the users existing CSS. For example, the user might have defined a .next-year CSS selector in there CSS which will mess up the menu. It is also possible that users have applied their own CSS to the menu to workaround some of the issues the CSS had in version 2.x, in these cases I don't want the user's CSS to mess up the new menu which works differently. previous-year is now month-picker-previous next-year is now month-picker-next jump-years is now month-picker-title --- MonthPicker.js | 12 ++++----- MonthPicker.min.js | 2 +- css/MonthPicker.css | 10 +++---- css/MonthPicker.min.css | 2 +- demo/Demo.min.css | 2 +- demo/Demo.min.js | 2 +- test/test.js | 60 ++++++++++++++++++++--------------------- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 34db2ce..9d452c3 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -182,9 +182,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. '
    ' + '' + '' + - '' + - '' + - '' + + '' + + '' + + '' + '' + '
    ' + '
    ' + @@ -399,7 +399,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _menu.appendTo( isInline ? _el : document.body ); this._jumpYearsButton = - $('.jump-years', _menu) + $('.month-picker-title', _menu) .click($proxy(this._showYearsClickHandler, this)) .find('a').jqueryUIButton() .removeClass(_defaultClass); @@ -407,11 +407,11 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._applyJumpYearsHint(); this._createValidationMessage(); - this._prevButton = $('.previous-year a', _menu) + this._prevButton = $('.month-picker-previous>a', _menu) .jqueryUIButton({ text: false }) .removeClass(_defaultClass); - this._nextButton = $('.next-year a', _menu) + this._nextButton = $('.month-picker-next>a', _menu) .jqueryUIButton({ text: false }) .removeClass(_defaultClass); diff --git a/MonthPicker.min.js b/MonthPicker.min.js index c1ec0cb..003a129 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/css/MonthPicker.css b/css/MonthPicker.css index aad95fa..04c4828 100644 --- a/css/MonthPicker.css +++ b/css/MonthPicker.css @@ -56,10 +56,6 @@ See: .month-picker-month-table button { width: 4.3em; } user-select: none; } -.month-picker-year-table .jump-years { - text-align: center; -} - /* The plugin uses buttons with a transparent background in the year-table (aka header) in order to look consistent with jQuery UI datepicker and to @@ -93,7 +89,11 @@ and removes the pointer cursor from the buttons in the heading (year-table). margin: 0; } -.month-picker-year-table .jump-years .ui-button { +.month-picker-year-table .month-picker-title { + text-align: center; +} + +.month-picker-year-table .month-picker-title .ui-button { font-size: 1em; padding: .1em 0; width: 100%; diff --git a/css/MonthPicker.min.css b/css/MonthPicker.min.css index 35526ca..f12a581 100644 --- a/css/MonthPicker.min.css +++ b/css/MonthPicker.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table .ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default;margin:0}.month-picker-year-table .jump-years .ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled{background-color:#e1e1e1} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table .ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default;margin:0}.month-picker-year-table .month-picker-title{text-align:center}.month-picker-year-table .month-picker-title .ui-button{font-size:1em;padding:.1em 0;width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled{background-color:#e1e1e1} \ No newline at end of file diff --git a/demo/Demo.min.css b/demo/Demo.min.css index 3bbbf0b..6b673c5 100644 --- a/demo/Demo.min.css +++ b/demo/Demo.min.css @@ -1 +1 @@ -.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table .jump-years{text-align:center}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table .ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default;margin:0}.month-picker-year-table .jump-years .ui-button{width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file +.month-picker{display:inline-block;position:absolute;z-index:9999}.month-picker table{border-collapse:separate;border-spacing:2px 2px}.month-picker td{padding:0}.month-picker .ui-button-text{padding:.4em 0}.month-picker-header{margin:3px 3px 0}.month-picker-year-table{width:100%;-ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none}.month-picker-year-table a{border:1px solid transparent}.month-picker-year-table .ui-button{font-size:1.1em;width:1.5em;height:1.5em;cursor:default;margin:0}.month-picker-year-table .month-picker-title{text-align:center}.month-picker-year-table .month-picker-title .ui-button{font-size:1em;padding:.1em 0;width:100%;font-weight:700}.month-picker-year-table .ui-button-text{padding:0}.month-picker-month-table td{height:35px;text-align:center}.month-picker-month-table button{width:4.3em;margin:.2em}.month-picker-open-button{height:20px;width:20px;vertical-align:bottom}.month-picker-invalid-message{display:none;background-color:#ff0}.month-picker-disabled,.option-block{background-color:#e1e1e1}body{font-size:12px;font-family:Verdana,Arial,sans-serif}.option-block{display:none;padding:4px;border:1px solid #000}.option{margin:20px;border:1px solid Gray;padding:4px}.demo,.demo-position{background-color:#e1e1e1;padding:8px;border:1px solid Gray}.option-link{text-decoration:underline;color:#00f;cursor:pointer;font-weight:700}.option-link:hover{color:Red}.option-type{margin:0 25px}.demo-position{width:100%}.text-right{text-align:right} \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index c3e1b94..1672735 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".jump-years",i).attr("title",this._i18n("jumpYears")).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".previous-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".next-year a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 48be8be..8d5be2d 100644 --- a/test/test.js +++ b/test/test.js @@ -17,7 +17,7 @@ var _today = new Date(); $.KidSysco.MonthPicker.prototype.options.Duration = 1; function _getPickerYear(_pickerMenu) { - return parseInt($('.jump-years span', _pickerMenu).text().replace(/\D/g, ''), 10); + return parseInt($('.month-picker-title span', _pickerMenu).text().replace(/\D/g, ''), 10); } QUnit.module("Installation"); @@ -398,11 +398,11 @@ QUnit.test('Inline menu', function(assert) { }); var menu = $(MonthPicker_InlineMenuDiv); - var nextYearButton = menu.find('.next-year .ui-button'); - var previousYearButton = menu.find('.previous-year .ui-button'); + var nextYearButton = menu.find('.month-picker-next .ui-button'); + var previousYearButton = menu.find('.month-picker-previous .ui-button'); - assert.equal(nextYearButton.css('float'), 'right', 'The next year button has the expected alignment for RTL documents'); - assert.equal(previousYearButton.css('float'), 'left', 'The previous year button has the expected alignment for RTL documents'); + assert.equal(nextYearButton.css('float'), 'right', 'The next year button has the expected alignment for RTL documents'); + assert.equal(previousYearButton.css('float'), 'left', 'The previous year button has the expected alignment for RTL documents'); assert.ok(menu.width() <= 200, 'The menu is visible and has the expected width'); @@ -491,7 +491,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterNextYear was called in the right context' ); }); - var nextYearButton = menu.find('.next-year>a'); + var nextYearButton = menu.find('.month-picker-next>a'); nextYearButton.trigger('click'); assert.ok(OnAfterNextYearTriggered, 'Clicking the next button triggered OnAfterNextYear'); @@ -503,7 +503,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterPreviousYear was called in the right context' ); }); - var previousYearButton = menu.find('.previous-year>a'); + var previousYearButton = menu.find('.month-picker-previous>a'); previousYearButton.trigger('click'); assert.ok(OnAfterPreviousYearTriggerd, 'Clciking rhe previous button triggered OnAfterPreviousYear'); @@ -514,7 +514,7 @@ QUnit.test('Events and context', function (assert) { // A.k.a duplicate code tes assert.equal( this, EventsField, 'OnAfterChooseYears was called in the right context' ); }); - var showYearsButton = menu.find('.jump-years a'); + var showYearsButton = menu.find('.month-picker-title a'); showYearsButton.trigger('click'); assert.ok(OnAfterChooseYearsTriggerd, 'Clicking the show years button triggered OnAfterChooseYears'); @@ -658,8 +658,8 @@ QUnit.test('Right to left', function (assert) { var menu = $(MonthPicker_RTLField); - var nextYearButton = menu.find('.next-year .ui-button'); - var previousYearButton = menu.find('.previous-year .ui-button'); + var nextYearButton = menu.find('.month-picker-next .ui-button'); + var previousYearButton = menu.find('.month-picker-previous .ui-button'); // Make sure the buttons are pointing in the right (opposite) direction. assert.ok(previousYearButton.find('span.ui-icon-circle-triangle-e').length, 'Previous button is pointed east'); @@ -985,8 +985,8 @@ QUnit.test('Month buttons are disabled', function (assert) { field.MonthPicker('Open'); var menu = $(MonthPicker_RistrictMonthField); - var previousYearButton = menu.find('.previous-year>a'); - var nextYearButton = menu.find('.next-year>a'); + var previousYearButton = menu.find('.month-picker-previous>a'); + var nextYearButton = menu.find('.month-picker-next>a'); // Try to click the disabled buttons. var buttons = menu.find('.month-picker-month-table button'); @@ -1063,7 +1063,7 @@ QUnit.test('Year buttons are disabled', function (assert) { var menu = $(MonthPicker_RistrictMonthField); // Click the year title to show the years. - menu.find('.jump-years a').trigger('click'); + menu.find('.month-picker-title a').trigger('click'); // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); @@ -1085,7 +1085,7 @@ QUnit.test('Year buttons are disabled', function (assert) { assert.ok(firstVisibleYear, "Clciking the disabled buttons didn't take us to month view"); // Make sure the next years button is disabled. - var nextYearsButton = menu.find('.next-year>a'); + var nextYearsButton = menu.find('.month-picker-next>a'); var isDisabled = nextYearsButton .trigger('click') .is('.ui-button-disabled'); @@ -1094,7 +1094,7 @@ QUnit.test('Year buttons are disabled', function (assert) { var newFirstYrar = parseInt($(buttons[0]).text(), 10); assert.equal(newFirstYrar, firstVisibleYear, "Clicking next year didn't change the year"); - var previousYearsButton = menu.find('.previous-year>a'); + var previousYearsButton = menu.find('.month-picker-previous>a'); // Keep going back until there are no disabled buttons. // We count to 10 to avoid an infinite loop in case there's // a bug where we are going back in time but the the buttons stay disabled. @@ -1145,7 +1145,7 @@ QUnit.test('Year buttons are disabled', function (assert) { assert.ok(!hasDidabledButtons, 'All buttons are enabled'); // Click the year title to show the years menu. - menu.find('.jump-years a').trigger('click'); + menu.find('.month-picker-title a').trigger('click'); // Keeps clicking next years until we reach the disabled years. for (var i = 1; !buttons.is('.ui-button-disabled') && i <= 10; i++) { @@ -1268,8 +1268,8 @@ QUnit.test('Today and selected months are highlighted', function (assert) { var todaysButton = $(buttons[new Date().getMonth()]); - var nextYearButton = menu.find('.next-year>a'); - var previousYearButton = menu.find('.previous-year>a'); + var nextYearButton = menu.find('.month-picker-next>a'); + var previousYearButton = menu.find('.month-picker-previous>a'); assert.ok(todaysButton.is('.ui-state-highlight'), "Today's month is highlighted"); @@ -1292,7 +1292,7 @@ QUnit.test('Today and selected months are highlighted', function (assert) { assert.equal( selectedButton.length, 1, 'There is one selected button'); assert.equal( selectedButton[0], buttons[4], 'The selected month is highlighted'); - menu.find('.jump-years a').trigger('click'); + menu.find('.month-picker-title a').trigger('click'); var selectdBtn = buttons.filter('.ui-state-active'); assert.equal( selectdBtn.jqueryUIButton( "option", "label" ), _today.getFullYear(), 'The selected year is highlighted'); @@ -1332,8 +1332,8 @@ QUnit.test('Number of months from today', function (assert) { // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); - var nextYearButton = menu.find('.next-year>a'); - var previousYearButton = menu.find('.previous-year>a'); + var nextYearButton = menu.find('.month-picker-next>a'); + var previousYearButton = menu.find('.month-picker-previous>a'); var enabledMonths = 0; @@ -1388,8 +1388,8 @@ QUnit.test('Relative month periods', function (assert) { // Make sure we are in years view. var buttons = menu.find('.month-picker-month-table button'); - var nextYearButton = menu.find('.next-year>a'); - var previousYearButton = menu.find('.previous-year>a'); + var nextYearButton = menu.find('.month-picker-next>a'); + var previousYearButton = menu.find('.month-picker-previous>a'); var enabledMonths = 0; // Make sure that 18 buttons + 1 for today are disabled. @@ -1464,7 +1464,7 @@ QUnit.test('Title buttons', function (assert) { }); var menu = $(MonthPicker_RistrictMonthField); - var nextButton = menu.find('.next-year .ui-button'); + var nextButton = menu.find('.month-picker-next .ui-button'); field.MonthPicker('Open'); assert.notOk(nextButton.is('.ui-state-default'), "The next button doesn't have the .ui-state-default class"); @@ -1512,9 +1512,9 @@ QUnit.test('Back to 2015 button', function (assert) { field.MonthPicker('Open'); var menu = $(MonthPicker_RistrictMonthField); - var titleButton = menu.find('.jump-years .ui-button'); - var nextButton = menu.find('.next-year .ui-button'); - var backButton = menu.find('.previous-year .ui-button'); + var titleButton = menu.find('.month-picker-title .ui-button'); + var nextButton = menu.find('.month-picker-next .ui-button'); + var backButton = menu.find('.month-picker-previous .ui-button'); nextButton.trigger('click'); var nextYear = _today.getFullYear() + 1; @@ -1523,7 +1523,7 @@ QUnit.test('Back to 2015 button', function (assert) { titleButton.trigger('click'); var expectedTitle = $.MonthPicker.i18n.backTo + ' ' + nextYear; - assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'The title button has the expected label' ); + assert.equal( $('.month-picker-title span', menu).text(), expectedTitle, 'The title button has the expected label' ); /* Here we simulate the user jumping back and forth in @@ -1546,7 +1546,7 @@ QUnit.test('Back to 2015 button', function (assert) { var nextClickCount = i; assert.notOk( hasNext, "Today's year is not visible after clicking next" ); - assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'Clicking next did not change the button label' ); + assert.equal( $('.month-picker-title span', menu).text(), expectedTitle, 'Clicking next did not change the button label' ); for (var p = 0; p < nextClickCount * 2; p++) { backButton.trigger('click'); @@ -1554,7 +1554,7 @@ QUnit.test('Back to 2015 button', function (assert) { hasNext = buttons.is('.ui-state-highlight'); assert.notOk( hasNext, "Today's year is not visible after clicking previous" ); - assert.equal( $('.jump-years span', menu).text(), expectedTitle, 'Clicking previous did not change the button label' ); + assert.equal( $('.month-picker-title span', menu).text(), expectedTitle, 'Clicking previous did not change the button label' ); // Click the title button and make sure it returnd us to the expected year. titleButton.trigger('click'); From c4ce4d6ae9cf2d7a079e809e627c1bf9af40d1bc Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 19 Jan 2016 14:13:03 +0200 Subject: [PATCH 44/48] Renames _jumpYearsButton to _titleButton --- MonthPicker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MonthPicker.js b/MonthPicker.js index 9d452c3..d7756fc 100644 --- a/MonthPicker.js +++ b/MonthPicker.js @@ -398,7 +398,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. $(_markup).appendTo(_menu); _menu.appendTo( isInline ? _el : document.body ); - this._jumpYearsButton = + this._titleButton = $('.month-picker-title', _menu) .click($proxy(this._showYearsClickHandler, this)) .find('a').jqueryUIButton() @@ -649,7 +649,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. }, _applyJumpYearsHint: function() { - _applyButtonHint(this._jumpYearsButton, this._i18n('jumpYears')); + _applyButtonHint(this._titleButton, this._i18n('jumpYears')); }, _i18n: function(str) { @@ -822,7 +822,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. _setPickerYear: function (year) { this._pickerYear = year || new Date().getFullYear(); - this._jumpYearsButton.jqueryUIButton({ label: this._i18n('year') + ' ' + this._pickerYear }); + this._titleButton.jqueryUIButton({ label: this._i18n('year') + ' ' + this._pickerYear }); }, _updateAlt: function (noop, date) { @@ -886,7 +886,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. this._showYears(); var _label = this._i18n('backTo') + ' ' + this._getPickerYear(); - this._jumpYearsButton.jqueryUIButton({ label: _label }).data( _clearHint )(); + this._titleButton.jqueryUIButton({ label: _label }).data( _clearHint )(); _event('OnAfterChooseYears', this)(); } else { From 19fe09239310c02797d50114ccabdefcd62a0a62 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 19 Jan 2016 16:00:20 +0200 Subject: [PATCH 45/48] Adds the 3.x Upgrade Guide --- UPGRADE.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 UPGRADE.md diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 0000000..094a6f4 --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,56 @@ +# 3.x Upgrade Guide + +Version 3.x features a redesigned Month Picker menu which: + +1. Looks more consistent with [jQuery UI Datepicker](https://jqueryui.com/datepicker/). +2. Turns the Year title into a button which gives the user a "hint" about +the Jump Years menu when they mouse over it. +3. Allows the user to return to the year they clicked Jump years at. + +See it for yourself at the [demo on JSFiddle](http://jsfiddle.net/kidsysco/JeZap/). + +## i18n property name changes +If you changed out the buttons, labels or other text using the +i18n support you should rename and translate `next5Years` to `next12Years` +and `prev5Years` to `prev12Years`. + +You should also add the `backTo` property, which is used for the +new *Back to 2016* button when the user enters the Jump Year menu. + +## CSS changes +Version 3.x uses `em` instead of `px` units. +This means that the menu determines it's size according to the +`body` element's `font-size`. + +If you need to resize the menu, add this rule to your CSS: +``` +/* Makes the Month Picker menu 20% bigger. */ +.month-picker { + font-size: 1.2em; +} +``` + +## Markup changes +If you've applied custom CSS to the Month Picker menu, please note that: + +The following elements were removed: +``` +`. +The `` tag is a [jQyery UI Button](https://jqueryui.com/button/). + +The following elements: +``` + + +``` +were replaced by: +``` + + +``` From 90e3d2c51e464f2c5368c13692c3e18ae68b1cb4 Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 19 Jan 2016 16:25:23 +0200 Subject: [PATCH 46/48] Adds a link to the 3.0 Upgrade Guide to README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index fbd9445..8560bef 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ for date validation, setting the start year, using an icon button, input masking -See a demo on jsFiddle at... -http://jsfiddle.net/kidsysco/JeZap/ +

    Upgrading from version 2.x.x?

    +

    +Please read the 3.x Upgrade Guide +

    +

    Prerequisites

    This plugin has been tested using the following configuration.

      From e1fc3237635bb22b20b7b84980da46368bbc234e Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 19 Jan 2016 19:27:17 +0200 Subject: [PATCH 47/48] Runs grunt --- MonthPicker.min.js | 2 +- demo/Demo.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MonthPicker.min.js b/MonthPicker.min.js index 003a129..ccacd03 100644 --- a/MonthPicker.min.js +++ b/MonthPicker.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    +
    + + +
    +``` +They were replaces by `
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._titleButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._titleButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._titleButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._titleButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file diff --git a/demo/Demo.min.js b/demo/Demo.min.js index 1672735..b791048 100644 --- a/demo/Demo.min.js +++ b/demo/Demo.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._jumpYearsButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._jumpYearsButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._jumpYearsButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._jumpYearsButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;return 0===this.length||this.is(":hidden")?void 0:"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.beging)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})}),function(a,b,c,d){"use strict";function e(a){return a.getMonth()+12*a.getFullYear()}function f(a){return Math.floor(a/12)}function g(){a(this).addClass(z)}function h(a,b){return a[b?"on":"off"]("mousenter mouseout",g).toggleClass(z,b)}function i(a,b,c){return(!b||a>=b)&&(!c||c>=a)}function j(b,c){if(null===c)return c;if(c instanceof d)return e(c);if(a.isNumeric(c))return e(new d)+parseInt(c,10);var f=b._parseMonth(c);return f?e(f):l(c)}function k(a,b){return L(b.options[a]||K,b.element[0])}function l(b,c){var f=a.trim(b);f=f.replace(/y/i,'":"y"'),f=f.replace(/m/i,'":"m"');try{var g=JSON.parse('{"'+f.replace(/ /g,',"')+"}"),h={};for(var i in g)h[g[i]]=i;var j=e(new d);return j+=parseInt(h.m,10)||0,j+12*(parseInt(h.y,10)||0)}catch(k){return!1}}function m(b){return a(''+b.i18n.buttonText+"").jqueryUIButton({text:!1,icons:{primary:b.ButtonIcon}})}function n(a,b){a.jqueryUIButton("option",{icons:{primary:"ui-icon-circle-triangle-"+(b?"w":"e")}})}function o(a){return!a.is("input")}function p(b,c){function d(){j=setTimeout(e,175)}function e(){j=null,l=a("span",b).animate({opacity:.45},k,f)}function f(){i=l.text(),l.animate({opacity:1},k).text(c)}function g(){j?clearTimeout(j):l=a("span",b).animate({opacity:.45},k,h)}function h(){l.text(i).animate({opacity:1},k)}var i,j,k=125,l=a();b.on("mouseenter"+t+"h",d),b.on("mouseleave"+t+"h",g),b.data(v,function(){clearTimeout(j),l.stop().css({opacity:1}),b.off(t+"h")})}function q(a,b){var c=a.data("ui-button");c.option("disabled")!==b&&c.option("disabled",b)}var r="MonthPicker Error: ";if(!(a&&a.ui&&a.ui.button&&a.ui.datepicker))return void alert(r+"The jQuery UI button and datepicker plug-ins must be loaded.");a.widget.bridge("jqueryUIButton",a.ui.button);var s=a.fx.speeds,t=".MonthPicker",u="month-year-input",v="month-picker-clear-hint",w=".ui-button-icon-primary",x="month-picker-disabled",y="ui-state-highlight",z="ui-state-active",A="ui-state-default",B={my:"left top+1",at:"left bottom"},C={my:"right top+1",at:"right bottom"},D=r+"The jQuery UI position plug-in must be loaded.",E=r+"Unsupported % option value, supported values are: ",F=r+'"_" is not a valid %Month value.',G=null,H=!!a.ui.position,I={Animation:["slideToggle","fadeToggle","none"],ShowAnim:["fadeIn","slideDown","none"],HideAnim:["fadeOut","slideUp","none"]},J={ValidationErrorMessage:"_createValidationMessage",Disabled:"_setDisabledState",ShowIcon:"_updateButton",Button:"_updateButton",ShowOn:"_updateFieldEvents",IsRTL:"_setRTL",AltFormat:"_updateAlt",AltField:"_updateAlt",StartYear:"_setPickerYear",MinMonth:"_setMinMonth",MaxMonth:"_setMaxMonth",SelectedMonth:"_setSelectedMonth"},K=a.noop,L=a.proxy,M=a.datepicker,N="click"+t;a.MonthPicker={VERSION:"3.0-beta1",i18n:{year:"Year",prevYear:"Previous Year",nextYear:"Next Year",next12Years:"Jump Forward 12 Years",prev12Years:"Jump Back 12 Years",nextLabel:"Next",prevLabel:"Prev",buttonText:"Open Month Chooser",jumpYears:"Jump Years",backTo:"Back to",months:["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec."]}};var O='
    ';a.widget("KidSysco.MonthPicker",{options:{i18n:{},IsRTL:!1,Position:null,StartYear:null,ShowIcon:!0,UseInputMask:!1,ValidationErrorMessage:null,Disabled:!1,MonthFormat:"mm/yy",Animation:"fadeToggle",ShowAnim:null,HideAnim:null,ShowOn:null,MinMonth:null,MaxMonth:null,Duration:"normal",Button:m,ButtonIcon:"ui-icon-calculator"},_monthPickerButton:a(),_validationMessage:a(),_selectedBtn:a(),_destroy:function(){var b=this.element;a.mask&&this.options.UseInputMask&&(b.unmask(),this.GetSelectedDate()||b.val("")),b.removeClass(u).off(t),a(c).off(t+this.uuid),this._monthPickerMenu.remove();var d=this._monthPickerButton.off(N);this._removeOldBtn&&d.remove(),this._validationMessage.remove(),G===this&&(G=null)},_setOption:function(b,c){switch(b){case"i18n":c=a.extend({},c);break;case"Position":if(!H)return void alert(D);break;case"MonthFormat":var d=this.GetSelectedDate();d&&this.element.val(this.FormatMonth(d,c))}return b in I&&-1===a.inArray(c,I[b])?void alert(E.replace(/%/,b)+I[b]):(this._super(b,c),void(J[b]?this[J[b]](c):0))},_create:function(){var b=this.element,e=this.options;if(!b.is("input,div,span")||-1===a.inArray(b.attr("type"),["text","month",void 0])){var g=r+"MonthPicker can only be called on text or month inputs.";return alert(g+" \n\nSee (developer tools) for more details."),console.error(g+"\n Caused by:"),console.log(b[0]),!1}if(!a.mask&&e.UseInputMask)return alert(r+"The UseInputMask option requires the Input Mask Plugin. Get it from digitalbush.com"),!1;if(null!==e.Position&&!H)return alert(D),!1;for(var h in I)if(null!==e[h]&&-1===a.inArray(e[h],I[h]))return alert(E.replace(/%/,h)+I[h]),!1;this._isMonthInputType="month"===b.attr("type"),this._isMonthInputType&&(this.options.MonthFormat=this.MonthInputFormat,b.css("width","auto"));var i=this._monthPickerMenu=a('
    ').hide(),k=o(b);a(O).appendTo(i),i.appendTo(k?b:c.body),this._titleButton=a(".month-picker-title",i).click(L(this._showYearsClickHandler,this)).find("a").jqueryUIButton().removeClass(A),this._applyJumpYearsHint(),this._createValidationMessage(),this._prevButton=a(".month-picker-previous>a",i).jqueryUIButton({text:!1}).removeClass(A),this._nextButton=a(".month-picker-next>a",i).jqueryUIButton({text:!1}).removeClass(A),this._setRTL(e.IsRTL),a(w,this._nextButton).text(this._i18n("nextLabel")),a(w,this._prevButton).text(this._i18n("prevLabel"));for(var l=a(".month-picker-month-table",i),m=0;12>m;m++){var n=m%3?n:a("").appendTo(l);n.append('')}this._buttons=a("button",l).jqueryUIButton(),i.on(N,function(a){return!1});var p=this,q="Month";a.each(["Min","Max"],function(a,b){p["_set"+b+q]=function(a){(p["_"+b+q]=j(p,a))===!1&&alert(F.replace(/%/,b).replace(/_/,a))},p._setOption(b+q,p.options[b+q])});var s=e.SelectedMonth;if(void 0!==s){var t=j(this,s);b.val(this._formatMonth(new d(f(t),t%12,1)))}this._updateAlt(),this._setUseInputMask(),this._setDisabledState(),this.Destroy=this.destroy,k?this.Open():(b.addClass(u),b.change(L(this._updateAlt,this)))},GetSelectedDate:function(){return this._parseMonth()},GetSelectedYear:function(){var a=this.GetSelectedDate();return a?a.getFullYear():NaN},GetSelectedMonth:function(){var a=this.GetSelectedDate();return a?a.getMonth()+1:NaN},Validate:function(){var a=this.GetSelectedDate();return null===this.options.ValidationErrorMessage||this.options.Disabled||this._validationMessage.toggle(!a),a},GetSelectedMonthYear:function(){var a=this.Validate();return a?a.getMonth()+1+"/"+a.getFullYear():null},Disable:function(){this._setOption("Disabled",!0)},Enable:function(){this._setOption("Disabled",!1)},ClearAllCallbacks:function(){for(var a in this.options)0===a.indexOf("On")&&(this.options[a]=K)},Clear:function(){this.element.val(""),this._validationMessage.hide()},Toggle:function(a){return this._visible?this.Close(a):this.Open(a)},Open:function(b){var d=this.element,e=this.options;if(!e.Disabled&&!this._visible){if(b=b||a.Event(),k("OnBeforeMenuOpen",this)(b)===!1||b.isDefaultPrevented())return!1;this._visible=!0,this._ajustYear(e);var f=this._monthPickerMenu;if(this._showMonths(),o(d))f.css("position","static").show(),k("OnAfterMenuOpen",this)();else{G&&G.Close(b),G=this,a(c).on(N+this.uuid,L(this.Close,this)).on("keydown"+t+this.uuid,L(this._keyDown,this)),d.off("blur"+t).focus();var g=e.ShowAnim||e.Animation,h="none"===g;f[h?"fadeIn":g]({duration:h?0:this._duration(),start:L(this._position,this,f),complete:k("OnAfterMenuOpen",this)})}}return!1},Close:function(b){var d=this.element;if(!o(d)&&this._visible){var e=this._monthPickerMenu,f=this.options;if(b=b||a.Event(),k("OnBeforeMenuClose",this)(b)===!1||b.isDefaultPrevented())return;this._backToYear&&(this._applyJumpYearsHint(),this._backToYear=0),this._visible=!1,G=null,a(c).off("keydown"+t+this.uuid).off(N+this.uuid),this.Validate(),d.on("blur"+t,L(this.Validate,this));var g=k("OnAfterMenuClose",this),h=f.HideAnim||f.Animation;"none"===h?e.hide(0,g):e[h](this._duration(),g)}},MonthInputFormat:"yy-mm",ParseMonth:function(a,b){try{return M.parseDate("dd"+b,"01"+a)}catch(c){return null}},FormatMonth:function(a,b){try{return M.formatDate(b,a)||null}catch(c){return null}},_setSelectedMonth:function(a){var b=j(this,a),c=this.element;b?c.val(this._formatMonth(new d(f(b),b%12,1))):c.val(""),this._ajustYear(this.options),this._showMonths()},_applyJumpYearsHint:function(){p(this._titleButton,this._i18n("jumpYears"))},_i18n:function(b){return this.options.i18n[b]||a.MonthPicker.i18n[b]},_parseMonth:function(a,b){return this.ParseMonth(a||this.element.val(),b||this.options.MonthFormat)},_formatMonth:function(a,b){return this.FormatMonth(a||this._parseMonth(),b||this.options.MonthFormat)},_updateButton:function(){var a=this.options.Disabled;this._createButton();var b=this._monthPickerButton;try{b.jqueryUIButton("option","disabled",a)}catch(c){b.filter("button,input").prop("disabled",a)}this._updateFieldEvents()},_createButton:function(){var b=this.element,d=this.options;if(!o(b)){var e=this._monthPickerButton.off(t),f=d.ShowIcon?d.Button:!1;if(a.isFunction(f)){var g=a.extend(!0,{i18n:a.extend(!0,{},a.MonthPicker.i18n)},this.options);f=f.call(b[0],g)}var h=!1;this._monthPickerButton=(f instanceof a?f:a(f)).each(function(){a.contains(c.body,this)||(h=!0,a(this).insertAfter(b))}).on(N,L(this.Toggle,this)),this._removeOldBtn&&e.remove(),this._removeOldBtn=h}},_updateFieldEvents:function(){var a=N+" focus"+t;this.element.off(a),"both"!==this.options.ShowOn&&this._monthPickerButton.length||this.element.on(a,L(this.Open,this))},_createValidationMessage:function(){var b=this.options.ValidationErrorMessage,c=this.element;if(-1===a.inArray(b,[null,""])){var d=a(''+b+""),e=this._monthPickerButton;this._validationMessage=d.insertAfter(e.length?e:c),c.on("blur"+t,L(this.Validate,this))}else this._validationMessage.remove()},_setRTL:function(a){n(this._prevButton.css("float",a?"right":"left"),!a),n(this._nextButton.css("float",a?"left":"right"),a)},_keyDown:function(a){switch(a.keyCode){case 13:this.element.val()||this._chooseMonth((new d).getMonth()+1),this.Close(a);break;case 27:case 9:this.Close(a)}},_duration:function(){var b=this.options.Duration;return a.isNumeric(b)?b:b in s?s[b]:s._default},_position:H?function(b){var c=this.options.IsRTL?C:B,d=a.extend(c,this.options.Position);return b.position(a.extend({of:this.element},d))}:function(a){var b=this.element,c={top:b.offset().top+b.height()+7+"px"};return this.options.IsRTL?c.left=b.offset().left-a.width()+b.width()+7+"px":c.left=b.offset().left+"px",a.css(c)},_setUseInputMask:function(){if(!this._isMonthInputType)try{this.options.UseInputMask?this.element.mask(this._formatMonth(new d).replace(/\d/g,9)):this.element.unmask()}catch(a){}},_setDisabledState:function(){var a=this.options.Disabled,b=this.element;b[0].disabled=a,b.toggleClass(x,a),a&&this._validationMessage.hide(),this.Close(),this._updateButton(),k("OnAfterSetDisabled",this)(a)},_getPickerYear:function(){return this._pickerYear},_setPickerYear:function(a){this._pickerYear=a||(new d).getFullYear(),this._titleButton.jqueryUIButton({label:this._i18n("year")+" "+this._pickerYear})},_updateAlt:function(b,c){var d=a(this.options.AltField);d.length&&d.val(this._formatMonth(c,this.options.AltFormat))},_chooseMonth:function(b){var c=this._getPickerYear(),e=new d(c,b-1);this.element.val(this._formatMonth(e)).blur(),this._updateAlt(0,e),h(this._selectedBtn,!1),this._selectedBtn=h(a(this._buttons[b-1]),!0),k("OnAfterChooseMonth",this)(e)},_chooseYear:function(a){this._backToYear=0,this._setPickerYear(a),this._buttons.removeClass(y),this._showMonths(),k("OnAfterChooseYear",this)()},_showMonths:function(){var b=this._i18n("months");this._prevButton.attr("title",this._i18n("prevYear")).off(N).on(N,L(this._addToYear,this,-1)),this._nextButton.attr("title",this._i18n("nextYear")).off(N).on(N,L(this._addToYear,this,1)),this._buttons.off(t);var c=this,d=L(c._onMonthClick,c);a.each(b,function(b,e){a(c._buttons[b]).on(N,{month:b+1},d).jqueryUIButton("option","label",e)}),this._decorateButtons()},_showYearsClickHandler:function(){if(this._buttons.removeClass(y),this._backToYear)this._setPickerYear(this._backToYear),this._applyJumpYearsHint(),this._showMonths(),this._backToYear=0;else{this._backToYear=this._getPickerYear(),this._showYears();var a=this._i18n("backTo")+" "+this._getPickerYear();this._titleButton.jqueryUIButton({label:a}).data(v)(),k("OnAfterChooseYears",this)()}},_showYears:function(){var b=this._getPickerYear(),c=-4,e=b+c,g=12,j=(new d).getFullYear(),k=this._MinMonth,l=this._MaxMonth,m=k?f(k):0,n=l?f(l):0;this._prevButton.attr("title",this._i18n("prev12Years")).off(N).on(N,L(this._addToYears,this,-g)),this._nextButton.attr("title",this._i18n("next12Years")).off(N).on(N,L(this._addToYears,this,g)),q(this._prevButton,m&&m>e-1),q(this._nextButton,n&&e+12-1>n),this._buttons.off(t),h(this._selectedBtn,!1);for(var o=this.GetSelectedYear(),p=L(this._onYearClick,this),r=i(j,m,n),s=i(o,m,n),u=0;12>u;u++){var v=b+c,w=a(this._buttons[u]).jqueryUIButton({disabled:!i(v,m,n),label:v}).toggleClass(y,v===j&&r).on(N,{year:v},p);s&&o&&o===v&&(this._selectedBtn=h(w,!0)),c++}},_onMonthClick:function(a){this._chooseMonth(a.data.month),this.Close(a)},_onYearClick:function(a){this._chooseYear(a.data.year)},_addToYear:function(a){this._setPickerYear(this._getPickerYear()+a),this.element.focus(),this._decorateButtons(),k("OnAfter"+(a>0?"Next":"Previous")+"Year",this)()},_addToYears:function(a){this._pickerYear=this._getPickerYear()+a,this._showYears(),this.element.focus(),k("OnAfter"+(a>0?"Next":"Previous")+"Years",this)()},_ajustYear:function(a){var b=a.StartYear||this.GetSelectedYear()||(new d).getFullYear();null!==this._MinMonth&&(b=Math.max(f(this._MinMonth),b)),null!==this._MaxMonth&&(b=Math.min(f(this._MaxMonth),b)),this._setPickerYear(b)},_decorateButtons:function(){var b=this._getPickerYear(),c=e(new d),g=this._MinMonth,j=this._MaxMonth;h(this._selectedBtn,!1);var k=this.GetSelectedDate(),l=i(k?e(k):null,g,j);k&&k.getFullYear()===b&&(this._selectedBtn=h(a(this._buttons[k.getMonth()]),l)),q(this._prevButton,g&&b==f(g)),q(this._nextButton,j&&b==f(j));for(var m=0;12>m;m++){var n=12*b+m,o=i(n,g,j);a(this._buttons[m]).jqueryUIButton({disabled:!o}).toggleClass(y,o&&n==c)}}})}(jQuery,window,document,Date); \ No newline at end of file From cb168bba063ca8b1ce32eae90a4402864c08463d Mon Sep 17 00:00:00 2001 From: Benjamin Albert Date: Tue, 19 Jan 2016 20:05:03 +0200 Subject: [PATCH 48/48] Adds notice about removing the width: 60px; rule --- UPGRADE.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 094a6f4..04959a4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -20,7 +20,7 @@ new *Back to 2016* button when the user enters the Jump Year menu. ## CSS changes Version 3.x uses `em` instead of `px` units. This means that the menu determines it's size according to the -`body` element's `font-size`. +`body` element's `font-size`, instead of having a fixed width of `200px`. If you need to resize the menu, add this rule to your CSS: ``` @@ -30,6 +30,17 @@ If you need to resize the menu, add this rule to your CSS: } ``` +Version 3.x removes: +``` +.month-year-input { + width: 60px; +} +``` + +If you still want the plugin to implicitly resize the input fields it's applied to you must add this rule to your own CSS. + +If you explicitly defined a rule that reverts the effects of this rule, it's no longer necessary and it can be deleted. + ## Markup changes If you've applied custom CSS to the Month Picker menu, please note that: