":if(l>n){o=true}break}return o},_setSection:function(n,m,l,s){var r=n,q=Date.parse(m),p=Date.parse(l),o=Date.parse(s);if(q>=p&&q<=o){r=true}return r},_isSelectable:function(x,w,o,u){var s=true,r=this._parseDate(this.options.min,this.format),z=this._parseDate(this.options.max,this.format),t=this._parseDateArr(this.options.selectableDate,this.format),B=this._parseDateSection(this.options.selectableYear),n=this._parseDateSection(this.options.selectableMonth),q=this._parseDateSection(this.options.selectableDay),l=this._parseDateSection(this.options.selectableDayOfWeek);var p,C,v,A;switch(x){case"years":p=new Date(w,0,1);C=new Date(w+1,0,0);v=[p,C];A=false;break;case"months":p=new Date(w,o,1);C=new Date(w,o+1,0);v=[p,C];A=false;break;case"days":p=C=v=new Date(w,o,u);A=true;break}if(r&&r>C){s=false}if(z&&z0){s=this._judgeSections("date",v,t,A)}if(s&&B.length>0){s=this._judgeSections("block",w,B)}if(x==="months"||x==="days"){if(s&&n.length>0){s=this._judgeSections("block",o,n)}}if(x==="days"){if(s&&q.length>0){s=this._judgeSections("block",u,q)}if(s&&l.length>0){s=this._judgeSections("dayOfWeek",new Date(w,o,u),l)}}return s},_renderStatus:function(m){var l=m[0],p=m[1],q=m[2],n=m[3],o="";if(n===true){o=" "+this.namespace+"_untouchable"}else{if(l===true){o=" "+this.namespace+"_untouchable"}if(q===true){o+=" "+this.namespace+"_inRange"}}if(p===true){o+=" "+this.namespace+"_active"}return o},_changeView:function(m,l){switch(m){case"caption":if(this.options.mode!=="multiple"){if(this.views[l]==="days"){this.views[l]="months"}else{if(this.views[l]==="months"){this.views[l]="years"}}}break;case"content":if(this.views[l]==="years"){this.views[l]="months"}else{if(this.views[l]==="months"){this.views[l]="days"}}break;case"higher":if(this.options.mode!=="multiple"){if(this.views[l]==="days"){this.views[l]="months"}else{if(this.views[l]==="months"){this.views[l]="years"}}}break;case"lower":if(this.options.mode!=="multiple"){if(this.views[l]==="years"){this.views[l]="months"}else{if(this.views[l]==="months"){this.views[l]="days"}}}break}},_setDate:function(o,n,l){if(typeof n==="object"){for(var m in n){switch(m){case"day":o.setDate(n[m]);break;case"month":o.setMonth(n[m]);break;case"year":o.setYear(n[m]);break}}}else{switch(n){case"day":o.setDate(l);break;case"month":o.setMonth(l);break;case"year":o.setYear(l);break}}},_formatDate:function(l,o){l=new Date(l);var p={d:l.getDate(),m:l.getMonth()+1,yy:l.getFullYear().toString().substring(2),yyyy:l.getFullYear()};p.dd=(p.d<10?"0":"")+p.d;p.mm=(p.m<10?"0":"")+p.m;l=[];for(var m=0,n=o.parts.length;m");if(l.length>1){l={from:l[0],to:l[1]}}else{l=l[0]}r.push(l)}return r}else{return p}},_parseFormat:function(n){var m=n.match(/[.\/\-\s].*?/),l=n.split(/\W+/)||l;if(!l||l.length===0){throw new Error("Invalid date format.")}return{separator:m,parts:l}},_parseDate:function(p,r){if(p!==null){var m=new Date(),l=m.getDate();switch(typeof(p)){case"string":if(p.length<5){m.setHours(0,0,0,0);m.setDate(l+Number(p))}else{var q=p.split(r.separator)||q,s;m.setHours(0,0,0,0);if(q.length===r.parts.length){for(var n=0,o=r.parts.length;n(n)){if(r==="bottom"){r="top"}else{if(r="left"){r="leftTop"}else{if(r="right"){r="rightTop"}}}}break;case"top":case"rightTop":case"leftTop":if(l-x<0){if(r==="top"){r="bottom"}else{if(r="leftTop"){r="left"}else{if(r="rightTop"){r="right"}}}}break}switch(r){case"top":m=u+t;w=l-x;break;case"right":m=u+s+t;w=l;break;case"bottom":m=u+t;w=l+q;break;case"left":m=u-v+t;w=l;break;case"rightTop":m=u+s+t;w=l-x+q;break;case"leftTop":m=u-v+t;w=l-x+q;break}}this.$picker.css({left:m,top:w})},_toggle:function(){if(this.showed){this.pickerHide=true;this._blur()}else{this._focus()}},_focus:function(){if(this.options.displayMode==="dropdown"&&this.showed===false){this.show()}if(this.hasKeyboard){this._keyboard.init(this)}},_blur:function(){if(this.options.displayMode==="dropdown"){if(this.pickerHide===true){this.hide();this.pickerHide=false}}if(this.hasKeyboard){this._keyboard.destroy(this)}},_trigger:function(m){var o=arguments.length>1?Array.prototype.slice.call(arguments,1).push(this):this;this.$el.trigger(h+"::"+m,o);m=m.replace(/\b\w+\b/g,function(p){return p.substring(0,1).toUpperCase()+p.substring(1)});var n="on"+m;var l=arguments.length>1?Array.prototype.slice.call(arguments,1):b;if(typeof this.options[n]==="function"){this.options[n].apply(this,l)}},_click:function(s){var l=e(s.target);if(l.closest(this.$inputIcon).length===0&&l.closest(this.$picker).length===0&&l.closest(this.$el).length===0&&this.options.alwaysShow===false){if(this.isMobile){this.mobileCancel(0)}else{this.hide()}}else{if(l.closest(this.$el).length!==1&&l.closest(this.$picker).length===1){var n=e(s.target).closest("div");var q=e(s.target).closest("span");if(n.parent("."+this.namespace+"-header").length===1){var r=n.parents("."+this.namespace+"-content").index();switch(n[0].className){case this.namespace+"-caption":this._changeView("caption",r);this._manageViews(r);break;case this.namespace+"-prev":this.prev(r);break;case this.namespace+"-next":this.next(r);break}}if(q.length===1){var p=q.parents("."+this.namespace+"-content").index();if(!q.hasClass(this.namespace+"_otherMonth")&&!q.hasClass(this.namespace+"_untouchable")&&q.parent("."+this.namespace+"-head").length!==1){this._changeValue(q,p);this._changeView("content",p);this._updateDate(p);switch(this.mode){case"single":if(this.views[p]==="days"){this.selected=true}this._manageViews(p);break;case"range":this._manageViews(0);this._manageViews(1);break;case"multiple":this._manageViews(p-1);this._manageViews(p);this._manageViews(p+1);break}if(!this.isMobile){this._setValue()}}}if(n.parent("."+this.namespace+"-buttons").length===1){var o=n.parents("."+this.namespace+"-content").index(),m=n[0].className===this.namespace+"-button-save"?true:false;if(m){this.mobileEnter(o)}else{this.mobileCancel(o)}}if(!this.isMobile){if(this.selected===true&&this.options.alwaysShow===false&&this.options.onceClick===true){this.hide()}else{if(this.options.displayMode==="dropdown"){this.$el.focus()}}}}}s.preventDefault()},_changeValue:function(q,p){var o="",l="",m=this;switch(this.views[p]){case"years":o=parseInt(q.text(),10);this._date.currentDate[p].setYear(o);break;case"months":o=Number(q.attr("class").match(/month\-([0-9]+)/)[1]);this._date.currentDate[p].setMonth(o);break;case"days":o=parseInt(q.text(),10);l=new Date(this._date.currentYear[p],this._date.currentMonth[p],o,0,0,0,0);switch(this.options.mode){case"single":case"range":this._date.selectedDate[p]=l;break;case"multiple":var n=Date.parse(l);if(e.inArray(n,this._date.selectedDate)>-1){e.each(this._date.selectedDate,function(r,s){if(s===n){m._date.selectedDate.splice(r,1)}})}else{if(this._date.selectedDate.lengthm){this._date.focusDate.setDate(m)}this._date.focusDate.setMonth(this._date.focusDate.getMonth()-1);for(var l=0;lm){this._date.focusDate[q].setDate(m)}this._date.focusDate[q]=new Date(o.getFullYear(),o.getMonth(),this._date.focusDate[q].getDate(),0,0,0,0)}}break;case"months":o.setYear(this._date.currentYear[q]-1);if(this.hasKeyboard){this._date.focusDate[q]=new Date(o.getFullYear(),this._date.focusDate[q].getMonth(),this._date.focusDate[q].getDate(),0,0,0,0)}break;case"years":o.setYear(this._date.currentYear[q]-12);if(this.hasKeyboard&&p){this._date.focusDate[q]=new Date(this._date.focusDate[q].getFullYear()-12,this._date.focusDate[q].getMonth(),this._date.focusDate[q].getDate(),0,0,0,0)}break}this._updateDate(q);this._manageViews(q)},next:function(p,o){this.touchflag=false;var n=this._date.currentDate[p];switch(this.views[p]){case"days":var q;if(this.mode==="multiple"){if(o){if(this.focused===this.calendarsNum-1){for(var m=0;mq){this._date.focusDate.setDate(q)}this._date.focusDate.setMonth(this._date.focusDate.getMonth()+1);for(var l=0;lq){this._date.focusDate[p].setDate(q)}this._date.focusDate[p]=new Date(n.getFullYear(),n.getMonth(),this._date.focusDate[p].getDate(),0,0,0,0)}}break;case"months":n.setYear(this._date.currentYear[p]+1);if(this.hasKeyboard){this._date.focusDate[p]=new Date(n.getFullYear(),this._date.focusDate[p].getMonth(),this._date.focusDate[p].getDate(),0,0,0,0)}break;case"years":n.setYear(this._date.currentYear[p]+12);if(this.hasKeyboard&&o){this._date.focusDate[p]=new Date(this._date.focusDate[p].getFullYear()+12,this._date.focusDate[p].getMonth(),this._date.focusDate[p].getDate(),0,0,0,0)}break}this._updateDate(p);this._manageViews(p)},mobilePrev:function(l){this.calendars.eq(l).removeClass(this.namespace+"_show");this.calendars.eq(l-1).addClass(this.namespace+"_show")},mobileNext:function(l){this.calendars.eq(l).removeClass(this.namespace+"_show");this.calendars.eq(l+1).addClass(this.namespace+"_show")},mobileInteDate:function(m){var l=this;if(this.mode==="multiple"){if(this._date.selectedDate.length>0){l._date.currentDate[0]=new Date(this._date.selectedDate[0])}}else{this._date.currentDate[m]=new Date(this._date.selectedDate[m])}this.views[m]="days";this._updateDate(m)},mobileEnter:function(l){if(this.mode==="range"&&l===0){this.mobileNext(l);this.views[l]="days"}else{this.mobileInteDate(l);this._setValue();this.hide()}this._manageViews(l)},mobileCancel:function(l){if(l===1){this.mobilePrev(l);this.views[l]="days"}else{this.dateTransform(this._date.cache,this._date);this.mobileInteDate(l);this.hide()}this._manageViews(l)},dateTransform:function(n,m){var l=this;m.currentDate=[];m.selectedDate=[];e.each(n.currentDate,function(p,o){m.currentDate[p]=new Date(o)});e.each(n.selectedDate,function(q,o){var p=new Date(o);m.selectedDate[q]=l.mode==="multiple"?Date.parse(p):p})},show:function(){var l=this;if(this.isMobile){this.dateTransform(this._date,this._date.cache)}if(this.options.displayMode==="inline"){this._trigger("beforeShow");this.$picker.on("mouseDown."+this.flag,function(n){l._prevent(n)});this.$picker.on("click."+this.flag,function(n){l._click.call(l,n)})}else{if(this.showed===false){this._trigger("beforeShow");this.$inputWrap.addClass(this.namespace+"_active");this.$picker.addClass(this.namespace+"_show");if(this.isMobile){this.calendars.eq(0).addClass(this.namespace+"_show");if(this.mode==="range"){this.calendars.eq(1).removeClass(this.namespace+"_show")}e("body").append(this.$cover).css("overflow","hidden");d.on("scrollstart."+this.flag,function(n){n.preventDefault()});d.on("tap."+this.flag,function(n){l._click.call(l,n)});var m=function(p){var o=p.swipestart.coords[0],n=p.swipestop.coords[0];if(n>o){l.prev.call(l,0)}else{if(nthis._date.currentYear[m]+1){if(!n){l.setFullYear(l.getFullYear()+3);this.next(m)}}else{l.setFullYear(l.getFullYear()+3);this._manageViews(m)}break}},prevPage:function(){if(this.mode==="multiple"){this.prev(this.focused)}else{if(!this.calendarPrevs.eq(this.focused).hasClass(this.namespace+"_blocked")){this.prev(this.focused,true)}}},nextPage:function(){if(this.mode==="multiple"){this.next(this.focused)}else{if(!this.calendarNexts.eq(this.focused).hasClass(this.namespace+"_blocked")){this.next(this.focused,true)}}},higherView:function(){if(this.mode!=="multiple"){var l=this.focused;this._changeView("higher",l);this._manageViews(l)}},prevCalendar:function(){if(this.mode!=="multiple"){var l=this.calendars.length;if(--this.focused<0){this.focused=l}}},nextCalendar:function(){if(this.mode!=="multiple"){var l=this.calendars.length;if(++this.focused>=l){this.focused=0}}},updateValue:function(m){var o=m.focused,n=m.mode==="multiple"?m._date.focusDate:m._date.focusDate[o];if(!m.calendars.eq(o).find("."+m.namespace+"_focus").hasClass(m.namespace+"_untouchable")){switch(m.views[o]){case"days":switch(m.options.mode){case"single":case"range":m._date.selectedDate[o]=new Date(n);break;case"multiple":var l=Date.parse(new Date(n));if(e.inArray(l,m._date.selectedDate)>-1){e.each(m._date.selectedDate,function(p,q){if(q===l){m._date.selectedDate.splice(p,1);return false}})}else{m._date.selectedDate.push(l)}break}break;case"months":m._date.currentDate[o].setMonth(n.getMonth());m.views[o]="days";break;case"years":m._date.currentDate[o].setFullYear(n.getFullYear());m.views[o]="months";break}m._updateDate(o);if(m.mode==="range"){m._manageViews(0);m._manageViews(1)}else{if(m.mode==="multiple"){m._manageViews(o-1);m._manageViews(o);m._manageViews(o+1)}else{m._manageViews(o)}}m._setValue()}},enter:function(){var n=this.$el.val(),w=this,t;if(n===this.oldValue||this.oldValue===""){this._keyboard.updateValue(this)}else{var q;switch(this.mode){case"single":var x=Date.parse(n);if(x){this._date.selectedDate[0]=new Date(x);this._date.currentDate[0]=new Date(this._date.selectedDate[0]);this._updateDate(0);this._manageViews(0)}break;case"range":q=this._stringSeparate(n,this.options.rangeSeparator);var u=Date.parse(q[0]),v=Date.parse(q[1]);if(q.length===2){t=true;if(u&&v){if(u>v){t=false}}else{t=false}}else{t=false}if(t===true){this._date.selectedDate[0]=new Date(u);this._date.selectedDate[1]=new Date(v);for(var r=0;r<2;r++){this._date.currentDate[r]=new Date(this._date.selectedDate[r]);this._updateDate(r);this._manageViews(r)}}else{this._keyboard.updateValue(this)}break;case"multiple":q=this._stringSeparate(n,this.options.multipleSeparator);var s=[];t=true;for(var p=0;p-1){e.each(this._date.selectedDate,function(m,y){if(y===s[o]){w._date.selectedDate.splice(m,1)}})}else{this._date.selectedDate.push(s[o])}}for(var l=0;l