diff --git a/dist/laydate.js b/dist/laydate.js index 5f93fa9..a59cab2 100644 --- a/dist/laydate.js +++ b/dist/laydate.js @@ -1,2 +1,2 @@ /*! layDate v5.1.0 | 日期与时间组件 | The MIT License */ - ;!function(){"use strict";var e="lay",t="1.0.0",a=window.document,n=function(e){return new i(e)},i=function(e){for(var t=0,n="object"==typeof e?[e]:(this.selector=e,a.querySelectorAll(e||null));t0;i--)if("interactive"===t[i].readyState){e=t[i].src;break}return e||t[n].src}();return e.substring(0,e.lastIndexOf("/")+1)},n.stope=function(e){e=e||window.event,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},n.each=function(e,t){var a,n=this;if("function"!=typeof t)return n;if(e=e||[],e.constructor===Object){for(a in e)if(t.call(e[a],a,e[a]))break}else for(a=0;a80?window.console&&console.error(o+".css: Invalid"):void(1989===parseInt(n.getStyle(a.getElementById(s),"width"))?t():setTimeout(c,100))}()},i.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),n.each(t,function(t,a){new RegExp("\\b"+a+"\\b").test(e)||(e=e+" "+a)}),e.replace(/^\s|\s$/,"")},i.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),n.each(t,function(t,a){var n=new RegExp("\\b"+a+"\\b");n.test(e)&&(e=e.replace(n,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},i.prototype.lay=t,i.prototype.find=function(e){var t=this,a=0,i=[],l="object"==typeof e;return this.each(function(n,r){for(var o=l?[e]:r.querySelectorAll(e||null);a0)return a[0].getAttribute(e)}():a.each(function(a,n){n.setAttribute(e,t)})},i.prototype.removeAttr=function(e){return this.each(function(t,a){a.removeAttribute(e)})},i.prototype.html=function(e){return this.each(function(t,a){a.innerHTML=e})},i.prototype.val=function(e){return this.each(function(t,a){a.value=e})},i.prototype.append=function(e){return this.each(function(t,a){"object"==typeof e?a.appendChild(e):a.innerHTML=a.innerHTML+e})},i.prototype.remove=function(e){return this.each(function(t,a){e?a.removeChild(e):a.parentNode.removeChild(a)})},i.prototype.on=function(e,t){return this.each(function(a,n){n.attachEvent?n.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(n,e)}):n.addEventListener(e,t,!1)})},i.prototype.off=function(e,t){return this.each(function(a,n){n.detachEvent?n.detachEvent("on"+e,t):n.removeEventListener(e,t,!1)})},window.lay=n,window.layui&&layui.define&&layui.define(function(t){t(e,n)})}(),!function(e){"use strict";var t=e.layui&&layui.define,a={getPath:e.lay&&lay.getPath?lay.getPath():"",link:function(t,a,i){n.path&&e.lay&&lay.link&&lay.link(n.path+t,a,i)}},n={v:"5.1.0",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:a.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var i="laydate",l="",r=(t?"modules/laydate/":"theme/")+"default/laydate.css?v="+n.v+l;return t?layui.addcss(r,e,i):a.link(r,e,i),this}},i=function(){var e=this;return{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",r=".layui-laydate",o="layui-this",s="laydate-disabled",y="开始时间不能早于结束时间
请重新选择",c=[100,2e5],d="layui-laydate-static",m="layui-laydate-list",u="laydate-selected",h="layui-laydate-hint",f="laydate-day-prev",p="laydate-day-next",g="layui-laydate-footer",v=".laydate-btns-confirm",T="laydate-time-text",D=".laydate-btns-time",w=function(e){var t=this;t.index=++n.index,t.config=lay.extend({},t.config,n.config,e),n.ready(function(){t.init()})};w.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},w.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"focus",show:!1,showBottom:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},w.prototype.lang=function(){var e=this,t=e.config,a={cn:{weeks:["日","一","二","三","四","五","六"],time:["时","分","秒"],timeTips:"选择时间",startTime:"开始时间",endTime:"结束时间",dateTips:"返回日期",month:["一","二","三","四","五","六","七","八","九","十","十一","十二"],tools:{confirm:"确定",clear:"清空",now:"现在"}},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"}}};return a[t.lang]||a.cn},w.prototype.init=function(){var e=this,t=e.config,a="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s",n="static"===t.position,i={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};t.elem=lay(t.elem),t.eventElem=lay(t.eventElem),t.elem[0]&&(t.range===!0&&(t.range="-"),t.format===i.date&&(t.format=i[t.type]),e.format=t.format.match(new RegExp(a+"|.","g"))||[],e.EXP_IF="",e.EXP_SPLIT="",lay.each(e.format,function(t,n){var i=new RegExp(a).test(n)?"\\d{"+function(){return new RegExp(a).test(e.format[0===t?t+1:t-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;e.EXP_IF=e.EXP_IF+i,e.EXP_SPLIT=e.EXP_SPLIT+"("+i+")"}),e.EXP_IF=new RegExp("^"+(t.range?e.EXP_IF+"\\s\\"+t.range+"\\s"+e.EXP_IF:e.EXP_IF)+"$"),e.EXP_SPLIT=new RegExp("^"+e.EXP_SPLIT+"$",""),e.isInput(t.elem[0])||"focus"===t.trigger&&(t.trigger="click"),t.elem.attr("lay-key")||(t.elem.attr("lay-key",e.index),t.eventElem.attr("lay-key",e.index)),t.mark=lay.extend({},t.calendar&&"cn"===t.lang?{"0-1-1":"元旦","0-2-14":"情人","0-3-8":"妇女","0-3-12":"植树","0-4-1":"愚人","0-5-1":"劳动","0-5-4":"青年","0-6-1":"儿童","0-9-10":"教师","0-9-18":"国耻","0-10-1":"国庆","0-12-25":"圣诞"}:{},t.mark),lay.each(["min","max"],function(e,a){var n=[],i=[];if("number"==typeof t[a]){var l=t[a],r=(new Date).getTime(),o=864e5,s=new Date(l?l0)return!0;var n=lay.elem("div",{"class":"layui-laydate-header"}),i=[function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("div",{"class":"laydate-set-ym"}),t=lay.elem("span"),a=lay.elem("span");return e.appendChild(t),e.appendChild(a),e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],y=lay.elem("div",{"class":"layui-laydate-content"}),c=lay.elem("table"),d=lay.elem("thead"),m=lay.elem("tr");lay.each(i,function(e,t){n.appendChild(t)}),d.appendChild(m),lay.each(new Array(6),function(e){var t=c.insertRow(0);lay.each(new Array(7),function(n){if(0===e){var i=lay.elem("th");i.innerHTML=a.weeks[n],m.appendChild(i)}t.insertCell(n)})}),c.insertBefore(d,c.children[0]),y.appendChild(c),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(n),l[e].appendChild(y),r.push(i),o.push(y),s.push(c)}),lay(y).html(function(){var e=[],i=[];return"datetime"===t.type&&e.push(''+a.timeTips+""),lay.each(t.btns,function(e,l){var r=a.tools[l]||"btn";t.range&&"now"===l||(n&&"clear"===l&&(r="cn"===t.lang?"重置":"Reset"),i.push(''+r+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){i.appendChild(t)}),t.showBottom&&i.appendChild(y),/^#/.test(t.theme)){var c=lay.elem("style"),m=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,t.theme);"styleSheet"in c?(c.setAttribute("type","text/css"),c.styleSheet.cssText=m):c.innerHTML=m,lay(i).addClass("laydate-theme-molv"),i.appendChild(c)}e.remove(w.thisElemDate),n?t.elem.append(i):(document.body.appendChild(i),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),w.thisElemDate=e.elemID,"function"==typeof t.ready&&t.ready(lay.extend({},t.dateTime,{month:t.dateTime.month+1}))},w.prototype.remove=function(e){var t=this,a=(t.config,lay("#"+(e||t.elemID)));return a.hasClass(d)||t.checkDate(function(){a.remove(),delete t.endDate}),t},w.prototype.position=function(){var e=this,t=e.config,a=e.bindElem||t.elem[0],n=a.getBoundingClientRect(),i=e.elem.offsetWidth,l=e.elem.offsetHeight,r=function(e){return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e]},o=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},s=5,y=n.left,c=n.bottom;y+i+s>o("width")&&(y=o("width")-i-s),c+l+s>o()&&(c=n.top>l?n.top-l:o()-l,c-=2*s),t.position&&(e.elem.style.position=t.position),e.elem.style.left=y+("fixed"===t.position?0:r(1))+"px",e.elem.style.top=c+("fixed"===t.position?0:r())+"px"},w.prototype.hint=function(e){var t=this,a=(t.config,lay.elem("div",{"class":h}));t.elem&&(a.innerHTML=e||"",lay(t.elem).find("."+h).remove(),t.elem.appendChild(a),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+h).remove()},3e3))},w.prototype.getAsYM=function(e,t,a){return a?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},w.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},w.prototype.checkDate=function(e){var t,a,i=this,l=(new Date,i.config),r=l.dateTime=l.dateTime||i.systemDate(),o=i.bindElem||l.elem[0],s=(i.isInput(o)?"val":"html",i.isInput(o)?o.value:"static"===l.position?"":o.innerHTML),y=function(e){e.year>c[1]&&(e.year=c[1],a=!0),e.month>11&&(e.month=11,a=!0),e.hours>23&&(e.hours=0,a=!0),e.minutes>59&&(e.minutes=0,e.hours++,a=!0),e.seconds>59&&(e.seconds=0,e.minutes++,a=!0),t=n.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,a=!0)},d=function(e,t,n){var r=["startTime","endTime"];t=(t.match(i.EXP_SPLIT)||[]).slice(1),n=n||0,l.range&&(i[r[n]]=i[r[n]]||{}),lay.each(i.format,function(o,s){var y=parseFloat(t[o]);t[o].length必须遵循下述格式:
"+(l.range?l.format+" "+l.range+" "+l.format:l.format)+"
已为你重置"),a=!0):s&&s.constructor===Date?l.dateTime=i.systemDate(s):(l.dateTime=i.systemDate(),delete i.startTime,delete i.endTime),y(r),a&&s&&i.setValue(l.range?i.endDate?i.parse():"":i.parse()),e&&e(),i)},w.prototype.mark=function(e,t){var a,n=this,i=n.config;return lay.each(i.mark,function(e,n){var i=e.split("-");i[0]!=t[0]&&0!=i[0]||i[1]!=t[1]&&0!=i[1]||i[2]!=t[2]||(a=n||t[2])}),a&&e.html(''+a+""),n},w.prototype.limit=function(e,t,a,n){var i,l=this,r=l.config,o={},y=r[a>41?"endDate":"dateTime"],c=lay.extend({},y,t||{});return lay.each({now:c,min:r.min,max:r.max},function(e,t){o[e]=l.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(n,function(a,n){e[n]=t[n]}),e}())).getTime()}),i=o.nowo.max,e&&e[i?"addClass":"removeClass"](s),i},w.prototype.thisDateTime=function(e){var t=this,a=t.config;return e?t.endDate:a.dateTime},w.prototype.calendar=function(e,t,a){var i,l,r,s=this,y=s.config,t=t?1:0,d=e||s.thisDateTime(t),m=new Date,u=s.lang(),h="date"!==y.type&&"datetime"!==y.type,f=lay(s.table[t]).find("td"),p=lay(s.elemHeader[t][2]).find("span");return d.yearc[1]&&(d.year=c[1],s.hint("最高只能支持到公元"+c[1]+"年")),s.firstDate||(s.firstDate=lay.extend({},d)),m.setFullYear(d.year,d.month,1),i=m.getDay(),l=n.getEndDate(d.month||12,d.year),r=n.getEndDate(d.month+1,d.year),lay.each(f,function(e,t){var a=[d.year,d.month],n=0;t=lay(t),t.removeAttr("class"),e=i&&e=a.firstDate.year&&(l.month=n.max.month,l.date=n.max.date),a.limit(lay(i),l,t),x++}),lay(d[f?0:1]).attr("lay-ym",x-8+"-"+g[1]).html(M+p+" - "+(x-1+p))}else if("month"===e)lay.each(new Array(12),function(e){var i=lay.elem("li",{"lay-ym":e}),r={year:g[0],month:e};e+1==g[1]&&lay(i).addClass(o),i.innerHTML=l.month[e]+(f?"月":""),y.appendChild(i),g[0]=a.firstDate.year&&(r.date=n.max.date),a.limit(lay(i),r,t)}),lay(d[f?0:1]).attr("lay-ym",g[0]+"-"+g[1]).html(g[0]+p);else if("time"===e){var b=function(){lay(y).find("ol").each(function(e,n){lay(n).find("li").each(function(n,i){a.limit(lay(i),[{hours:n},{hours:a[C].hours,minutes:n},{hours:a[C].hours,minutes:a[C].minutes,seconds:n}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),n.range||a.limit(lay(a.footer).find(v),a[C],0,["hours","minutes","seconds"])};n.range?a[C]||(a[C]={hours:0,minutes:0,seconds:0}):a[C]=i,lay.each([24,60,60],function(e,t){var n=lay.elem("li"),i=["

"+l.time[e]+"

    "];lay.each(new Array(t),function(t){i.push(""+lay.digit(t,2)+"")}),n.innerHTML=i.join("")+"
",y.appendChild(n)}),b()}if(h&&u.removeChild(h),u.appendChild(y),"year"===e||"month"===e)lay(a.elemMain[t]).addClass("laydate-ym-show"),lay(y).find("li").on("click",function(){var l=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(s)){0===t?(i[e]=l,a.limit(lay(a.footer).find(v),null,0)):a.endDate[e]=l;var c="year"===n.type||"month"===n.type;c?(lay(y).find("."+o).removeClass(o),lay(this).addClass(o),"month"===n.type&&"year"===e&&(a.listYM[t][0]=l,r&&(t?i.year=l:a.endDate.year=l),a.list("month",t))):(a.checkDate("limit").calendar(null,t),a.closeList()),a.setBtnStatus(),n.range||(("month"===n.type&&"month"===e||"year"===n.type&&"year"===e)&&a.setValue(a.parse()).remove().done(),a.done(null,"change")),lay(a.footer).find(D).removeClass(s)}});else{var E=lay.elem("span",{"class":T}),k=function(){lay(y).find("ol").each(function(e){var t=this,n=lay(t).find("li");t.scrollTop=30*(a[C][w[e]]-2),t.scrollTop<=0&&n.each(function(e,a){if(!lay(this).hasClass(s))return t.scrollTop=30*(e-2),!0})})},H=lay(c[2]).find("."+T);k(),E.innerHTML=n.range?[l.startTime,l.endTime][t]:l.timeTips,lay(a.elemMain[t]).addClass("laydate-time-show"),H[0]&&H.remove(),c[2].appendChild(E),lay(y).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var l=0|this.innerHTML;lay(this).hasClass(s)||(n.range?a[C][w[e]]=l:i[w[e]]=l,lay(t).find("."+o).removeClass(o),lay(this).addClass(o),b(),k(),(a.endDate||"time"===n.type)&&a.done(null,"change"),a.setBtnStatus())})})}return a},w.prototype.listYM=[],w.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,a){lay(this).find("."+m).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+T).remove()},w.prototype.setBtnStatus=function(e,t,a){var n,i=this,l=i.config,r=lay(i.footer).find(v);l.range&&"time"!==l.type&&(t=t||l.dateTime,a=a||i.endDate,n=i.newDate(t).getTime()>i.newDate(a).getTime(),i.limit(null,t)||i.limit(null,a)?r.addClass(s):r[n?"addClass":"removeClass"](s),e&&n&&i.hint("string"==typeof e?y.replace(/日期/g,e):y))},w.prototype.parse=function(e,t){var a=this,n=a.config,i=t||(e?lay.extend({},a.endDate,a.endTime):n.range?lay.extend({},n.dateTime,a.startTime):n.dateTime),l=a.format.concat();return lay.each(l,function(e,t){/yyyy|y/.test(t)?l[e]=lay.digit(i.year,t.length):/MM|M/.test(t)?l[e]=lay.digit(i.month+1,t.length):/dd|d/.test(t)?l[e]=lay.digit(i.date,t.length):/HH|H/.test(t)?l[e]=lay.digit(i.hours,t.length):/mm|m/.test(t)?l[e]=lay.digit(i.minutes,t.length):/ss|s/.test(t)&&(l[e]=lay.digit(i.seconds,t.length))}),n.range&&!e?l.join("")+" "+n.range+" "+a.parse(1):l.join("")},w.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},w.prototype.setValue=function(e){var t=this,a=t.config,n=t.bindElem||a.elem[0],i=t.isInput(n)?"val":"html";return"static"===a.position||lay(n)[i](e||""),this},w.prototype.stampRange=function(){var e,t,a=this,n=a.config,i=n.dateTime,l=lay(a.elem).find("td");if(n.range&&!a.endDate&&lay(a.footer).find(v).addClass(s),a.endDate)return e=a.newDate({year:i.year,month:i.month,date:i.date}).getTime(),t=a.newDate({year:a.endDate.year,month:a.endDate.month,date:a.endDate.date}).getTime(),e>t?a.hint(y):void lay.each(l,function(n,i){var l=lay(i).attr("lay-ymd").split("-"),r=a.newDate({year:l[0],month:l[1]-1,date:l[2]}).getTime();lay(i).removeClass(u+" "+o),r!==e&&r!==t||lay(i).addClass(lay(i).hasClass(f)||lay(i).hasClass(p)?u:o),r>e&&r0;i--)if("interactive"===a[i].readyState){e=a[i].src;break}return e||a[n].src}();return e.substring(0,e.lastIndexOf("/")+1)},a.stope=function(e){e=e||window.event,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},a.each=function(e,t){var a,n=this;if("function"!=typeof t)return n;if(e=e||[],e.constructor===Object){for(a in e)if(t.call(e[a],a,e[a]))break}else for(a=0;a80?window.console&&console.error(o+".css: Invalid"):void(1989===parseInt(a.getStyle(t.getElementById(s),"width"))?n():setTimeout(c,100))}()},n.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),a.each(t,function(t,a){new RegExp("\\b"+a+"\\b").test(e)||(e=e+" "+a)}),e.replace(/^\s|\s$/,"")},n.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),a.each(t,function(t,a){var n=new RegExp("\\b"+a+"\\b");n.test(e)&&(e=e.replace(n,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},n.prototype.find=function(e){var t=this,n=0,i=[],l="object"==typeof e;return this.each(function(a,r){for(var o=l?[e]:r.querySelectorAll(e||null);n0)return a[0].getAttribute(e)}():a.each(function(a,n){n.setAttribute(e,t)})},n.prototype.removeAttr=function(e){return this.each(function(t,a){a.removeAttribute(e)})},n.prototype.html=function(e){return this.each(function(t,a){a.innerHTML=e})},n.prototype.val=function(e){return this.each(function(t,a){a.value=e})},n.prototype.append=function(e){return this.each(function(t,a){"object"==typeof e?a.appendChild(e):a.innerHTML=a.innerHTML+e})},n.prototype.remove=function(e){return this.each(function(t,a){e?a.removeChild(e):a.parentNode.removeChild(a)})},n.prototype.on=function(e,t){return this.each(function(a,n){n.attachEvent?n.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(n,e)}):n.addEventListener(e,t,!1)})},n.prototype.off=function(e,t){return this.each(function(a,n){n.detachEvent?n.detachEvent("on"+e,t):n.removeEventListener(e,t,!1)})},window.lay=a,window.layui&&layui.define&&layui.define(function(t){t(e,a)})}(),!function(e){"use strict";var t=e.layui&&layui.define,a={getPath:e.lay&&lay.getPath?lay.getPath():"",link:function(t,a,i){n.path&&e.lay&&lay.link&&lay.link(n.path+t,a,i)}},n={v:"5.1.0",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:a.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var i="laydate",l="",r=(t?"modules/laydate/":"theme/")+"default/laydate.css?v="+n.v+l;return t?layui.addcss(r,e,i):a.link(r,e,i),this}},i=function(){var e=this;return{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",r=".layui-laydate",o="layui-this",s="laydate-disabled",y="开始时间不能早于结束时间
请重新选择",c=[100,2e5],d="layui-laydate-static",m="layui-laydate-list",u="laydate-selected",h="layui-laydate-hint",f="laydate-day-prev",p="laydate-day-next",g="layui-laydate-footer",v=".laydate-btns-confirm",T="laydate-time-text",D=".laydate-btns-time",w=function(e){var t=this;t.index=++n.index,t.config=lay.extend({},t.config,n.config,e),n.ready(function(){t.init()})};w.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},w.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"focus",show:!1,showBottom:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},w.prototype.lang=function(){var e=this,t=e.config,a={cn:{weeks:["日","一","二","三","四","五","六"],time:["时","分","秒"],timeTips:"选择时间",startTime:"开始时间",endTime:"结束时间",dateTips:"返回日期",month:["一","二","三","四","五","六","七","八","九","十","十一","十二"],tools:{confirm:"确定",clear:"清空",now:"现在"}},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"}}};return a[t.lang]||a.cn},w.prototype.init=function(){var e=this,t=e.config,a="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s",n="static"===t.position,i={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};t.elem=lay(t.elem),t.eventElem=lay(t.eventElem),t.elem[0]&&(t.range===!0&&(t.range="-"),t.format===i.date&&(t.format=i[t.type]),e.format=t.format.match(new RegExp(a+"|.","g"))||[],e.EXP_IF="",e.EXP_SPLIT="",lay.each(e.format,function(t,n){var i=new RegExp(a).test(n)?"\\d{"+function(){return new RegExp(a).test(e.format[0===t?t+1:t-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;e.EXP_IF=e.EXP_IF+i,e.EXP_SPLIT=e.EXP_SPLIT+"("+i+")"}),e.EXP_IF=new RegExp("^"+(t.range?e.EXP_IF+"\\s\\"+t.range+"\\s"+e.EXP_IF:e.EXP_IF)+"$"),e.EXP_SPLIT=new RegExp("^"+e.EXP_SPLIT+"$",""),e.isInput(t.elem[0])||"focus"===t.trigger&&(t.trigger="click"),t.elem.attr("lay-key")||(t.elem.attr("lay-key",e.index),t.eventElem.attr("lay-key",e.index)),t.mark=lay.extend({},t.calendar&&"cn"===t.lang?{"0-1-1":"元旦","0-2-14":"情人","0-3-8":"妇女","0-3-12":"植树","0-4-1":"愚人","0-5-1":"劳动","0-5-4":"青年","0-6-1":"儿童","0-9-10":"教师","0-9-18":"国耻","0-10-1":"国庆","0-12-25":"圣诞"}:{},t.mark),lay.each(["min","max"],function(e,a){var n=[],i=[];if("number"==typeof t[a]){var l=t[a],r=(new Date).getTime(),o=864e5,s=new Date(l?l0)return!0;var n=lay.elem("div",{"class":"layui-laydate-header"}),i=[function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("div",{"class":"laydate-set-ym"}),t=lay.elem("span"),a=lay.elem("span");return e.appendChild(t),e.appendChild(a),e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],y=lay.elem("div",{"class":"layui-laydate-content"}),c=lay.elem("table"),d=lay.elem("thead"),m=lay.elem("tr");lay.each(i,function(e,t){n.appendChild(t)}),d.appendChild(m),lay.each(new Array(6),function(e){var t=c.insertRow(0);lay.each(new Array(7),function(n){if(0===e){var i=lay.elem("th");i.innerHTML=a.weeks[n],m.appendChild(i)}t.insertCell(n)})}),c.insertBefore(d,c.children[0]),y.appendChild(c),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(n),l[e].appendChild(y),r.push(i),o.push(y),s.push(c)}),lay(y).html(function(){var e=[],i=[];return"datetime"===t.type&&e.push(''+a.timeTips+""),lay.each(t.btns,function(e,l){var r=a.tools[l]||"btn";t.range&&"now"===l||(n&&"clear"===l&&(r="cn"===t.lang?"重置":"Reset"),i.push(''+r+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){i.appendChild(t)}),t.showBottom&&i.appendChild(y),/^#/.test(t.theme)){var c=lay.elem("style"),m=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,t.theme);"styleSheet"in c?(c.setAttribute("type","text/css"),c.styleSheet.cssText=m):c.innerHTML=m,lay(i).addClass("laydate-theme-molv"),i.appendChild(c)}e.remove(w.thisElemDate),n?t.elem.append(i):(document.body.appendChild(i),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),w.thisElemDate=e.elemID,"function"==typeof t.ready&&t.ready(lay.extend({},t.dateTime,{month:t.dateTime.month+1}))},w.prototype.remove=function(e){var t=this,a=(t.config,lay("#"+(e||t.elemID)));return a.hasClass(d)||t.checkDate(function(){a.remove(),delete t.endDate}),t},w.prototype.position=function(){var e=this,t=e.config,a=e.bindElem||t.elem[0],n=a.getBoundingClientRect(),i=e.elem.offsetWidth,l=e.elem.offsetHeight,r=function(e){return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e]},o=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},s=5,y=n.left,c=n.bottom;y+i+s>o("width")&&(y=o("width")-i-s),c+l+s>o()&&(c=n.top>l?n.top-l:o()-l,c-=2*s),t.position&&(e.elem.style.position=t.position),e.elem.style.left=y+("fixed"===t.position?0:r(1))+"px",e.elem.style.top=c+("fixed"===t.position?0:r())+"px"},w.prototype.hint=function(e){var t=this,a=(t.config,lay.elem("div",{"class":h}));t.elem&&(a.innerHTML=e||"",lay(t.elem).find("."+h).remove(),t.elem.appendChild(a),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+h).remove()},3e3))},w.prototype.getAsYM=function(e,t,a){return a?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},w.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},w.prototype.checkDate=function(e){var t,a,i=this,l=(new Date,i.config),r=l.dateTime=l.dateTime||i.systemDate(),o=i.bindElem||l.elem[0],s=(i.isInput(o)?"val":"html",i.isInput(o)?o.value:"static"===l.position?"":o.innerHTML),y=function(e){e.year>c[1]&&(e.year=c[1],a=!0),e.month>11&&(e.month=11,a=!0),e.hours>23&&(e.hours=0,a=!0),e.minutes>59&&(e.minutes=0,e.hours++,a=!0),e.seconds>59&&(e.seconds=0,e.minutes++,a=!0),t=n.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,a=!0)},d=function(e,t,n){var r=["startTime","endTime"];t=(t.match(i.EXP_SPLIT)||[]).slice(1),n=n||0,l.range&&(i[r[n]]=i[r[n]]||{}),lay.each(i.format,function(o,s){var y=parseFloat(t[o]);t[o].length必须遵循下述格式:
"+(l.range?l.format+" "+l.range+" "+l.format:l.format)+"
已为你重置"),a=!0):s&&s.constructor===Date?l.dateTime=i.systemDate(s):(l.dateTime=i.systemDate(),delete i.startTime,delete i.endTime),y(r),a&&s&&i.setValue(l.range?i.endDate?i.parse():"":i.parse()),e&&e(),i)},w.prototype.mark=function(e,t){var a,n=this,i=n.config;return lay.each(i.mark,function(e,n){var i=e.split("-");i[0]!=t[0]&&0!=i[0]||i[1]!=t[1]&&0!=i[1]||i[2]!=t[2]||(a=n||t[2])}),a&&e.html(''+a+""),n},w.prototype.limit=function(e,t,a,n){var i,l=this,r=l.config,o={},y=r[a>41?"endDate":"dateTime"],c=lay.extend({},y,t||{});return lay.each({now:c,min:r.min,max:r.max},function(e,t){o[e]=l.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(n,function(a,n){e[n]=t[n]}),e}())).getTime()}),i=o.nowo.max,e&&e[i?"addClass":"removeClass"](s),i},w.prototype.thisDateTime=function(e){var t=this,a=t.config;return e?t.endDate:a.dateTime},w.prototype.calendar=function(e,t,a){var i,l,r,s=this,y=s.config,t=t?1:0,d=e||s.thisDateTime(t),m=new Date,u=s.lang(),h="date"!==y.type&&"datetime"!==y.type,f=lay(s.table[t]).find("td"),p=lay(s.elemHeader[t][2]).find("span");return d.yearc[1]&&(d.year=c[1],s.hint("最高只能支持到公元"+c[1]+"年")),s.firstDate||(s.firstDate=lay.extend({},d)),m.setFullYear(d.year,d.month,1),i=m.getDay(),l=n.getEndDate(d.month||12,d.year),r=n.getEndDate(d.month+1,d.year),lay.each(f,function(e,t){var a=[d.year,d.month],n=0;t=lay(t),t.removeAttr("class"),e=i&&e=a.firstDate.year&&(l.month=n.max.month,l.date=n.max.date),a.limit(lay(i),l,t),x++}),lay(d[f?0:1]).attr("lay-ym",x-8+"-"+g[1]).html(M+p+" - "+(x-1+p))}else if("month"===e)lay.each(new Array(12),function(e){var i=lay.elem("li",{"lay-ym":e}),r={year:g[0],month:e};e+1==g[1]&&lay(i).addClass(o),i.innerHTML=l.month[e]+(f?"月":""),y.appendChild(i),g[0]=a.firstDate.year&&(r.date=n.max.date),a.limit(lay(i),r,t)}),lay(d[f?0:1]).attr("lay-ym",g[0]+"-"+g[1]).html(g[0]+p);else if("time"===e){var b=function(){lay(y).find("ol").each(function(e,n){lay(n).find("li").each(function(n,i){a.limit(lay(i),[{hours:n},{hours:a[C].hours,minutes:n},{hours:a[C].hours,minutes:a[C].minutes,seconds:n}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),n.range||a.limit(lay(a.footer).find(v),a[C],0,["hours","minutes","seconds"])};n.range?a[C]||(a[C]={hours:0,minutes:0,seconds:0}):a[C]=i,lay.each([24,60,60],function(e,t){var n=lay.elem("li"),i=["

"+l.time[e]+"

    "];lay.each(new Array(t),function(t){i.push(""+lay.digit(t,2)+"")}),n.innerHTML=i.join("")+"
",y.appendChild(n)}),b()}if(h&&u.removeChild(h),u.appendChild(y),"year"===e||"month"===e)lay(a.elemMain[t]).addClass("laydate-ym-show"),lay(y).find("li").on("click",function(){var l=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(s)){0===t?(i[e]=l,a.limit(lay(a.footer).find(v),null,0)):a.endDate[e]=l;var c="year"===n.type||"month"===n.type;c?(lay(y).find("."+o).removeClass(o),lay(this).addClass(o),"month"===n.type&&"year"===e&&(a.listYM[t][0]=l,r&&(t?i.year=l:a.endDate.year=l),a.list("month",t))):(a.checkDate("limit").calendar(null,t),a.closeList()),a.setBtnStatus(),n.range||(("month"===n.type&&"month"===e||"year"===n.type&&"year"===e)&&a.setValue(a.parse()).remove().done(),a.done(null,"change")),lay(a.footer).find(D).removeClass(s)}});else{var E=lay.elem("span",{"class":T}),k=function(){lay(y).find("ol").each(function(e){var t=this,n=lay(t).find("li");t.scrollTop=30*(a[C][w[e]]-2),t.scrollTop<=0&&n.each(function(e,a){if(!lay(this).hasClass(s))return t.scrollTop=30*(e-2),!0})})},H=lay(c[2]).find("."+T);k(),E.innerHTML=n.range?[l.startTime,l.endTime][t]:l.timeTips,lay(a.elemMain[t]).addClass("laydate-time-show"),H[0]&&H.remove(),c[2].appendChild(E),lay(y).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var l=0|this.innerHTML;lay(this).hasClass(s)||(n.range?a[C][w[e]]=l:i[w[e]]=l,lay(t).find("."+o).removeClass(o),lay(this).addClass(o),b(),k(),(a.endDate||"time"===n.type)&&a.done(null,"change"),a.setBtnStatus())})})}return a},w.prototype.listYM=[],w.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,a){lay(this).find("."+m).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+T).remove()},w.prototype.setBtnStatus=function(e,t,a){var n,i=this,l=i.config,r=lay(i.footer).find(v);l.range&&"time"!==l.type&&(t=t||l.dateTime,a=a||i.endDate,n=i.newDate(t).getTime()>i.newDate(a).getTime(),i.limit(null,t)||i.limit(null,a)?r.addClass(s):r[n?"addClass":"removeClass"](s),e&&n&&i.hint("string"==typeof e?y.replace(/日期/g,e):y))},w.prototype.parse=function(e,t){var a=this,n=a.config,i=t||(e?lay.extend({},a.endDate,a.endTime):n.range?lay.extend({},n.dateTime,a.startTime):n.dateTime),l=a.format.concat();return lay.each(l,function(e,t){/yyyy|y/.test(t)?l[e]=lay.digit(i.year,t.length):/MM|M/.test(t)?l[e]=lay.digit(i.month+1,t.length):/dd|d/.test(t)?l[e]=lay.digit(i.date,t.length):/HH|H/.test(t)?l[e]=lay.digit(i.hours,t.length):/mm|m/.test(t)?l[e]=lay.digit(i.minutes,t.length):/ss|s/.test(t)&&(l[e]=lay.digit(i.seconds,t.length))}),n.range&&!e?l.join("")+" "+n.range+" "+a.parse(1):l.join("")},w.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},w.prototype.setValue=function(e){var t=this,a=t.config,n=t.bindElem||a.elem[0],i=t.isInput(n)?"val":"html";return"static"===a.position||lay(n)[i](e||""),this},w.prototype.stampRange=function(){var e,t,a=this,n=a.config,i=n.dateTime,l=lay(a.elem).find("td");if(n.range&&!a.endDate&&lay(a.footer).find(v).addClass(s),a.endDate)return e=a.newDate({year:i.year,month:i.month,date:i.date}).getTime(),t=a.newDate({year:a.endDate.year,month:a.endDate.month,date:a.endDate.date}).getTime(),e>t?a.hint(y):void lay.each(l,function(n,i){var l=lay(i).attr("lay-ymd").split("-"),r=a.newDate({year:l[0],month:l[1]-1,date:l[2]}).getTime();lay(i).removeClass(u+" "+o),r!==e&&r!==t||lay(i).addClass(lay(i).hasClass(f)||lay(i).hasClass(p)?u:o),r>e&&r