You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
38 KiB
Plaintext
2 lines
38 KiB
Plaintext
11 months ago
|
(function(e,j,i,b){var h="asDatepicker",c={firstDayOfWeek:0,mode:"single",displayMode:"dropdown",calendars:1,date:"today",keyboard:true,rangeSeparator:"--",multipleSeparator:",",multipleSize:5,container:"body",position:"bottom",alwaysShow:false,onceClick:false,min:null,max:null,selectableDate:[],selectableYear:[],selectableMonth:[],selectableDay:[],selectableDayOfWeek:[],lang:"zh",views:["days"],outputFormat:"yyyy-mm-dd",mobileMode:false,namespace:"calendar",tplInputWrapper:function(){return'<div class="namespace-inputWrap"></div>'},tplWrapper:function(){return'<div class="namespace-wrap"></div>'},tplContent:function(){return'<div class="namespace-content"><div class="namespace-header"><div class="namespace-prev"><</div><div class="namespace-caption"></div><div class="namespace-next">></div></div><div class="namespace-days"></div><div class="namespace-months"></div><div class="namespace-years"></div><div class="namespace-buttons"><div class="namespace-button-cancel"></div><div class="namespace-button-save"></div></div></div>'},tplTitle:function(){return'<div class="namespace-title">test</div>'},onInit:null,onReady:null,onRender:null,onChange:null,onBeforeShow:null,onShow:null,onBeforeHide:null,onHide:null};var d=e(j);var a=e(i);var f={};var g=0;var k=e[h]=function(n,m){var l=this,o=e(n).data();this.$el=e(n);this.defaultOptions=e.extend(true,{},c,m,o);this.options=e.extend(true,{},c,m,o);e.each(o,function(p,q){l.options[p]=l._parseHtmlString(p,q);l.defaultOptions[p]=l._parseHtmlString(p,q)});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=e('<i class="'+this.namespace+'-icon"></i>');this.$inputIcon.appendTo(this.$inputWrap);this.$container=e(this.options.container);this._trigger("init");this._init()};k.LABEL=f;k.localize=function(m,l){f[m]=l};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.localize("zh",{days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],daysShort:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["一","二","三","四","五","六","七","八","九","十","十一","十二"],buttons:["取消","确定"]});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=g++;this.pickerHide=false;this.selected=false;this.showed=false;this.bound=false;this.hasKeyboard=this.options.keyboard;this.map={};this.views=[];this.isMobile=this.options.mobileMode;var m=this.options.tplWrapper().replace(/namespace/g,this.namespace),q=this.options.tplContent().replace(/namespace/g,this.namespace),t=this.options.tplTitle().replace(/namespace/g,this.namespace),r=f[this.options.lang].buttons;this.$picker=e(m);switch(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"];break}for(var p=0;p<this.calendarsNum;p++){this.$picker.append(q);this.views[p]=this.options.views[p]||"days"}if(this.isMobile){var s=i.innerWidth;var l=i.innerHeight;var o=Math.min(s,l);this.$el.attr("readonly","readonly");this.$cover=e('<div class="'+this.namespace+'-cover"></div>');this.$picker.append(t).addClass(this.namespace+"_isMobile");this.$picker.css({"font-size":Math.round(o*0.04)+"px"})}this.$picker.attr("tabindex","0");this._initStatus(this.options.displayMode);this._initSections();this._initDate();for(var n=0;n<this.calendars
|
||
|
m++){o[m]=this._formatDate(this._date.selectedDate[m],l)}return o}},multipleClear:function(){this._date.selectedDate=[];for(var l=0;l<this.calendarsNum;l++){this._manageViews(l)}this._setValue()},destroy:function(){this.$el.removeData("asDatepicker");this._removeEvents();this.$picker.remove()},update:function(n){if(typeof n!=="undefined"){for(var l in n){this.options[l]=n[l]}}this._removeEvents();this.$picker.remove();this._init()},reset:function(o){for(var l in this.defaultOptions){this.options[l]=this.defaultOptions[l]}if(typeof o!=="undefined"){for(var p in o){this.options[p]=o[p]}}this._removeEvents();this.$picker.remove();this._init()},_keyboard:{init:function(l){this.attach(l,this.gather(l))},destroy:function(l){if(l.options.displayMode==="dropdown"){l.$el.off("keydown.dropdown")}else{l.$picker.off("keydown.inline")}l.bound=false},keys:function(){return{LEFT:37,UP:38,RIGHT:39,DOWN:40,ENTER:13,ESC:27,CTRL:17,ALT:18}},prevDate:function(){var m=this.focused,l=this.mode==="multiple"?this._date.focusDate:this._date.focusDate[m],n=this.mode==="multiple"?false:this.calendarPrevs.eq(this.focused).hasClass(this.namespace+"_blocked");switch(this.views[m]){case"days":if(Date.parse(l)===Date.parse(this._date.currentDate[m])){if(!n){l.setDate(l.getDate()-1);this.prev(m,true)}}else{l.setDate(l.getDate()-1);this._manageViews(m)}break;case"months":if(l.getMonth()===0){if(!n){l.setMonth(l.getMonth()-1);this.prev(m)}}else{l.setMonth(l.getMonth()-1);this._manageViews(m)}break;case"years":if(l.getFullYear()===this._date.currentYear[m]-7){if(!n){l.setFullYear(l.getFullYear()-1);this.prev(m)}}else{l.setFullYear(l.getFullYear()-1);this._manageViews(m)}break}},nextDate:function(){var m=this.focused,l=this.mode==="multiple"?this._date.focusDate:this._date.focusDate[m],n=this.mode==="multiple"?false:this.calendarNexts.eq(this.focused).hasClass(this.namespace+"_blocked");switch(this.views[m]){case"days":if(Date.parse(l)===Date.parse(new Date(this._date.currentYear[m],this._date.currentMonth[m]+1,0))){if(!n){l.setDate(l.getDate()+1);this.next(m,true)}}else{l.setDate(l.getDate()+1);this._manageViews(m)}break;case"months":if(l.getMonth()===11){if(!n){l.setMonth(l.getMonth()+1);this.next(m)}}else{l.setMonth(l.getMonth()+1);this._manageViews(m)}break;case"years":if(l.getFullYear()===this._date.currentYear[m]+4){if(!n){l.setFullYear(l.getFullYear()+1);this.next(m)}}else{l.setFullYear(l.getFullYear()+1);this._manageViews(m)}break}},upLine:function(){var m=this.focused,l=this.mode==="multiple"?this._date.focusDate:this._date.focusDate[m],n=this.mode==="multiple"?false:this.calendarPrevs.eq(this.focused).hasClass(this.namespace+"_blocked");switch(this.views[m]){case"days":if(new Date(l.getFullYear(),l.getMonth(),l.getDate()-7).setDate(1)===new Date(this._date.currentDate[m]).setMonth(this._date.currentMonth[m]-1)){if(!n){l.setDate(l.getDate()-7);this.prev(m,true)}}else{l.setDate(l.getDate()-7);this._manageViews(m)}break;case"months":if(l.getMonth()===0||l.getMonth()===1||l.getMonth()===2){if(!n){l.setMonth(l.getMonth()-3);this.prev(m)}}else{l.setMonth(l.getMonth()-3);this._manageViews(m)}break;case"years":if(l.getFullYear()<this._date.currentYear[m]-4){if(!n){l.setFullYear(l.getFullYear()-3);this.prev(m)}}else{l.setFullYear(l.getFullYear()-3);this._manageViews(m)}break}},downLine:function(){var m=this.focused,l=this.mode==="multiple"?this._date.focusDate:this._date.focusDate[m],n=this.mode==="multiple"?false:this.calendarNexts.eq(this.focused).hasClass(this.namespace+"_blocked");switch(this.views[m]){case"days":if(new Date(l.getFullYear(),l.getMonth(),l.getDate()+7).setDate(1)===new Date(this._date.currentDate[m]).setMonth(this._date.currentMonth[m]+1)){if(!n){l.setDate(l.getDate()+7);this.next(m,true)}}else{l.setDate(l.getDate()+7);this._manageViews(m)}break;case"months":if(l.getMonth()===9||l.getMonth()===10||l.getMonth()===11){if(!n){l.setMonth(l.getMonth()+3);this.next(m)}}else{l.setMonth(l.getMonth()+3);this._manageViews(m)}break;case"years":if(l.getFullYear()>this._date.currentYear[m]+1){if(!n){l.setFullYear(l.getFullYear()+3);this.next(m)}}el
|