/*! asDatepicker - v0.4.1 - 2014-12-24 * https://github.com/amazingSurge/jquery-asDatepicker * Copyright (c) 2014 amazingSurge; Licensed MIT */ !function(a,b,c,d){"use strict";var e="asDatepicker",f={firstDayOfWeek:0,mode:"single",displayMode:"dropdown",calendars:1,date:"today",keyboard:!0,rangeSeparator:"to",multipleSeparator:",",multipleSize:5,container:"body",position:"bottom",alwaysShow:!1,onceClick:!1,min:null,max:null,selectableDate:[],selectableYear:[],selectableMonth:[],selectableDay:[],selectableDayOfWeek:[],lang:"en",views:["days"],outputFormat:"yyyy/mm/dd",mobileMode:!1,namespace:"calendar",tplInputWrapper:function(){return'
'},tplWrapper:function(){return'
'},tplContent:function(){return'
<
>
'},tplTitle:function(){return'
test
'},onInit:null,onReady:null,onRender:null,onChange:null,onBeforeShow:null,onShow:null,onBeforeHide:null,onHide:null},g=a(b),h=a(c),i={},j=0,k=a[e]=function(b,c){var d=this,e=a(b).data();this.$el=a(b),this.defaultOptions=a.extend(!0,{},f,c,e),this.options=a.extend(!0,{},f,c,e),a.each(e,function(a,b){d.options[a]=d._parseHtmlString(a,b),d.defaultOptions[a]=d._parseHtmlString(a,b)}),this.namespace=this.options.namespace,this.$inputWrap=this.$el.addClass(this.namespace+"-input").wrap(this.options.tplInputWrapper().replace(/namespace/g,this.namespace)).parent(),this.$inputIcon=a(''),this.$inputIcon.appendTo(this.$inputWrap),this.$container=a(this.options.container),this._trigger("init"),this._init()};k.LABEL=i,k.localize=function(a,b){i[a]=b},k.localize("en",{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],buttons:["Cancel","Save"]}),k.prototype={constructor:k,_init:function(){this.mode=this.options.mode,this.format=this._parseFormat("yyyy-mm-dd"),this.outputFormat=this._parseFormat(this.options.outputFormat||"yyyy/mm/dd"),this.focused=0,this.flag=j++,this.pickerHide=!1,this.selected=!1,this.showed=!1,this.bound=!1,this.hasKeyboard=this.options.keyboard,this.map={},this.views=[],this.isMobile=this.options.mobileMode;var b=this.options.tplWrapper().replace(/namespace/g,this.namespace),d=this.options.tplContent().replace(/namespace/g,this.namespace),e=this.options.tplTitle().replace(/namespace/g,this.namespace),f=i[this.options.lang].buttons;switch(this.$picker=a(b),this.mode){case"single":this.calendarsNum=1;break;case"range":this.calendarsNum=2;break;case"multiple":this.calendarsNum=this.isMobile?1:this.options.calendars,this.options.views=["days"]}for(var g=0;g'),this.$picker.append(e).addClass(this.namespace+"_isMobile"),this.$picker.css({"font-size":Math.round(.04*l)+"px"})}this.$picker.attr("tabindex","0"),this._initStatus(this.options.displayMode),this._initSections(),this._initDate();for(var m=0;m',q=[],r=[];o=0>o?7+o:o;for(var s=0;7>s;s++){var t=this.options.firstDayOfWeek+s>6?this.options.firstDayOfWeek+s-7:this.options.firstDayOfWeek+s;p+=""+i[this.options.lang].daysShort[t]+""}p+='
';for(var u=0;42>u;u++)b=u-o+1,d=!1,e=!1,c=!1,f=!1,q=[c,d,e,f],g=0,h="",u>0&&u%7===0&&(p+='
'),o>u?(h=this.namespace+"_otherMonth",g=n-o+u+1,r[u]=new Date(j,k-1,g,0,0,0,0)):u>l+o-1?(h=this.namespace+"_otherMonth",g=b-l,r[u]=new Date(j,k+1,g,0,0,0,0)):(r[u]=new Date(j,k,b,0,0,0,0),g=b,this.hasKeyboard&&("multiple"===this.mode?Date.parse(r[u])===Date.parse(this._date.focusDate)&&(h+=" "+this.namespace+"_focus"):Date.parse(r[u])===Date.parse(this._date.focusDate[a])&&(h+=" "+this.namespace+"_focus"))),q=this._judgeStatus(a,"days",this.mode,q,r[u],this._date.selectedDate),h+=this._renderStatus(q),p+=''+g+"";return p+="
"},_generateMonths:function(a){var b,c,d,e,f,g=this._date.currentYear[a],h="",j=i[this.options.lang].monthsShort,k=[],l=this._date.focusDate[a],m=[];h+='
';for(var n=0;12>n;n++)c=!1,d=!1,e=!1,f=!1,m=[e,c,d,f],b="",n>0&&n%3===0&&(h+='
'),k[n]=new Date(g,n,1,0,0,0,0),this.hasKeyboard&&Date.parse(k[n])===Date.parse(new Date(l.getFullYear(),l.getMonth(),1,0,0,0,0))&&(b+=" "+this.namespace+"_focus"),m=this._judgeStatus(a,"months",this.mode,m,k[n],this._date.selectedMonthDate),b+=this._renderStatus(m),h+=''+j[n]+"";return h+="
"},_generateYears:function(a){var b,c,d,e,f,g=this._date.currentYear[a],h="",i=0,j=[],k=this._date.focusDate[a],l=[];h+='
';for(var m=0;12>m;m++)c=!1,d=!1,e=!1,f=!1,l=[e,c,d,f],b="",i=g-7+m,m>0&&m%3===0&&(h+='
'),j[m]=new Date(i,0,1,0,0,0,0),this.hasKeyboard&&Date.parse(j[m])===Date.parse(new Date(k.getFullYear(),0,1,0,0,0,0))&&(b+=" "+this.namespace+"_focus"),l=this._judgeStatus(a,"years",this.mode,l,j[m],this._date.selectedYearDate),b+=this._renderStatus(l),h+=''+i+"";return h+="
"},_judgeLock:function(a){var b,c,d=!1,e=!1;switch(this.mode){case"range":if(0===a){switch(this.views[a]){case"days":b=Date.parse(this._date.currentDate[a]),c=Date.parse(this._date.selectedMonthDate[1]);break;case"months":b=Date.parse(this._date.currentYearDate[a]),c=Date.parse(this._date.selectedYearDate[1]);break;case"years":b=new Date(this._date.currentYearDate[a]).setFullYear(this._date.currentYear[a]+4),c=Date.parse(this._date.selectedYearDate[1])}e=!this._setPoint("<",e,b,c)}else{switch(this.views[a]){case"days":b=Date.parse(this._date.currentDate[a]),c=Date.parse(this._date.selectedMonthDate[0]);break;case"months":b=Date.parse(this._date.currentYearDate[a]),c=Date.parse(this._date.selectedYearDate[0]);break;case"years":b=new Date(this._date.currentYearDate[a]).setFullYear(this._date.currentYear[a]-7),c=Date.parse(this._date.selectedYearDate[0])}d=!this._setPoint(">",d,b,c)}break;case"multiple":this.calendarsNum>1&&(0===a?e=!0:d=a===this.calendarsNum-1?!0:e=!0)}d===!0?this.calendarPrevs.eq(a).addClass(this.namespace+"_blocked"):this.calendarPrevs.eq(a).removeClass(this.namespace+"_blocked"),e===!0?this.calendarNexts.eq(a).addClass(this.namespace+"_blocked"):this.calendarNexts.eq(a).removeClass(this.namespace+"_blocked")},_judgeSection:function(a,b,c){var d=!0;return(b>a||a>c)&&(d=!1),d},_judgeSections:function(b,c,e,f){var g=this,h=!1;switch(b){case"date":if(f)c=Date.parse(c),a.each(e,function(a,b){if(!h)switch(b.length){case d:c===Date.parse(b)&&(h=!0);break;case 2:h=g._judgeSection(c,Date.parse(b[0]),Date.parse(b[1]))}});else{var i=Date.parse(c[0]),j=Date.parse(c[1]);a.each(e,function(a,b){if(!h)switch(b.length){case d:Date.parse(b)>=i&&Date.parse(b)<=j&&(h=!0);break;case 2:h=!0,(jDate.parse(b[1]))&&(h=!1)}})}break;case"block":a.each(e,function(a,b){if(!h)switch(b.length){case d:c===b&&(h=!0);break;case 2:h=g._judgeSection(c,b[0],b[1])}});break;case"dayOfWeek":var k=c.getDay();a.each(e,function(a,b){if(!h)switch(b.length){case d:k===b&&(h=!0);break;case 2:h=g._judgeSection(k,b[0],b[1])}})}return h},_judgeStatus:function(a,b,c,d,e,f){var g=d[0],h=d[1],i=d[2];switch(g=!this._isSelectable(b,e.getFullYear(),e.getMonth(),e.getDate()),c){case"single":h=this._setPoint("=",h,Date.parse(e),Date.parse(f[a]));break;case"range":h=this._setPoint("=",h,Date.parse(e),Date.parse(f[a])),i=this._setSection(i,e,f[0],f[1]),0===a?g=this._setPoint(">",g,Date.parse(e),Date.parse(f[1])):1===a&&(g=this._setPoint("<",g,Date.parse(e),Date.parse(f[0])));break;case"multiple":for(var j=0;jc&&(e=!0);break;case">":c>d&&(e=!0)}return e},_setSection:function(a,b,c,d){var e=a,f=Date.parse(b),g=Date.parse(c),h=Date.parse(d);return f>=g&&h>=f&&(e=!0),e},_isSelectable:function(a,b,c,d){var e,f,g,h,i=!0,j=this._parseDate(this.options.min,this.format),k=this._parseDate(this.options.max,this.format),l=this._parseDateArr(this.options.selectableDate,this.format),m=this._parseDateSection(this.options.selectableYear),n=this._parseDateSection(this.options.selectableMonth),o=this._parseDateSection(this.options.selectableDay),p=this._parseDateSection(this.options.selectableDayOfWeek);switch(a){case"years":e=new Date(b,0,1),f=new Date(b+1,0,0),g=[e,f],h=!1;break;case"months":e=new Date(b,c,1),f=new Date(b,c+1,0),g=[e,f],h=!1;break;case"days":e=f=g=new Date(b,c,d),h=!0}return j&&j>f&&(i=!1),k&&e>k&&(i=!1),i&&l.length>0&&(i=this._judgeSections("date",g,l,h)),i&&m.length>0&&(i=this._judgeSections("block",b,m)),("months"===a||"days"===a)&&i&&n.length>0&&(i=this._judgeSections("block",c,n)),"days"===a&&(i&&o.length>0&&(i=this._judgeSections("block",d,o)),i&&p.length>0&&(i=this._judgeSections("dayOfWeek",new Date(b,c,d),p))),i},_renderStatus:function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f="";return e===!0?f=" "+this.namespace+"_untouchable":(b===!0&&(f=" "+this.namespace+"_untouchable"),d===!0&&(f+=" "+this.namespace+"_inRange")),c===!0&&(f+=" "+this.namespace+"_active"),f},_changeView:function(a,b){switch(a){case"caption":"multiple"!==this.options.mode&&("days"===this.views[b]?this.views[b]="months":"months"===this.views[b]&&(this.views[b]="years"));break;case"content":"years"===this.views[b]?this.views[b]="months":"months"===this.views[b]&&(this.views[b]="days");break;case"higher":"multiple"!==this.options.mode&&("days"===this.views[b]?this.views[b]="months":"months"===this.views[b]&&(this.views[b]="years"));break;case"lower":"multiple"!==this.options.mode&&("years"===this.views[b]?this.views[b]="months":"months"===this.views[b]&&(this.views[b]="days"))}},_setDate:function(a,b,c){if("object"==typeof b)for(var d in b)switch(d){case"day":a.setDate(b[d]);break;case"month":a.setMonth(b[d]);break;case"year":a.setYear(b[d])}else switch(b){case"day":a.setDate(c);break;case"month":a.setMonth(c);break;case"year":a.setYear(c)}},_formatDate:function(a,b){a=new Date(a);var c={d:a.getDate(),m:a.getMonth()+1,yy:a.getFullYear().toString().substring(2),yyyy:a.getFullYear()};c.dd=(c.d<10?"0":"")+c.d,c.mm=(c.m<10?"0":"")+c.m,a=[];for(var d=0,e=b.parts.length;e>d;d++)a.push(c[b.parts[d]]);return a.join(b.separator)},_stringSeparate:function(a,b){var c=new RegExp("[.\\"+b+"\\s].*?"),d=a.match(c),e=a.split(d);return e},_parseHtmlString:function(a,b){var c=[],d=k.defaults;if("object"==typeof d[a]){for(var e,f=this._stringSeparate(b,","),g=0;g"),e=e.length>1?{from:e[0],to:e[1]}:e[0],c.push(e);return c}return b},_parseFormat:function(a){var b=a.match(/[.\/\-\s].*?/),c=a.split(/\W+/)||c;if(!c||0===c.length)throw new Error("Invalid date format.");return{separator:b,parts:c}},_parseDate:function(a,b){if(null!==a){var c=new Date,d=c.getDate();switch(typeof a){case"string":if(a.length<5)c.setHours(0,0,0,0),c.setDate(d+Number(a));else{var e,f=a.split(b.separator)||f;if(c.setHours(0,0,0,0),f.length===b.parts.length)for(var g=0,h=b.parts.length;h>g;g++){if(e=parseInt(f[g],10)||1,"1"===e)return;switch(b.parts[g]){case"dd":case"d":c.setDate(e);break;case"mm":case"m":c.setMonth(e-1,1);break;case"yy":c.setFullYear(2e3+e);break;case"yyyy":c.setFullYear(e)}}}break;case"number":c.setHours(0,0,0,0),c.setDate(d+a)}return c}return null},_parseDateArr:function(a,b){for(var c=[],d=0,e=0;ef&&("bottom"===n?n="top":(n="left")?n="leftTop":(n="right")&&(n="rightTop"));break;case"top":case"rightTop":case"leftTop":0>g-d&&("top"===n?n="bottom":(n="leftTop")?n="left":(n="rightTop")&&(n="right"))}switch(n){case"top":a=h+m,b=g-d;break;case"right":a=h+j+m,b=g;break;case"bottom":a=h+m,b=g+i;break;case"left":a=h-e+m,b=g;break;case"rightTop":a=h+j+m,b=g-d+i;break;case"leftTop":a=h-e+m,b=g-d+i}}this.$picker.css({left:a,top:b})},_toggle:function(){this.showed?(this.pickerHide=!0,this._blur()):this._focus()},_focus:function(){"dropdown"===this.options.displayMode&&this.showed===!1&&this.show(),this.hasKeyboard&&this._keyboard.init(this)},_blur:function(){"dropdown"===this.options.displayMode&&this.pickerHide===!0&&(this.hide(),this.pickerHide=!1),this.hasKeyboard&&this._keyboard.destroy(this)},_trigger:function(a){var b=arguments.length>1?Array.prototype.slice.call(arguments,1).push(this):this;this.$el.trigger(e+"::"+a,b),a=a.replace(/\b\w+\b/g,function(a){return a.substring(0,1).toUpperCase()+a.substring(1)});var c="on"+a,f=arguments.length>1?Array.prototype.slice.call(arguments,1):d;"function"==typeof this.options[c]&&this.options[c].apply(this,f)},_click:function(b){var c=a(b.target);if(0===c.closest(this.$inputIcon).length&&0===c.closest(this.$picker).length&&0===c.closest(this.$el).length&&this.options.alwaysShow===!1)this.isMobile?this.mobileCancel(0):this.hide();else if(1!==c.closest(this.$el).length&&1===c.closest(this.$picker).length){var d=a(b.target).closest("div"),e=a(b.target).closest("span");if(1===d.parent("."+this.namespace+"-header").length){var f=d.parents("."+this.namespace+"-content").index();switch(d[0].className){case this.namespace+"-caption":this._changeView("caption",f),this._manageViews(f);break;case this.namespace+"-prev":this.prev(f);break;case this.namespace+"-next":this.next(f)}}if(1===e.length){var g=e.parents("."+this.namespace+"-content").index();if(!e.hasClass(this.namespace+"_otherMonth")&&!e.hasClass(this.namespace+"_untouchable")&&1!==e.parent("."+this.namespace+"-head").length){switch(this._changeValue(e,g),this._changeView("content",g),this._updateDate(g),this.mode){case"single":"days"===this.views[g]&&(this.selected=!0),this._manageViews(g);break;case"range":this._manageViews(0),this._manageViews(1);break;case"multiple":this._manageViews(g-1),this._manageViews(g),this._manageViews(g+1)}this.isMobile||this._setValue()}}if(1===d.parent("."+this.namespace+"-buttons").length){var h=d.parents("."+this.namespace+"-content").index(),i=d[0].className===this.namespace+"-button-save"?!0:!1;i?this.mobileEnter(h):this.mobileCancel(h)}this.isMobile||(this.selected===!0&&this.options.alwaysShow===!1&&this.options.onceClick===!0?this.hide():"dropdown"===this.options.displayMode&&this.$el.focus())}b.preventDefault()},_changeValue:function(b,c){var d="",e="",f=this;switch(this.views[c]){case"years":d=parseInt(b.text(),10),this._date.currentDate[c].setYear(d);break;case"months":d=Number(b.attr("class").match(/month\-([0-9]+)/)[1]),this._date.currentDate[c].setMonth(d);break;case"days":switch(d=parseInt(b.text(),10),e=new Date(this._date.currentYear[c],this._date.currentMonth[c],d,0,0,0,0),this.options.mode){case"single":case"range":this._date.selectedDate[c]=e;break;case"multiple":var g=Date.parse(e);a.inArray(g,this._date.selectedDate)>-1?a.each(this._date.selectedDate,function(a,b){b===g&&f._date.selectedDate.splice(a,1)}):this._date.selectedDate.lengthd&&this._date.focusDate.setDate(d),this._date.focusDate.setMonth(this._date.focusDate.getMonth()-1);for(var f=0;fd&&this._date.focusDate[a].setDate(d),this._date.focusDate[a]=new Date(c.getFullYear(),c.getMonth(),this._date.focusDate[a].getDate(),0,0,0,0));break;case"months":c.setYear(this._date.currentYear[a]-1),this.hasKeyboard&&(this._date.focusDate[a]=new Date(c.getFullYear(),this._date.focusDate[a].getMonth(),this._date.focusDate[a].getDate(),0,0,0,0));break;case"years":c.setYear(this._date.currentYear[a]-12),this.hasKeyboard&&b&&(this._date.focusDate[a]=new Date(this._date.focusDate[a].getFullYear()-12,this._date.focusDate[a].getMonth(),this._date.focusDate[a].getDate(),0,0,0,0))}this._updateDate(a),this._manageViews(a)},next:function(a,b){this.touchflag=!1;var c=this._date.currentDate[a];switch(this.views[a]){case"days":var d;if("multiple"===this.mode)if(b)if(this.focused===this.calendarsNum-1)for(var e=0;ed&&this._date.focusDate.setDate(d),this._date.focusDate.setMonth(this._date.focusDate.getMonth()+1);for(var f=0;fd&&this._date.focusDate[a].setDate(d),this._date.focusDate[a]=new Date(c.getFullYear(),c.getMonth(),this._date.focusDate[a].getDate(),0,0,0,0));break;case"months":c.setYear(this._date.currentYear[a]+1),this.hasKeyboard&&(this._date.focusDate[a]=new Date(c.getFullYear(),this._date.focusDate[a].getMonth(),this._date.focusDate[a].getDate(),0,0,0,0));break;case"years":c.setYear(this._date.currentYear[a]+12),this.hasKeyboard&&b&&(this._date.focusDate[a]=new Date(this._date.focusDate[a].getFullYear()+12,this._date.focusDate[a].getMonth(),this._date.focusDate[a].getDate(),0,0,0,0))}this._updateDate(a),this._manageViews(a)},mobilePrev:function(a){this.calendars.eq(a).removeClass(this.namespace+"_show"),this.calendars.eq(a-1).addClass(this.namespace+"_show")},mobileNext:function(a){this.calendars.eq(a).removeClass(this.namespace+"_show"),this.calendars.eq(a+1).addClass(this.namespace+"_show")},mobileInteDate:function(a){var b=this;"multiple"===this.mode?this._date.selectedDate.length>0&&(b._date.currentDate[0]=new Date(this._date.selectedDate[0])):this._date.currentDate[a]=new Date(this._date.selectedDate[a]),this.views[a]="days",this._updateDate(a)},mobileEnter:function(a){"range"===this.mode&&0===a?(this.mobileNext(a),this.views[a]="days"):(this.mobileInteDate(a),this._setValue(),this.hide()),this._manageViews(a)},mobileCancel:function(a){1===a?(this.mobilePrev(a),this.views[a]="days"):(this.dateTransform(this._date.cache,this._date),this.mobileInteDate(a),this.hide()),this._manageViews(a)},dateTransform:function(b,c){var d=this;c.currentDate=[],c.selectedDate=[],a.each(b.currentDate,function(a,b){c.currentDate[a]=new Date(b)}),a.each(b.selectedDate,function(a,b){var e=new Date(b);c.selectedDate[a]="multiple"===d.mode?Date.parse(e):e})},show:function(){var b=this;if(this.isMobile&&this.dateTransform(this._date,this._date.cache),"inline"===this.options.displayMode)this._trigger("beforeShow"),this.$picker.on("mouseDown."+this.flag,function(a){b._prevent(a)}),this.$picker.on("click."+this.flag,function(a){b._click.call(b,a)});else if(this.showed===!1){if(this._trigger("beforeShow"),this.$inputWrap.addClass(this.namespace+"_active"),this.$picker.addClass(this.namespace+"_show"),this.isMobile){this.calendars.eq(0).addClass(this.namespace+"_show"),"range"===this.mode&&this.calendars.eq(1).removeClass(this.namespace+"_show"),a("body").append(this.$cover).css("overflow","hidden"),g.on("scrollstart."+this.flag,function(a){a.preventDefault()}),g.on("tap."+this.flag,function(a){b._click.call(b,a)});var c=function(a){var d=a.swipestart.coords[0],e=a.swipestop.coords[0];e>d?b.prev.call(b,0):d>e&&b.next.call(b,0),g.one("swipe."+b.flag,c)};g.one("swipe."+this.flag,c)}else g.on("click."+this.flag,function(a){b._click.call(b,a)});this._position(),this.showed=!0,h.on("resize."+this.flag,function(){b._position()}),this.$picker.on("mousedown."+this.flag,function(a){b._prevent(a)})}return this._trigger("show"),this},hide:function(){return this.showed===!0&&(this._trigger("beforeHide"),this.selected=!1,this.$inputWrap.removeClass(this.namespace+"_active"),this.$picker.removeClass(this.namespace+"_show"),this.showed=!1,this.$picker.off("mousedown."+this.flag),g.off("click."+this.flag),h.off("resize."+this.flag),this.isMobile&&(a("body").css("overflow","auto"),this.$cover.remove(),g.off("click."+this.flag+" tap."+this.flag+" scrollstart."+this.flag+" swipe."+this.flag)),this.$el.blur(),this._trigger("hide")),this},getWrap:function(){return this.picker},getInput:function(){return this.$el},getDate:function(a){if(a===d)return this._date.selectedDate;for(var b=this._parseFormat(a),c=[],e=0;ethis._date.currentYear[a]+1?c||(b.setFullYear(b.getFullYear()+3),this.next(a)):(b.setFullYear(b.getFullYear()+3),this._manageViews(a))}},prevPage:function(){"multiple"===this.mode?this.prev(this.focused):this.calendarPrevs.eq(this.focused).hasClass(this.namespace+"_blocked")||this.prev(this.focused,!0)},nextPage:function(){"multiple"===this.mode?this.next(this.focused):this.calendarNexts.eq(this.focused).hasClass(this.namespace+"_blocked")||this.next(this.focused,!0)},higherView:function(){if("multiple"!==this.mode){var a=this.focused;this._changeView("higher",a),this._manageViews(a)}},prevCalendar:function(){if("multiple"!==this.mode){var a=this.calendars.length;--this.focused<0&&(this.focused=a)}},nextCalendar:function(){if("multiple"!==this.mode){var a=this.calendars.length;++this.focused>=a&&(this.focused=0)}},updateValue:function(b){var c=b.focused,d="multiple"===b.mode?b._date.focusDate:b._date.focusDate[c];if(!b.calendars.eq(c).find("."+b.namespace+"_focus").hasClass(b.namespace+"_untouchable")){switch(b.views[c]){case"days":switch(b.options.mode){case"single":case"range":b._date.selectedDate[c]=new Date(d);break;case"multiple":var e=Date.parse(new Date(d));a.inArray(e,b._date.selectedDate)>-1?a.each(b._date.selectedDate,function(a,c){return c===e?(b._date.selectedDate.splice(a,1),!1):void 0}):b._date.selectedDate.push(e)}break;case"months":b._date.currentDate[c].setMonth(d.getMonth()),b.views[c]="days";break;case"years":b._date.currentDate[c].setFullYear(d.getFullYear()),b.views[c]="months"}b._updateDate(c),"range"===b.mode?(b._manageViews(0),b._manageViews(1)):"multiple"===b.mode?(b._manageViews(c-1),b._manageViews(c),b._manageViews(c+1)):b._manageViews(c),b._setValue()}},enter:function(){var b,c=this.$el.val(),d=this;if(c===this.oldValue||""===this.oldValue)this._keyboard.updateValue(this);else{var e;switch(this.mode){case"single":var f=Date.parse(c);f&&(this._date.selectedDate[0]=new Date(f),this._date.currentDate[0]=new Date(this._date.selectedDate[0]),this._updateDate(0),this._manageViews(0));break;case"range":e=this._stringSeparate(c,this.options.rangeSeparator);var g=Date.parse(e[0]),h=Date.parse(e[1]);if(2===e.length?(b=!0,g&&h?g>h&&(b=!1):b=!1):b=!1,b===!0){this._date.selectedDate[0]=new Date(g),this._date.selectedDate[1]=new Date(h);for(var i=0;2>i;i++)this._date.currentDate[i]=new Date(this._date.selectedDate[i]),this._updateDate(i),this._manageViews(i)}else this._keyboard.updateValue(this);break;case"multiple":e=this._stringSeparate(c,this.options.multipleSeparator);var j=[];b=!0;for(var k=0;k-1?a.each(this._date.selectedDate,function(a,b){b===j[l]&&d._date.selectedDate.splice(a,1)}):this._date.selectedDate.push(j[l]);for(var m=0;m