forked from kbwood/calendars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.calendars.all.min.js
6 lines (6 loc) · 47.6 KB
/
jquery.calendars.all.min.js
1
2
3
4
5
6
/* http://keith-wood.name/calendars.html
Calendars for jQuery v2.0.2.
Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009.
Available under the MIT (http://keith-wood.name/licence.html) license.
Please attribute the author if you use it. */
(function($){function Calendars(){this.regionalOptions=[];this.regionalOptions['']={invalidCalendar:'Calendar {0} not found',invalidDate:'Invalid {0} date',invalidMonth:'Invalid {0} month',invalidYear:'Invalid {0} year',differentCalendars:'Cannot mix {0} and {1} dates'};this.local=this.regionalOptions[''];this.calendars={};this._localCals={}}$.extend(Calendars.prototype,{instance:function(a,b){a=(a||'gregorian').toLowerCase();b=b||'';var c=this._localCals[a+'-'+b];if(!c&&this.calendars[a]){c=new this.calendars[a](b);this._localCals[a+'-'+b]=c}if(!c){throw(this.local.invalidCalendar||this.regionalOptions[''].invalidCalendar).replace(/\{0\}/,a)}return c},newDate:function(a,b,c,d,e){d=(a!=null&&a.year?a.calendar():(typeof d==='string'?this.instance(d,e):d))||this.instance();return d.newDate(a,b,c)},substituteDigits:function(c){return function(b){return(b+'').replace(/[0-9]/g,function(a){return c[a]})}},substituteChineseDigits:function(e,f){return function(a){var b='';var c=0;while(a>0){var d=a%10;b=(d===0?'':e[d]+f[c])+b;c++;a=Math.floor(a/10)}if(b.indexOf(e[1]+f[1])===0){b=b.substr(1)}return b||e[0]}}});function CDate(a,b,c,d){this._calendar=a;this._year=b;this._month=c;this._day=d;if(this._calendar._validateLevel===0&&!this._calendar.isValid(this._year,this._month,this._day)){throw($.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate).replace(/\{0\}/,this._calendar.local.name)}}function pad(a,b){a=''+a;return'000000'.substring(0,b-a.length)+a}$.extend(CDate.prototype,{newDate:function(a,b,c){return this._calendar.newDate((a==null?this:a),b,c)},year:function(a){return(arguments.length===0?this._year:this.set(a,'y'))},month:function(a){return(arguments.length===0?this._month:this.set(a,'m'))},day:function(a){return(arguments.length===0?this._day:this.set(a,'d'))},date:function(a,b,c){if(!this._calendar.isValid(a,b,c)){throw($.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate).replace(/\{0\}/,this._calendar.local.name)}this._year=a;this._month=b;this._day=c;return this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(a,b){return this._calendar.add(this,a,b)},set:function(a,b){return this._calendar.set(this,a,b)},compareTo:function(a){if(this._calendar.name!==a._calendar.name){throw($.calendars.local.differentCalendars||$.calendars.regionalOptions[''].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,a._calendar.local.name)}var c=(this._year!==a._year?this._year-a._year:this._month!==a._month?this.monthOfYear()-a.monthOfYear():this._day-a._day);return(c===0?0:(c<0?-1:+1))},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(a){return this._calendar.fromJD(a)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(a){return this._calendar.fromJSDate(a)},toString:function(){return(this.year()<0?'-':'')+pad(Math.abs(this.year()),4)+'-'+pad(this.month(),2)+'-'+pad(this.day(),2)}});function BaseCalendar(){this.shortYearCutoff='+10'}$.extend(BaseCalendar.prototype,{_validateLevel:0,newDate:function(a,b,c){if(a==null){return this.today()}if(a.year){this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);c=a.day();b=a.month();a=a.year()}return new CDate(this,a,b,c)},today:function(){return this.fromJSDate(new Date())},epoch:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(b.year()<0?this.local.epochs[0]:this.local.epochs[1])},formatYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(b.year()<0?'-':'')+pad(Math.abs(b.year()),4)},monthsInYear:function(a){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return 12},monthOfYear:function(a,b){var c=this._validate(a,b,this.minDay,$.calendars.local.invalidMonth||$.calendars.regionalOptions[''].invalidMonth);return(c.month()+this.monthsInYear(c)-this.firstMonth)%this.monthsInYear(c)+this.minMonth},fromMonthOfYear:function(a,b){var m=(b+this.firstMonth-2*this.minMonth)%this.monthsInYear(a)+this.minMonth;this._validate(a,m,this.minDay,$.calendars.local.invalidMonth||$.calendars.regionalOptions[''].invalidMonth);return m},daysInYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(this.leapYear(b)?366:365)},dayOfYear:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return d.toJD()-this.newDate(d.year(),this.fromMonthOfYear(d.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return(Math.floor(this.toJD(d))+2)%this.daysInWeek()},extraInfo:function(a,b,c){this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return{}},add:function(a,b,c){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return this._correctAdd(a,this._add(a,b,c),b,c)},_add:function(c,f,g){this._validateLevel++;if(g==='d'||g==='w'){var h=c.toJD()+f*(g==='w'?this.daysInWeek():1);var d=c.calendar().fromJD(h);this._validateLevel--;return[d.year(),d.month(),d.day()]}try{var y=c.year()+(g==='y'?f:0);var m=c.monthOfYear()+(g==='m'?f:0);var d=c.day();var i=function(a){while(m<a.minMonth){y--;m+=a.monthsInYear(y)}var b=a.monthsInYear(y);while(m>b-1+a.minMonth){y++;m-=b;b=a.monthsInYear(y)}};if(g==='y'){if(c.month()!==this.fromMonthOfYear(y,m)){m=this.newDate(y,c.month(),this.minDay).monthOfYear()}m=Math.min(m,this.monthsInYear(y));d=Math.min(d,this.daysInMonth(y,this.fromMonthOfYear(y,m)))}else if(g==='m'){i(this);d=Math.min(d,this.daysInMonth(y,this.fromMonthOfYear(y,m)))}var j=[y,this.fromMonthOfYear(y,m),d];this._validateLevel--;return j}catch(e){this._validateLevel--;throw e;}},_correctAdd:function(a,b,c,d){if(!this.hasYearZero&&(d==='y'||d==='m')){if(b[0]===0||(a.year()>0)!==(b[0]>0)){var e={y:[1,1,'y'],m:[1,this.monthsInYear(-1),'m'],w:[this.daysInWeek(),this.daysInYear(-1),'d'],d:[1,this.daysInYear(-1),'d']}[d];var f=(c<0?-1:+1);b=this._add(a,c*e[0]+f*e[1],e[2])}}return a.date(b[0],b[1],b[2])},set:function(a,b,c){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);var y=(c==='y'?b:a.year());var m=(c==='m'?b:a.month());var d=(c==='d'?b:a.day());if(c==='y'||c==='m'){d=Math.min(d,this.daysInMonth(y,m))}return a.date(y,m,d)},isValid:function(a,b,c){this._validateLevel++;var d=(this.hasYearZero||a!==0);if(d){var e=this.newDate(a,b,this.minDay);d=(b>=this.minMonth&&b-this.minMonth<this.monthsInYear(e))&&(c>=this.minDay&&c-this.minDay<this.daysInMonth(e))}this._validateLevel--;return d},toJSDate:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return $.calendars.instance().fromJD(this.toJD(d)).toJSDate()},fromJSDate:function(a){return this.fromJD($.calendars.instance().fromJSDate(a).toJD())},_validate:function(a,b,c,d){if(a.year){if(this._validateLevel===0&&this.name!==a.calendar().name){throw($.calendars.local.differentCalendars||$.calendars.regionalOptions[''].differentCalendars).replace(/\{0\}/,this.local.name).replace(/\{1\}/,a.calendar().local.name)}return a}try{this._validateLevel++;if(this._validateLevel===1&&!this.isValid(a,b,c)){throw d.replace(/\{0\}/,this.local.name)}var f=this.newDate(a,b,c);this._validateLevel--;return f}catch(e){this._validateLevel--;throw e;}}});function GregorianCalendar(a){this.local=this.regionalOptions[a]||this.regionalOptions['']}GregorianCalendar.prototype=new BaseCalendar;$.extend(GregorianCalendar.prototype,{name:'Gregorian',jdEpoch:1721425.5,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:false,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{'':{name:'Gregorian',epochs:['BCE','CE'],monthNames:['January','February','March','April','May','June','July','August','September','October','November','December'],monthNamesShort:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],dayNames:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],dayNamesShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],dayNamesMin:['Su','Mo','Tu','We','Th','Fr','Sa'],digits:null,dateFormat:'mm/dd/yyyy',firstDay:0,isRTL:false}},leapYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);var a=b.year()+(b.year()<0?1:0);return a%4===0&&(a%100!==0||a%400===0)},weekOfYear:function(a,b,c){var d=this.newDate(a,b,c);d.add(4-(d.dayOfWeek()||7),'d');return Math.floor((d.dayOfYear()-1)/7)+1},daysInMonth:function(a,b){var c=this._validate(a,b,this.minDay,$.calendars.local.invalidMonth||$.calendars.regionalOptions[''].invalidMonth);return this.daysPerMonth[c.month()-1]+(c.month()===2&&this.leapYear(c.year())?1:0)},weekDay:function(a,b,c){return(this.dayOfWeek(a,b,c)||7)<6},toJD:function(c,d,e){var f=this._validate(c,d,e,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);c=f.year();d=f.month();e=f.day();if(c<0){c++}if(d<3){d+=12;c--}var a=Math.floor(c/100);var b=2-a+Math.floor(a/4);return Math.floor(365.25*(c+4716))+Math.floor(30.6001*(d+1))+e+b-1524.5},fromJD:function(f){var z=Math.floor(f+0.5);var a=Math.floor((z-1867216.25)/36524.25);a=z+1+a-Math.floor(a/4);var b=a+1524;var c=Math.floor((b-122.1)/365.25);var d=Math.floor(365.25*c);var e=Math.floor((b-d)/30.6001);var g=b-d-Math.floor(e*30.6001);var h=e-(e>13.5?13:1);var i=c-(h>2.5?4716:4715);if(i<=0){i--}return this.newDate(i,h,g)},toJSDate:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);var e=new Date(d.year(),d.month()-1,d.day());e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0);e.setHours(e.getHours()>12?e.getHours()+2:0);return e},fromJSDate:function(a){return this.newDate(a.getFullYear(),a.getMonth()+1,a.getDate())}});$.calendars=new Calendars();$.calendars.cdate=CDate;$.calendars.baseCalendar=BaseCalendar;$.calendars.calendars.gregorian=GregorianCalendar})(jQuery);(function($){$.extend($.calendars.regionalOptions[''],{invalidArguments:'Invalid arguments',invalidFormat:'Cannot format a date from another calendar',missingNumberAt:'Missing number at position {0}',unknownNameAt:'Unknown name at position {0}',unexpectedLiteralAt:'Unexpected literal at position {0}',unexpectedText:'Additional text found at end'});$.calendars.local=$.calendars.regionalOptions[''];$.extend($.calendars.cdate.prototype,{formatDate:function(a,b){if(typeof a!=='string'){b=a;a=''}return this._calendar.formatDate(a||'',this,b)}});$.extend($.calendars.baseCalendar.prototype,{UNIX_EPOCH:$.calendars.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:24*60*60,TICKS_EPOCH:$.calendars.instance().jdEpoch,TICKS_PER_DAY:24*60*60*10000000,ATOM:'yyyy-mm-dd',COOKIE:'D, dd M yyyy',FULL:'DD, MM d, yyyy',ISO_8601:'yyyy-mm-dd',JULIAN:'J',RFC_822:'D, d M yy',RFC_850:'DD, dd-M-yy',RFC_1036:'D, d M yy',RFC_1123:'D, d M yyyy',RFC_2822:'D, d M yyyy',RSS:'D, d M yy',TICKS:'!',TIMESTAMP:'@',W3C:'yyyy-mm-dd',formatDate:function(f,g,h){if(typeof f!=='string'){h=g;g=f;f=''}if(!g){return''}if(g.calendar()!==this){throw $.calendars.local.invalidFormat||$.calendars.regionalOptions[''].invalidFormat;}f=f||this.local.dateFormat;h=h||{};var i=h.dayNamesShort||this.local.dayNamesShort;var j=h.dayNames||this.local.dayNames;var k=h.monthNamesShort||this.local.monthNamesShort;var l=h.monthNames||this.local.monthNames;var m=h.calculateWeek||this.local.calculateWeek;var n=function(a,b){var c=1;while(u+c<f.length&&f.charAt(u+c)===a){c++}u+=c-1;return Math.floor(c/(b||1))>1};var o=function(a,b,c,d){var e=''+b;if(n(a,d)){while(e.length<c){e='0'+e}}return e};var p=function(a,b,c,d){return(n(a)?d[b]:c[b])};var q=this.local.digits;var r=function(a){return(h.localNumbers&&q?q(a):a)};var s='';var t=false;for(var u=0;u<f.length;u++){if(t){if(f.charAt(u)==="'"&&!n("'")){t=false}else{s+=f.charAt(u)}}else{switch(f.charAt(u)){case'd':s+=r(o('d',g.day(),2));break;case'D':s+=p('D',g.dayOfWeek(),i,j);break;case'o':s+=o('o',g.dayOfYear(),3);break;case'w':s+=o('w',g.weekOfYear(),2);break;case'm':s+=r(o('m',g.month(),2));break;case'M':s+=p('M',g.month()-this.minMonth,k,l);break;case'y':s+=(n('y',2)?g.year():(g.year()%100<10?'0':'')+g.year()%100);break;case'Y':n('Y',2);s+=g.formatYear();break;case'J':s+=g.toJD();break;case'@':s+=(g.toJD()-this.UNIX_EPOCH)*this.SECS_PER_DAY;break;case'!':s+=(g.toJD()-this.TICKS_EPOCH)*this.TICKS_PER_DAY;break;case"'":if(n("'")){s+="'"}else{t=true}break;default:s+=f.charAt(u)}}}return s},parseDate:function(g,h,j){if(h==null){throw $.calendars.local.invalidArguments||$.calendars.regionalOptions[''].invalidArguments;}h=(typeof h==='object'?h.toString():h+'');if(h===''){return null}g=g||this.local.dateFormat;j=j||{};var k=j.shortYearCutoff||this.shortYearCutoff;k=(typeof k!=='string'?k:this.today().year()%100+parseInt(k,10));var l=j.dayNamesShort||this.local.dayNamesShort;var m=j.dayNames||this.local.dayNames;var n=j.monthNamesShort||this.local.monthNamesShort;var o=j.monthNames||this.local.monthNames;var p=-1;var q=-1;var r=-1;var s=-1;var t=-1;var u=false;var v=false;var w=function(a,b){var c=1;while(C+c<g.length&&g.charAt(C+c)===a){c++}C+=c-1;return Math.floor(c/(b||1))>1};var x=function(a,b){var c=w(a,b);var d=[2,3,c?4:2,c?4:2,10,11,20]['oyYJ@!'.indexOf(a)+1];var e=new RegExp('^-?\\d{1,'+d+'}');var f=h.substring(B).match(e);if(!f){throw($.calendars.local.missingNumberAt||$.calendars.regionalOptions[''].missingNumberAt).replace(/\{0\}/,B)}B+=f[0].length;return parseInt(f[0],10)};var y=this;var z=function(a,b,c,d){var e=(w(a,d)?c:b);for(var i=0;i<e.length;i++){if(h.substr(B,e[i].length).toLowerCase()===e[i].toLowerCase()){B+=e[i].length;return i+y.minMonth}}throw($.calendars.local.unknownNameAt||$.calendars.regionalOptions[''].unknownNameAt).replace(/\{0\}/,B)};var A=function(){if(h.charAt(B)!==g.charAt(C)){throw($.calendars.local.unexpectedLiteralAt||$.calendars.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/,B)}B++};var B=0;for(var C=0;C<g.length;C++){if(v){if(g.charAt(C)==="'"&&!w("'")){v=false}else{A()}}else{switch(g.charAt(C)){case'd':s=x('d');break;case'D':z('D',l,m);break;case'o':t=x('o');break;case'w':x('w');break;case'm':r=x('m');break;case'M':r=z('M',n,o);break;case'y':var D=C;u=!w('y',2);C=D;q=x('y',2);break;case'Y':q=x('Y',2);break;case'J':p=x('J')+0.5;if(h.charAt(B)==='.'){B++;x('J')}break;case'@':p=x('@')/this.SECS_PER_DAY+this.UNIX_EPOCH;break;case'!':p=x('!')/this.TICKS_PER_DAY+this.TICKS_EPOCH;break;case'*':B=h.length;break;case"'":if(w("'")){A()}else{v=true}break;default:A()}}}if(B<h.length){throw $.calendars.local.unexpectedText||$.calendars.regionalOptions[''].unexpectedText;}if(q===-1){q=this.today().year()}else if(q<100&&u){q+=(k===-1?1900:this.today().year()-this.today().year()%100-(q<=k?0:100))}if(t>-1){r=1;s=t;for(var E=this.daysInMonth(q,r);s>E;E=this.daysInMonth(q,r)){r++;s-=E}}return(p>-1?this.fromJD(p):this.newDate(q,r,s))},determineDate:function(f,g,h,i,j){if(h&&typeof h!=='object'){j=i;i=h;h=null}if(typeof i!=='string'){j=i;i=''}var k=this;var l=function(a){try{return k.parseDate(i,a,j)}catch(e){}a=a.toLowerCase();var b=(a.match(/^c/)&&h?h.newDate():null)||k.today();var c=/([+-]?[0-9]+)\s*(d|w|m|y)?/g;var d=c.exec(a);while(d){b.add(parseInt(d[1],10),d[2]||'d');d=c.exec(a)}return b};g=(g?g.newDate():null);f=(f==null?g:(typeof f==='string'?l(f):(typeof f==='number'?(isNaN(f)||f===Infinity||f===-Infinity?g:k.today().add(f,'d')):k.newDate(f))));return f}})})(jQuery);(function($){var H='calendarsPicker';$.JQPlugin.createPlugin({name:H,defaultRenderer:{picker:'<div class="calendars">'+'<div class="calendars-nav">{link:prev}{link:today}{link:next}</div>{months}'+'{popup:start}<div class="calendars-ctrl">{link:clear}{link:close}</div>{popup:end}'+'<div class="calendars-clear-fix"></div></div>',monthRow:'<div class="calendars-month-row">{months}</div>',month:'<div class="calendars-month"><div class="calendars-month-header">{monthHeader}</div>'+'<table><thead>{weekHeader}</thead><tbody>{weeks}</tbody></table></div>',weekHeader:'<tr>{days}</tr>',dayHeader:'<th>{day}</th>',week:'<tr>{days}</tr>',day:'<td>{day}</td>',monthSelector:'.calendars-month',daySelector:'td',rtlClass:'calendars-rtl',multiClass:'calendars-multi',defaultClass:'',selectedClass:'calendars-selected',highlightedClass:'calendars-highlight',todayClass:'calendars-today',otherMonthClass:'calendars-other-month',weekendClass:'calendars-weekend',commandClass:'calendars-cmd',commandButtonClass:'',commandLinkClass:'',disabledClass:'calendars-disabled'},commands:{prev:{text:'prevText',status:'prevStatus',keystroke:{keyCode:33},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(1-a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay).add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,-a.options.monthsToStep)}},prevJump:{text:'prevJumpText',status:'prevJumpStatus',keystroke:{keyCode:33,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(1-a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay).add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,-a.options.monthsToJump)}},next:{text:'nextText',status:'nextStatus',keystroke:{keyCode:34},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay).compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,a.options.monthsToStep)}},nextJump:{text:'nextJumpText',status:'nextJumpStatus',keystroke:{keyCode:34,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay).compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,a.options.monthsToJump)}},current:{text:'currentText',status:'currentStatus',keystroke:{keyCode:36,ctrlKey:true},enabled:function(a){var b=a.curMinDate();var c=a.get('maxDate');var d=a.selectedDates[0]||a.options.calendar.today();return(!b||d.compareTo(b)!==-1)&&(!c||d.compareTo(c)!==+1)},date:function(a){return a.selectedDates[0]||a.options.calendar.today()},action:function(a){var b=a.selectedDates[0]||a.options.calendar.today();I.showMonth(this,b.year(),b.month())}},today:{text:'todayText',status:'todayStatus',keystroke:{keyCode:36,ctrlKey:true},enabled:function(a){var b=a.curMinDate();var c=a.get('maxDate');return(!b||a.options.calendar.today().compareTo(b)!==-1)&&(!c||a.options.calendar.today().compareTo(c)!==+1)},date:function(a){return a.options.calendar.today()},action:function(a){I.showMonth(this)}},clear:{text:'clearText',status:'clearStatus',keystroke:{keyCode:35,ctrlKey:true},enabled:function(a){return true},date:function(a){return null},action:function(a){I.clear(this)}},close:{text:'closeText',status:'closeStatus',keystroke:{keyCode:27},enabled:function(a){return true},date:function(a){return null},action:function(a){I.hide(this)}},prevWeek:{text:'prevWeekText',status:'prevWeekStatus',keystroke:{keyCode:38,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(-a.options.calendar.daysInWeek(),'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.calendar.daysInWeek(),'d')},action:function(a){I.changeDay(this,-a.options.calendar.daysInWeek())}},prevDay:{text:'prevDayText',status:'prevDayStatus',keystroke:{keyCode:37,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-1,'d')},action:function(a){I.changeDay(this,-1)}},nextDay:{text:'nextDayText',status:'nextDayStatus',keystroke:{keyCode:39,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(1,'d').compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(1,'d')},action:function(a){I.changeDay(this,1)}},nextWeek:{text:'nextWeekText',status:'nextWeekStatus',keystroke:{keyCode:40,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.calendar.daysInWeek(),'d').compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.calendar.daysInWeek(),'d')},action:function(a){I.changeDay(this,a.options.calendar.daysInWeek())}}},defaultOptions:{calendar:$.calendars.instance(),pickerClass:'',showOnFocus:true,showTrigger:null,showAnim:'show',showOptions:{},showSpeed:'normal',popupContainer:null,alignment:'bottom',fixedWeeks:false,firstDay:null,calculateWeek:null,localNumbers:false,monthsToShow:1,monthsOffset:0,monthsToStep:1,monthsToJump:12,useMouseWheel:true,changeMonth:true,yearRange:'c-10:c+10',showOtherMonths:false,selectOtherMonths:false,defaultDate:null,selectDefaultDate:false,minDate:null,maxDate:null,dateFormat:null,autoSize:false,rangeSelect:false,rangeSeparator:' - ',multiSelect:0,multiSeparator:',',onDate:null,onShow:null,onChangeMonthYear:null,onSelect:null,onClose:null,altField:null,altFormat:null,constrainInput:true,commandsAsDateFormat:false,commands:{}},regionalOptions:{'':{renderer:{},prevText:'<Prev',prevStatus:'Show the previous month',prevJumpText:'<<',prevJumpStatus:'Show the previous year',nextText:'Next>',nextStatus:'Show the next month',nextJumpText:'>>',nextJumpStatus:'Show the next year',currentText:'Current',currentStatus:'Show the current month',todayText:'Today',todayStatus:'Show today\'s month',clearText:'Clear',clearStatus:'Clear all the dates',closeText:'Close',closeStatus:'Close the datepicker',yearStatus:'Change the year',earlierText:'  ▲',laterText:'  ▼',monthStatus:'Change the month',weekText:'Wk',weekStatus:'Week of the year',dayStatus:'Select DD, M d, yyyy',defaultStatus:'Select a date',isRTL:false}},_getters:['getDate','isDisabled','isSelectable','retrieveDate'],_disabled:[],_popupClass:'calendars-popup',_triggerClass:'calendars-trigger',_disableClass:'calendars-disable',_monthYearClass:'calendars-month-year',_curMonthClass:'calendars-month-',_anyYearClass:'calendars-any-year',_curDoWClass:'calendars-dow-',_init:function(){this.defaultOptions.commands=this.commands;this.regionalOptions[''].renderer=this.defaultRenderer;this._super()},_instSettings:function(b,c){return{selectedDates:[],drawDate:null,pickingRange:false,inline:($.inArray(b[0].nodeName.toLowerCase(),['div','span'])>-1),get:function(a){if($.inArray(a,['defaultDate','minDate','maxDate'])>-1){return this.options.calendar.determineDate(this.options[a],null,this.selectedDates[0],this.get('dateFormat'),this.getConfig())}if(a==='dateFormat'){return this.options.dateFormat||this.options.calendar.local.dateFormat}return this.options[a]},curMinDate:function(){return(this.pickingRange?this.selectedDates[0]:this.get('minDate'))},getConfig:function(){return{dayNamesShort:this.options.dayNamesShort,dayNames:this.options.dayNames,monthNamesShort:this.options.monthNamesShort,monthNames:this.options.monthNames,calculateWeek:this.options.calculateWeek,shortYearCutoff:this.options.shortYearCutoff}}}},_postAttach:function(a,b){if(b.inline){b.drawDate=I._checkMinMax((b.selectedDates[0]||b.get('defaultDate')||b.options.calendar.today()).newDate(),b);b.prevDate=b.drawDate.newDate();this._update(a[0]);if($.fn.mousewheel){a.mousewheel(this._doMouseWheel)}}else{this._attachments(a,b);a.on('keydown.'+b.name,this._keyDown).on('keypress.'+b.name,this._keyPress).on('keyup.'+b.name,this._keyUp);if(a.attr('disabled')){this.disable(a[0])}}},_optionsChanged:function(b,c,d){if(d.calendar&&d.calendar!==c.options.calendar){var e=function(a){return(typeof c.options[a]==='object'?null:c.options[a])};d=$.extend({defaultDate:e('defaultDate'),minDate:e('minDate'),maxDate:e('maxDate')},d);c.selectedDates=[];c.drawDate=null}var f=c.selectedDates;$.extend(c.options,d);this.setDate(b[0],f,null,false,true);c.pickingRange=false;var g=c.options.calendar;var h=c.get('defaultDate');c.drawDate=this._checkMinMax((h?h:c.drawDate)||h||g.today(),c).newDate();if(!c.inline){this._attachments(b,c)}if(c.inline||c.div){this._update(b[0])}},_attachments:function(a,b){a.off('focus.'+b.name);if(b.options.showOnFocus){a.on('focus.'+b.name,this.show)}if(b.trigger){b.trigger.remove()}var c=b.options.showTrigger;b.trigger=(!c?$([]):$(c).clone().removeAttr('id').addClass(this._triggerClass)[b.options.isRTL?'insertBefore':'insertAfter'](a).click(function(){if(!I.isDisabled(a[0])){I[I.curInst===b?'hide':'show'](a[0])}}));this._autoSize(a,b);var d=this._extractDates(b,a.val());if(d){this.setDate(a[0],d,null,true)}var e=b.get('defaultDate');if(b.options.selectDefaultDate&&e&&b.selectedDates.length===0){this.setDate(a[0],(e||b.options.calendar.today()).newDate())}},_autoSize:function(d,e){if(e.options.autoSize&&!e.inline){var f=e.options.calendar;var g=f.newDate(2009,10,20);var h=e.get('dateFormat');if(h.match(/[DM]/)){var j=function(a){var b=0;var c=0;for(var i=0;i<a.length;i++){if(a[i].length>b){b=a[i].length;c=i}}return c};g.month(j(f.local[h.match(/MM/)?'monthNames':'monthNamesShort'])+1);g.day(j(f.local[h.match(/DD/)?'dayNames':'dayNamesShort'])+20-g.dayOfWeek())}e.elem.attr('size',g.formatDate(h,{localNumbers:e.options.localnumbers}).length)}},_preDestroy:function(a,b){if(b.trigger){b.trigger.remove()}a.empty().off('.'+b.name);if(b.inline&&$.fn.mousewheel){a.unmousewheel()}if(!b.inline&&b.options.autoSize){a.removeAttr('size')}},multipleEvents:function(b){var c=arguments;return function(a){for(var i=0;i<c.length;i++){c[i].apply(this,arguments)}}},enable:function(b){b=$(b);if(!b.hasClass(this._getMarker())){return}var c=this._getInst(b);if(c.inline){b.children('.'+this._disableClass).remove().end().find('button,select').prop('disabled',false).end().find('a').attr('href','javascript:void(0)')}else{b.prop('disabled',false);c.trigger.filter('button.'+this._triggerClass).prop('disabled',false).end().filter('img.'+this._triggerClass).css({opacity:'1.0',cursor:''})}this._disabled=$.map(this._disabled,function(a){return(a===b[0]?null:a)})},disable:function(b){b=$(b);if(!b.hasClass(this._getMarker())){return}var c=this._getInst(b);if(c.inline){var d=b.children(':last');var e=d.offset();var f={left:0,top:0};d.parents().each(function(){if($(this).css('position')==='relative'){f=$(this).offset();return false}});var g=b.css('zIndex');g=(g==='auto'?0:parseInt(g,10))+1;b.prepend('<div class="'+this._disableClass+'" style="'+'width: '+d.outerWidth()+'px; height: '+d.outerHeight()+'px; left: '+(e.left-f.left)+'px; top: '+(e.top-f.top)+'px; z-index: '+g+'"></div>').find('button,select').prop('disabled',true).end().find('a').removeAttr('href')}else{b.prop('disabled',true);c.trigger.filter('button.'+this._triggerClass).prop('disabled',true).end().filter('img.'+this._triggerClass).css({opacity:'0.5',cursor:'default'})}this._disabled=$.map(this._disabled,function(a){return(a===b[0]?null:a)});this._disabled.push(b[0])},isDisabled:function(a){return(a&&$.inArray(a,this._disabled)>-1)},show:function(a){a=$(a.target||a);var b=I._getInst(a);if(I.curInst===b){return}if(I.curInst){I.hide(I.curInst,true)}if(!$.isEmptyObject(b)){b.lastVal=null;b.selectedDates=I._extractDates(b,a.val());b.pickingRange=false;b.drawDate=I._checkMinMax((b.selectedDates[0]||b.get('defaultDate')||b.options.calendar.today()).newDate(),b);b.prevDate=b.drawDate.newDate();I.curInst=b;I._update(a[0],true);var c=I._checkOffset(b);b.div.css({left:c.left,top:c.top});var d=b.options.showAnim;var e=b.options.showSpeed;e=(e==='normal'&&$.ui&&parseInt($.ui.version.substring(2))>=8?'_default':e);if($.effects&&($.effects[d]||($.effects.effect&&$.effects.effect[d]))){var f=b.div.data();for(var g in f){if(g.match(/^ec\.storage\./)){f[g]=b._mainDiv.css(g.replace(/ec\.storage\./,''))}}b.div.data(f).show(d,b.options.showOptions,e)}else{b.div[d||'show'](d?e:0)}}},_extractDates:function(a,b){if(b===a.lastVal){return}a.lastVal=b;b=b.split(a.options.multiSelect?a.options.multiSeparator:(a.options.rangeSelect?a.options.rangeSeparator:'\x00'));var c=[];for(var i=0;i<b.length;i++){try{var d=a.options.calendar.parseDate(a.get('dateFormat'),b[i]);if(d){var f=false;for(var j=0;j<c.length;j++){if(c[j].compareTo(d)===0){f=true;break}}if(!f){c.push(d)}}}catch(e){}}c.splice(a.options.multiSelect||(a.options.rangeSelect?2:1),c.length);if(a.options.rangeSelect&&c.length===1){c[1]=c[0]}return c},_update:function(a,b){a=$(a.target||a);var c=I._getInst(a);if(!$.isEmptyObject(c)){if(c.inline||I.curInst===c){if($.isFunction(c.options.onChangeMonthYear)&&(!c.prevDate||c.prevDate.year()!==c.drawDate.year()||c.prevDate.month()!==c.drawDate.month())){c.options.onChangeMonthYear.apply(a[0],[c.drawDate.year(),c.drawDate.month()])}}if(c.inline){var d=$('a, :input',a).index($(':focus',a));a.html(this._generateContent(a[0],c));var e=a.find('a, :input');e.eq(Math.max(Math.min(d,e.length-1),0)).focus()}else if(I.curInst===c){if(!c.div){c.div=$('<div></div>').addClass(this._popupClass).css({display:(b?'none':'static'),position:'absolute',left:a.offset().left,top:a.offset().top+a.outerHeight()}).appendTo($(c.options.popupContainer||'body'));if($.fn.mousewheel){c.div.mousewheel(this._doMouseWheel)}}c.div.html(this._generateContent(a[0],c));a.focus()}}},_updateInput:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d='';var e='';var f=(c.options.multiSelect?c.options.multiSeparator:c.options.rangeSeparator);var g=c.options.calendar;var h=c.get('dateFormat');var j=c.options.altFormat||h;var k={localNumbers:c.options.localNumbers};for(var i=0;i<c.selectedDates.length;i++){d+=(b?'':(i>0?f:'')+g.formatDate(h,c.selectedDates[i],k));e+=(i>0?f:'')+g.formatDate(j,c.selectedDates[i],k)}if(!c.inline&&!b){$(a).val(d)}$(c.options.altField).val(e);if($.isFunction(c.options.onSelect)&&!b&&!c.inSelect){c.inSelect=true;c.options.onSelect.apply(a,[c.selectedDates]);c.inSelect=false}}},_getBorders:function(b){var c=function(a){return{thin:1,medium:3,thick:5}[a]||a};return[parseFloat(c(b.css('border-left-width'))),parseFloat(c(b.css('border-top-width')))]},_checkOffset:function(a){var b=(a.elem.is(':hidden')&&a.trigger?a.trigger:a.elem);var c=b.offset();var d=$(window).width();var e=$(window).height();if(d===0){return c}var f=false;$(a.elem).parents().each(function(){f|=$(this).css('position')==='fixed';return!f});var g=document.documentElement.scrollLeft||document.body.scrollLeft;var h=document.documentElement.scrollTop||document.body.scrollTop;var i=c.top-(f?h:0)-a.div.outerHeight();var j=c.top-(f?h:0)+b.outerHeight();var k=c.left-(f?g:0);var l=c.left-(f?g:0)+b.outerWidth()-a.div.outerWidth();var m=(c.left-g+a.div.outerWidth())>d;var n=(c.top-h+a.elem.outerHeight()+a.div.outerHeight())>e;a.div.css('position',f?'fixed':'absolute');var o=a.options.alignment;if(o==='topLeft'){c={left:k,top:i}}else if(o==='topRight'){c={left:l,top:i}}else if(o==='bottomLeft'){c={left:k,top:j}}else if(o==='bottomRight'){c={left:l,top:j}}else if(o==='top'){c={left:(a.options.isRTL||m?l:k),top:i}}else{c={left:(a.options.isRTL||m?l:k),top:(n?i:j)}}c.left=Math.max((f?0:g),c.left);c.top=Math.max((f?0:h),c.top);return c},_checkExternalClick:function(a){if(!I.curInst){return}var b=$(a.target);if(b.closest('.'+I._popupClass+',.'+I._triggerClass).length===0&&!b.hasClass(I._getMarker())){I.hide(I.curInst)}},hide:function(a,b){if(!a){return}var c=this._getInst(a);if($.isEmptyObject(c)){c=a}if(c&&c===I.curInst){var d=(b?'':c.options.showAnim);var e=c.options.showSpeed;e=(e==='normal'&&$.ui&&parseInt($.ui.version.substring(2))>=8?'_default':e);var f=function(){if(!c.div){return}c.div.remove();c.div=null;I.curInst=null;if($.isFunction(c.options.onClose)){c.options.onClose.apply(a,[c.selectedDates])}};c.div.stop();if($.effects&&($.effects[d]||($.effects.effect&&$.effects.effect[d]))){c.div.hide(d,c.options.showOptions,e,f)}else{var g=(d==='slideDown'?'slideUp':(d==='fadeIn'?'fadeOut':'hide'));c.div[g]((d?e:''),f)}if(!d){f()}}},_keyDown:function(a){var b=(a.data&&a.data.elem)||a.target;var c=I._getInst(b);var d=false;if(c.inline||c.div){if(a.keyCode===9){I.hide(b)}else if(a.keyCode===13){I.selectDate(b,$('a.'+c.options.renderer.highlightedClass,c.div)[0]);d=true}else{var e=c.options.commands;for(var f in e){var g=e[f];if(g.keystroke.keyCode===a.keyCode&&!!g.keystroke.ctrlKey===!!(a.ctrlKey||a.metaKey)&&!!g.keystroke.altKey===a.altKey&&!!g.keystroke.shiftKey===a.shiftKey){I.performAction(b,f);d=true;break}}}}else{var g=c.options.commands.current;if(g.keystroke.keyCode===a.keyCode&&!!g.keystroke.ctrlKey===!!(a.ctrlKey||a.metaKey)&&!!g.keystroke.altKey===a.altKey&&!!g.keystroke.shiftKey===a.shiftKey){I.show(b);d=true}}c.ctrlKey=((a.keyCode<48&&a.keyCode!==32)||a.ctrlKey||a.metaKey);if(d){a.preventDefault();a.stopPropagation()}return!d},_keyPress:function(a){var b=I._getInst((a.data&&a.data.elem)||a.target);if(!$.isEmptyObject(b)&&b.options.constrainInput){var c=String.fromCharCode(a.keyCode||a.charCode);var d=I._allowedChars(b);return(a.metaKey||b.ctrlKey||c<' '||!d||d.indexOf(c)>-1)}return true},_allowedChars:function(a){var b=(a.options.multiSelect?a.options.multiSeparator:(a.options.rangeSelect?a.options.rangeSeparator:''));var c=false;var d=false;var e=a.get('dateFormat');for(var i=0;i<e.length;i++){var f=e.charAt(i);if(c){if(f==="'"&&e.charAt(i+1)!=="'"){c=false}else{b+=f}}else{switch(f){case'd':case'm':case'o':case'w':b+=(d?'':'0123456789');d=true;break;case'y':case'@':case'!':b+=(d?'':'0123456789')+'-';d=true;break;case'J':b+=(d?'':'0123456789')+'-.';d=true;break;case'D':case'M':case'Y':return null;case"'":if(e.charAt(i+1)==="'"){b+="'"}else{c=true}break;default:b+=f}}}return b},_keyUp:function(a){var b=(a.data&&a.data.elem)||a.target;var c=I._getInst(b);if(!$.isEmptyObject(c)&&!c.ctrlKey&&c.lastVal!==c.elem.val()){try{var d=I._extractDates(c,c.elem.val());if(d.length>0){I.setDate(b,d,null,true)}}catch(a){}}return true},_doMouseWheel:function(a,b){var c=(I.curInst&&I.curInst.elem[0])||$(a.target).closest('.'+I._getMarker())[0];if(I.isDisabled(c)){return}var d=I._getInst(c);if(d.options.useMouseWheel){b=(b<0?-1:+1);I.changeMonth(c,-d.options[a.ctrlKey?'monthsToJump':'monthsToStep']*b)}a.preventDefault()},clear:function(a){var b=this._getInst(a);if(!$.isEmptyObject(b)){b.selectedDates=[];this.hide(a);var c=b.get('defaultDate');if(b.options.selectDefaultDate&&c){this.setDate(a,(c||b.options.calendar.today()).newDate())}else{this._updateInput(a)}}},getDate:function(a){var b=this._getInst(a);return(!$.isEmptyObject(b)?b.selectedDates:[])},setDate:function(a,b,c,d,e){var f=this._getInst(a);if(!$.isEmptyObject(f)){if(!$.isArray(b)){b=[b];if(c){b.push(c)}}var g=f.get('minDate');var h=f.get('maxDate');var k=f.selectedDates[0];f.selectedDates=[];for(var i=0;i<b.length;i++){var l=f.options.calendar.determineDate(b[i],null,k,f.get('dateFormat'),f.getConfig());if(l){if((!g||l.compareTo(g)!==-1)&&(!h||l.compareTo(h)!==+1)){var m=false;for(var j=0;j<f.selectedDates.length;j++){if(f.selectedDates[j].compareTo(l)===0){m=true;break}}if(!m){f.selectedDates.push(l)}}}}f.selectedDates.splice(f.options.multiSelect||(f.options.rangeSelect?2:1),f.selectedDates.length);if(f.options.rangeSelect){switch(f.selectedDates.length){case 1:f.selectedDates[1]=f.selectedDates[0];break;case 2:f.selectedDates[1]=(f.selectedDates[0].compareTo(f.selectedDates[1])===+1?f.selectedDates[0]:f.selectedDates[1]);break}f.pickingRange=false}f.prevDate=(f.drawDate?f.drawDate.newDate():null);f.drawDate=this._checkMinMax((f.selectedDates[0]||f.get('defaultDate')||f.options.calendar.today()).newDate(),f);if(!e){this._update(a);this._updateInput(a,d)}}},isSelectable:function(a,b){var c=this._getInst(a);if($.isEmptyObject(c)){return false}b=c.options.calendar.determineDate(b,c.selectedDates[0]||c.options.calendar.today(),null,c.options.dateFormat,c.getConfig());return this._isSelectable(a,b,c.options.onDate,c.get('minDate'),c.get('maxDate'))},_isSelectable:function(a,b,c,d,e){var f=(typeof c==='boolean'?{selectable:c}:(!$.isFunction(c)?{}:c.apply(a,[b,true])));return(f.selectable!==false)&&(!d||b.toJD()>=d.toJD())&&(!e||b.toJD()<=e.toJD())},performAction:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)&&!this.isDisabled(a)){var d=c.options.commands;if(d[b]&&d[b].enabled.apply(a,[c])){d[b].action.apply(a,[c])}}},showMonth:function(a,b,c,d){var e=this._getInst(a);if(!$.isEmptyObject(e)&&(d!=null||(e.drawDate.year()!==b||e.drawDate.month()!==c))){e.prevDate=e.drawDate.newDate();var f=e.options.calendar;var g=this._checkMinMax((b!=null?f.newDate(b,c,1):f.today()),e);e.drawDate.date(g.year(),g.month(),(d!=null?d:Math.min(e.drawDate.day(),f.daysInMonth(g.year(),g.month()))));this._update(a)}},changeMonth:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d=c.drawDate.newDate().add(b,'m');this.showMonth(a,d.year(),d.month())}},changeDay:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d=c.drawDate.newDate().add(b,'d');this.showMonth(a,d.year(),d.month(),d.day())}},_checkMinMax:function(a,b){var c=b.get('minDate');var d=b.get('maxDate');a=(c&&a.compareTo(c)===-1?c.newDate():a);a=(d&&a.compareTo(d)===+1?d.newDate():a);return a},retrieveDate:function(a,b){var c=this._getInst(a);return($.isEmptyObject(c)?null:c.options.calendar.fromJD(parseFloat(b.className.replace(/^.*jd(\d+\.5).*$/,'$1'))))},selectDate:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)&&!this.isDisabled(a)){var d=this.retrieveDate(a,b);if(c.options.multiSelect){var e=false;for(var i=0;i<c.selectedDates.length;i++){if(d.compareTo(c.selectedDates[i])===0){c.selectedDates.splice(i,1);e=true;break}}if(!e&&c.selectedDates.length<c.options.multiSelect){c.selectedDates.push(d)}}else if(c.options.rangeSelect){if(c.pickingRange){c.selectedDates[1]=d}else{c.selectedDates=[d,d]}c.pickingRange=!c.pickingRange}else{c.selectedDates=[d]}c.prevDate=c.drawDate=d.newDate();this._updateInput(a);if(c.inline||c.pickingRange||c.selectedDates.length<(c.options.multiSelect||(c.options.rangeSelect?2:1))){this._update(a)}else{this.hide(a)}}},_generateContent:function(h,i){var j=i.options.monthsToShow;j=($.isArray(j)?j:[1,j]);i.drawDate=this._checkMinMax(i.drawDate||i.get('defaultDate')||i.options.calendar.today(),i);var k=i.drawDate.newDate().add(-i.options.monthsOffset,'m');var l='';for(var m=0;m<j[0];m++){var n='';for(var o=0;o<j[1];o++){n+=this._generateMonth(h,i,k.year(),k.month(),i.options.calendar,i.options.renderer,(m===0&&o===0));k.add(1,'m')}l+=this._prepare(i.options.renderer.monthRow,i).replace(/\{months\}/,n)}var p=this._prepare(i.options.renderer.picker,i).replace(/\{months\}/,l).replace(/\{weekHeader\}/g,this._generateDayHeaders(i,i.options.calendar,i.options.renderer));var q=function(a,b,c,d,e){if(p.indexOf('{'+a+':'+d+'}')===-1){return}var f=i.options.commands[d];var g=(i.options.commandsAsDateFormat?f.date.apply(h,[i]):null);p=p.replace(new RegExp('\\{'+a+':'+d+'\\}','g'),'<'+b+(f.status?' title="'+i.options[f.status]+'"':'')+' class="'+i.options.renderer.commandClass+' '+i.options.renderer.commandClass+'-'+d+' '+e+(f.enabled(i)?'':' '+i.options.renderer.disabledClass)+'">'+(g?g.formatDate(i.options[f.text],{localNumbers:i.options.localNumbers}):i.options[f.text])+'</'+c+'>')};for(var r in i.options.commands){q('button','button type="button"','button',r,i.options.renderer.commandButtonClass);q('link','a href="javascript:void(0)"','a',r,i.options.renderer.commandLinkClass)}p=$(p);if(j[1]>1){var s=0;$(i.options.renderer.monthSelector,p).each(function(){var a=++s%j[1];$(this).addClass(a===1?'first':(a===0?'last':''))})}var t=this;function removeHighlight(){(i.inline?$(this).closest('.'+t._getMarker()):i.div).find(i.options.renderer.daySelector+' a').removeClass(i.options.renderer.highlightedClass)}p.find(i.options.renderer.daySelector+' a').hover(function(){removeHighlight.apply(this);$(this).addClass(i.options.renderer.highlightedClass)},removeHighlight).click(function(){t.selectDate(h,this)}).end().find('select.'+this._monthYearClass+':not(.'+this._anyYearClass+')').change(function(){var a=$(this).val().split('/');t.showMonth(h,parseInt(a[1],10),parseInt(a[0],10))}).end().find('select.'+this._anyYearClass).click(function(){$(this).css('visibility','hidden').next('input').css({left:this.offsetLeft,top:this.offsetTop,width:this.offsetWidth,height:this.offsetHeight}).show().focus()}).end().find('input.'+t._monthYearClass).change(function(){try{var a=parseInt($(this).val(),10);a=(isNaN(a)?i.drawDate.year():a);t.showMonth(h,a,i.drawDate.month(),i.drawDate.day())}catch(e){alert(e)}}).keydown(function(a){if(a.keyCode===13){$(a.elem).change()}else if(a.keyCode===27){$(a.elem).hide().prev('select').css('visibility','visible');i.elem.focus()}});var u={elem:i.elem[0]};p.keydown(u,this._keyDown).keypress(u,this._keyPress).keyup(u,this._keyUp);p.find('.'+i.options.renderer.commandClass).click(function(){if(!$(this).hasClass(i.options.renderer.disabledClass)){var a=this.className.replace(new RegExp('^.*'+i.options.renderer.commandClass+'-([^ ]+).*$'),'$1');I.performAction(h,a)}});if(i.options.isRTL){p.addClass(i.options.renderer.rtlClass)}if(j[0]*j[1]>1){p.addClass(i.options.renderer.multiClass)}if(i.options.pickerClass){p.addClass(i.options.pickerClass)}$('body').append(p);var v=0;p.find(i.options.renderer.monthSelector).each(function(){v+=$(this).outerWidth()});p.width(v/j[0]);if($.isFunction(i.options.onShow)){i.options.onShow.apply(h,[p,i.options.calendar,i])}return p},_generateMonth:function(b,c,d,e,f,g,h){var j=f.daysInMonth(d,e);var k=c.options.monthsToShow;k=($.isArray(k)?k:[1,k]);var l=c.options.fixedWeeks||(k[0]*k[1]>1);var m=c.options.firstDay;m=(m==null?f.local.firstDay:m);var n=(f.dayOfWeek(d,e,f.minDay)-m+f.daysInWeek())%f.daysInWeek();var o=(l?6:Math.ceil((n+j)/f.daysInWeek()));var p=c.options.selectOtherMonths&&c.options.showOtherMonths;var q=(c.pickingRange?c.selectedDates[0]:c.get('minDate'));var r=c.get('maxDate');var s=g.week.indexOf('{weekOfYear}')>-1;var t=f.today();var u=f.newDate(d,e,f.minDay);u.add(-n-(l&&(u.dayOfWeek()===m||u.daysInMonth()<f.daysInWeek())?f.daysInWeek():0),'d');var v=u.toJD();var w=function(a){return(c.options.localNumbers&&f.local.digits?f.local.digits(a):a)};var x='';for(var y=0;y<o;y++){var z=(!s?'':'<span class="jd'+v+'">'+($.isFunction(c.options.calculateWeek)?c.options.calculateWeek(u):u.weekOfYear())+'</span>');var A='';for(var B=0;B<f.daysInWeek();B++){var C=false;if(c.options.rangeSelect&&c.selectedDates.length>0){C=(u.compareTo(c.selectedDates[0])!==-1&&u.compareTo(c.selectedDates[1])!==+1)}else{for(var i=0;i<c.selectedDates.length;i++){if(c.selectedDates[i].compareTo(u)===0){C=true;break}}}var D=(!$.isFunction(c.options.onDate)?{}:c.options.onDate.apply(b,[u,u.month()===e]));var E=(p||u.month()===e)&&this._isSelectable(b,u,D.selectable,q,r);A+=this._prepare(g.day,c).replace(/\{day\}/g,(E?'<a href="javascript:void(0)"':'<span')+' class="jd'+v+' '+(D.dateClass||'')+(C&&(p||u.month()===e)?' '+g.selectedClass:'')+(E?' '+g.defaultClass:'')+(u.weekDay()?'':' '+g.weekendClass)+(u.month()===e?'':' '+g.otherMonthClass)+(u.compareTo(t)===0&&u.month()===e?' '+g.todayClass:'')+(u.compareTo(c.drawDate)===0&&u.month()===e?' '+g.highlightedClass:'')+'"'+(D.title||(c.options.dayStatus&&E)?' title="'+(D.title||u.formatDate(c.options.dayStatus,{localNumbers:c.options.localNumbers}))+'"':'')+'>'+(c.options.showOtherMonths||u.month()===e?D.content||w(u.day()):' ')+(E?'</a>':'</span>'));u.add(1,'d');v++}x+=this._prepare(g.week,c).replace(/\{days\}/g,A).replace(/\{weekOfYear\}/g,z)}var F=this._prepare(g.month,c).match(/\{monthHeader(:[^\}]+)?\}/);F=(F[0].length<=13?'MM yyyy':F[0].substring(13,F[0].length-1));F=(h?this._generateMonthSelection(c,d,e,q,r,F,f,g):f.formatDate(F,f.newDate(d,e,f.minDay),{localNumbers:c.options.localNumbers}));var G=this._prepare(g.weekHeader,c).replace(/\{days\}/g,this._generateDayHeaders(c,f,g));return this._prepare(g.month,c).replace(/\{monthHeader(:[^\}]+)?\}/g,F).replace(/\{weekHeader\}/g,G).replace(/\{weeks\}/g,x)},_generateDayHeaders:function(a,b,c){var d=a.options.firstDay;d=(d==null?b.local.firstDay:d);var e='';for(var f=0;f<b.daysInWeek();f++){var g=(f+d)%b.daysInWeek();e+=this._prepare(c.dayHeader,a).replace(/\{day\}/g,'<span class="'+this._curDoWClass+g+'" title="'+b.local.dayNames[g]+'">'+b.local.dayNamesMin[g]+'</span>')}return e},_generateMonthSelection:function(b,c,d,e,f,g,h){if(!b.options.changeMonth){return h.formatDate(g,h.newDate(c,d,1),{localNumbers:b.options.localNumbers})}var i=h.local['monthNames'+(g.match(/mm/i)?'':'Short')];var j=g.replace(/m+/i,'\\x2E').replace(/y+/i,'\\x2F');var k='<select class="'+this._monthYearClass+'" title="'+b.options.monthStatus+'">';var l=h.monthsInYear(c)+h.minMonth;for(var m=h.minMonth;m<l;m++){if((!e||h.newDate(c,m,h.daysInMonth(c,m)-1+h.minDay).compareTo(e)!==-1)&&(!f||h.newDate(c,m,h.minDay).compareTo(f)!==+1)){k+='<option value="'+m+'/'+c+'"'+(d===m?' selected="selected"':'')+'>'+i[m-h.minMonth]+'</option>'}}k+='</select>';j=j.replace(/\\x2E/,k);var n=b.options.yearRange;if(n==='any'){k='<select class="'+this._monthYearClass+' '+this._anyYearClass+'" title="'+b.options.yearStatus+'">'+'<option>'+c+'</option></select>'+'<input class="'+this._monthYearClass+' '+this._curMonthClass+d+'" value="'+c+'">'}else{n=n.split(':');var o=h.today().year();var p=(n[0].match('c[+-].*')?c+parseInt(n[0].substring(1),10):((n[0].match('[+-].*')?o:0)+parseInt(n[0],10)));var q=(n[1].match('c[+-].*')?c+parseInt(n[1].substring(1),10):((n[1].match('[+-].*')?o:0)+parseInt(n[1],10)));k='<select class="'+this._monthYearClass+'" title="'+b.options.yearStatus+'">';p=h.newDate(p+1,h.firstMonth,h.minDay).add(-1,'d');q=h.newDate(q,h.firstMonth,h.minDay);var r=function(y,a){if(y!==0||h.hasYearZero){k+='<option value="'+Math.min(d,h.monthsInYear(y)-1+h.minMonth)+'/'+y+'"'+(c===y?' selected="selected"':'')+'>'+(a||y)+'</option>'}};if(p.toJD()<q.toJD()){p=(e&&e.compareTo(p)===+1?e:p).year();q=(f&&f.compareTo(q)===-1?f:q).year();var s=Math.floor((q-p)/2);if(!e||e.year()<p){r(p-s,b.options.earlierText)}for(var y=p;y<=q;y++){r(y)}if(!f||f.year()>q){r(q+s,b.options.laterText)}}else{p=(f&&f.compareTo(p)===-1?f:p).year();q=(e&&e.compareTo(q)===+1?e:q).year();var s=Math.floor((p-q)/2);if(!f||f.year()>p){r(p+s,b.options.earlierText)}for(var y=p;y>=q;y--){r(y)}if(!e||e.year()<q){r(q-s,b.options.laterText)}}k+='</select>'}j=j.replace(/\\x2F/,k);return j},_prepare:function(e,f){var g=function(a,b){while(true){var c=e.indexOf('{'+a+':start}');if(c===-1){return}var d=e.substring(c).indexOf('{'+a+':end}');if(d>-1){e=e.substring(0,c)+(b?e.substr(c+a.length+8,d-a.length-8):'')+e.substring(c+d+a.length+6)}}};g('inline',f.inline);g('popup',!f.inline);var h=/\{l10n:([^\}]+)\}/;var i=null;while(i=h.exec(e)){e=e.replace(i[0],f.options[i[1]])}return e}});var I=$.calendarsPicker;$(function(){$(document).on('mousedown.'+H,I._checkExternalClick).on('resize.'+H,function(){I.hide(I.curInst)})})})(jQuery);