From f3ccfc871fe6d25b4147e85b8084bdd7474eab7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsin@users.noreply.github.com> Date: Fri, 21 May 2021 23:03:58 +0800 Subject: [PATCH] update --- dist/laydate.js | 5 +- gulpfile.js | 2 +- package.json | 2 +- src/laydate.js | 871 +++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 758 insertions(+), 122 deletions(-) diff --git a/dist/laydate.js b/dist/laydate.js index 2af9779..98a1e6a 100644 --- a/dist/laydate.js +++ b/dist/laydate.js @@ -1,2 +1,3 @@ -/*! layDate v5.3.0 | 日期与时间组件 | The MIT License */ - ;!function(){"use strict";var e="lay",t=window.document,n=function(e){return new a(e)},a=function(e){for(var n=0,a="object"==typeof e?[e]:(this.selector=e,t.querySelectorAll(e||null));n0;i--)if("interactive"===n[i].readyState){e=n[i].src;break}return e||n[a].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 n,a=this;if("function"!=typeof t)return a;if(e=e||[],e.constructor===Object){for(n in e)if(t.call(e[n],n,e[n]))break}else for(n=0;n1e4/i?window.console&&console.error(o+".css: Invalid"):void(1989===parseInt(n.getStyle(r,"width"))?(e===c&&r.removeAttribute("lay-status"),r.getAttribute("lay-status")===c?setTimeout(d,i):a()):(r.setAttribute("lay-status",c),setTimeout(function(){d(c)},i)))}()},n.hasScrollbar=function(){return t.body.scrollHeight>(window.innerHeight||t.documentElement.clientHeight)},n.position=function(e,a,i){if(a){i=i||{},e!==t&&e!==n("body")[0]||(i.clickType="right");var r="right"===i.clickType?function(){var e=i.e||window.event||{};return{left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY}}():e.getBoundingClientRect(),l=a.offsetWidth,o=a.offsetHeight,s=function(e){return e=e?"scrollLeft":"scrollTop",t.body[e]|t.documentElement[e]},c=function(e){return t.documentElement[e?"clientWidth":"clientHeight"]},y=5,d=r.left,u=r.bottom;d+l+y>c("width")&&(d=c("width")-l-y),u+o+y>c()&&(r.top>o+y?u=r.top-o-2*y:"right"===i.clickType&&(u=c()-o-2*y,u<0&&(u=0)));var m=i.position;if(m&&(a.style.position=m),a.style.left=d+("fixed"===m?0:s(1))+"px",a.style.top=u+("fixed"===m?0:s())+"px",!n.hasScrollbar()){var h=a.getBoundingClientRect();!i.SYSTEM_RELOAD&&h.bottom+y>c()&&(i.SYSTEM_RELOAD=!0,setTimeout(function(){n.position(e,a,i)},50))}}},n.options=function(e,t){var a=n(e),i=t||"lay-options";try{return new Function("return "+(a.attr(i)||"{}"))()}catch(r){return hint.error("parseerror\uff1a"+r,"error"),{}}},n.isTopElem=function(e){var a=[t,n("body")[0]],i=!1;return n.each(a,function(t,n){if(n===e)return i=!0}),i},a.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),n.each(t,function(t,n){new RegExp("\\b"+n+"\\b").test(e)||(e=e+" "+n)}),e.replace(/^\s|\s$/,"")},a.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),n.each(t,function(t,n){var a=new RegExp("\\b"+n+"\\b");a.test(e)&&(e=e.replace(a,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},a.prototype.find=function(e){var t=this,a=0,i=[],r="object"==typeof e;return this.each(function(n,l){for(var o=r?l.contains(e):l.querySelectorAll(e||null);a0)return a[0].style[e]}():a.each(function(a,r){"object"==typeof e?n.each(e,function(e,t){r.style[e]=i(t)}):r.style[e]=i(t)})},a.prototype.width=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetWidth}():t.each(function(n,a){t.css("width",e)})},a.prototype.height=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetHeight}():t.each(function(n,a){t.css("height",e)})},a.prototype.attr=function(e,t){var n=this;return void 0===t?function(){if(n.length>0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},a.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},a.prototype.html=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].innerHTML}():this.each(function(t,n){n.innerHTML=e})},a.prototype.val=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].value}():this.each(function(t,n){n.value=e})},a.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},a.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},a.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},a.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.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,n={getPath:e.lay&&lay.getPath?lay.getPath():"",link:function(t,n,a){i.path&&e.lay&&lay.link&&lay.link(i.path+t,n,a)}},a=e.LAYUI_GLOBAL||{},i={v:"5.3.0",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:a.laydate_dir||n.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var a="laydate",r="",l=(t?"modules/laydate/":"theme/")+"default/laydate.css?v="+i.v+r;return t?layui.addcss(l,e,a):n.link(l,e,a),this}},r=function(){var e=this,t=e.config,n=t.id;return r.that[n]=e,{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",o=".layui-laydate",s="layui-this",c="laydate-disabled",y=[100,2e5],d="layui-laydate-static",u="layui-laydate-list",m="layui-laydate-hint",h="layui-laydate-footer",f=".laydate-btns-confirm",p="laydate-time-text",g="laydate-btns-time",v="layui-laydate-preview",T=function(e){var t=this;t.index=++i.index,t.config=lay.extend({},t.config,i.config,e),e=t.config,e.id="id"in e?e.id:t.index,i.ready(function(){t.init()})},D="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s";r.formatArr=function(e){return(e||"").match(new RegExp(D+"|.","g"))||[]},T.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},T.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"click",show:!1,showBottom:!0,isPreview:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},T.prototype.lang=function(){var e=this,t=e.config,n={cn:{weeks:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],time:["\u65f6","\u5206","\u79d2"],timeTips:"\u9009\u62e9\u65f6\u95f4",startTime:"\u5f00\u59cb\u65f6\u95f4",endTime:"\u7ed3\u675f\u65f6\u95f4",dateTips:"\u8fd4\u56de\u65e5\u671f",month:["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"],tools:{confirm:"\u786e\u5b9a",clear:"\u6e05\u7a7a",now:"\u73b0\u5728"},timeout:"\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f00\u59cb\u65f6\u95f4
\u8bf7\u91cd\u65b0\u9009\u62e9",invalidDate:"\u4e0d\u5728\u6709\u6548\u65e5\u671f\u6216\u65f6\u95f4\u8303\u56f4\u5185",formatError:["\u65e5\u671f\u683c\u5f0f\u4e0d\u5408\u6cd5
\u5fc5\u987b\u9075\u5faa\u4e0b\u8ff0\u683c\u5f0f\uff1a
","
\u5df2\u4e3a\u4f60\u91cd\u7f6e"],preview:"\u5f53\u524d\u9009\u4e2d\u7684\u7ed3\u679c"},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"},timeout:"End time cannot be less than start Time
Please re-select",invalidDate:"Invalid date",formatError:["The date format error
Must be followed\uff1a
","
It has been reset"],preview:"The selected result"}};return n[t.lang]||n.cn},T.prototype.init=function(){var t=this,n=t.config,a="static"===n.position,i={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};n.elem=lay(n.elem),n.eventElem=lay(n.eventElem),n.elem[0]&&(t.rangeStr=n.range?"string"==typeof n.range?n.range:"-":"",n.range&&n.range.constructor===Array&&(t.rangeElem=[lay(n.range[0]),lay(n.range[1])]),i[n.type]||(e.console&&console.error&&console.error("laydate type error:'"+n.type+"' is not supported"),n.type="date"),n.format===i.date&&(n.format=i[n.type]||i.date),t.format=r.formatArr(n.format),t.EXP_IF="",t.EXP_SPLIT="",lay.each(t.format,function(e,n){var a=new RegExp(D).test(n)?"\\d{"+function(){return new RegExp(D).test(t.format[0===e?e+1:e-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;t.EXP_IF=t.EXP_IF+a,t.EXP_SPLIT=t.EXP_SPLIT+"("+a+")"}),t.EXP_IF_ONE=new RegExp("^"+t.EXP_IF+"$"),t.EXP_IF=new RegExp("^"+(n.range?t.EXP_IF+"\\s\\"+t.rangeStr+"\\s"+t.EXP_IF:t.EXP_IF)+"$"),t.EXP_SPLIT=new RegExp("^"+t.EXP_SPLIT+"$",""),t.isInput(n.elem[0])||"focus"===n.trigger&&(n.trigger="click"),n.elem.attr("lay-key")||(n.elem.attr("lay-key",t.index),n.eventElem.attr("lay-key",t.index)),n.mark=lay.extend({},n.calendar&&"cn"===n.lang?{"0-1-1":"\u5143\u65e6","0-2-14":"\u60c5\u4eba","0-3-8":"\u5987\u5973","0-3-12":"\u690d\u6811","0-4-1":"\u611a\u4eba","0-5-1":"\u52b3\u52a8","0-5-4":"\u9752\u5e74","0-6-1":"\u513f\u7ae5","0-9-10":"\u6559\u5e08","0-9-18":"\u56fd\u803b","0-10-1":"\u56fd\u5e86","0-12-25":"\u5723\u8bde"}:{},n.mark),lay.each(["min","max"],function(e,t){var a=[],i=[];if("number"==typeof n[t]){var r=n[t],l=(new Date).getTime(),o=864e5,s=new Date(r?r0)return!0;var a=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"),n=lay.elem("span");return e.appendChild(t),e.appendChild(n),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}()],r=lay.elem("div",{"class":"layui-laydate-content"}),y=lay.elem("table"),d=lay.elem("thead"),u=lay.elem("tr");lay.each(i,function(e,t){a.appendChild(t)}),d.appendChild(u),lay.each(new Array(6),function(e){var t=y.insertRow(0);lay.each(new Array(7),function(a){if(0===e){var i=lay.elem("th");i.innerHTML=n.weeks[a],u.appendChild(i)}t.insertCell(a)})}),y.insertBefore(d,y.children[0]),r.appendChild(y),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(a),l[e].appendChild(r),o.push(i),s.push(r),c.push(y)}),lay(y).html(function(){var e=[],i=[];return"datetime"===t.type&&e.push(''+n.timeTips+""),(t.range||"datetime"!==t.type)&&e.push(''),lay.each(t.btns,function(e,r){var l=n.tools[r]||"btn";t.range&&"now"===r||(a&&"clear"===r&&(l="cn"===t.lang?"\u91cd\u7f6e":"Reset"),i.push(''+l+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){r.appendChild(t)}),t.showBottom&&r.appendChild(y),/^#/.test(t.theme)){var u=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 u?(u.setAttribute("type","text/css"),u.styleSheet.cssText=m):u.innerHTML=m,lay(r).addClass("laydate-theme-molv"),r.appendChild(u)}i.thisId=t.id,e.remove(T.thisElemDate),a?t.elem.append(r):(document.body.appendChild(r),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),T.thisElemDate=e.elemID,"function"==typeof t.ready&&t.ready(lay.extend({},t.dateTime,{month:t.dateTime.month+1})),e.preview()},T.prototype.remove=function(e){var t=this,n=(t.config,lay("#"+(e||t.elemID)));return n[0]?(n.hasClass(d)||t.checkDate(function(){n.remove()}),t):t},T.prototype.position=function(){var e=this,t=e.config;return lay.position(e.bindElem||t.elem[0],e.elem,{position:t.position}),e},T.prototype.hint=function(e){var t=this,n=(t.config,lay.elem("div",{"class":m}));t.elem&&(n.innerHTML=e||"",lay(t.elem).find("."+m).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+m).remove()},3e3))},T.prototype.getAsYM=function(e,t,n){return n?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},T.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}},T.prototype.checkDate=function(e){var t,n,a=this,r=(new Date,a.config),l=a.lang(),o=r.dateTime=r.dateTime||a.systemDate(),s=a.bindElem||r.elem[0],c=(a.isInput(s)?"val":"html",function(){if(a.rangeElem){var e=[a.rangeElem[0].val(),a.rangeElem[1].val()];if(e[0]&&e[1])return e.join(" "+a.rangeStr+" ")}return a.isInput(s)?s.value:"static"===r.position?"":lay(s).attr("lay-date")}()),d=function(e){e.year>y[1]&&(e.year=y[1],n=!0),e.month>11&&(e.month=11,n=!0),e.hours>23&&(e.hours=0,n=!0),e.minutes>59&&(e.minutes=0,e.hours++,n=!0),e.seconds>59&&(e.seconds=0,e.minutes++,n=!0),t=i.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,n=!0)},u=function(e,t,i){var l=["startTime","endTime"];t=(t.match(a.EXP_SPLIT)||[]).slice(1),i=i||0,r.range&&(a[l[i]]=a[l[i]]||{}),lay.each(a.format,function(o,s){var c=parseFloat(t[o]);t[o].lengthh(r.max)||h(o)h(r.max))&&(a.endDate=lay.extend({},r.max)),e&&e(),a},T.prototype.mark=function(e,t){var n,a=this,i=a.config;return lay.each(i.mark,function(e,a){var i=e.split("-");i[0]!=t[0]&&0!=i[0]||i[1]!=t[1]&&0!=i[1]||i[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},T.prototype.limit=function(e,t,n,a){var i,r=this,l=r.config,o={},s=l[n>41?"endDate":"dateTime"],y=lay.extend({},s,t||{});return lay.each({now:y,min:l.min,max:l.max},function(e,t){o[e]=r.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),i=o.nowo.max,e&&e[i?"addClass":"removeClass"](c),i},T.prototype.thisDateTime=function(e){var t=this,n=t.config;return e?t.endDate:n.dateTime},T.prototype.calendar=function(e,t,n){var a,r,l,o=this,c=o.config,t=t?1:0,d=e||o.thisDateTime(t),u=new Date,m=o.lang(),h="date"!==c.type&&"datetime"!==c.type,p=lay(o.table[t]).find("td"),g=lay(o.elemHeader[t][2]).find("span");return d.yeary[1]&&(d.year=y[1],o.hint(m.invalidDate)),o.firstDate||(o.firstDate=lay.extend({},d)),u.setFullYear(d.year,d.month,1),a=u.getDay(),r=i.getEndDate(d.month||12,d.year),l=i.getEndDate(d.month+1,d.year),lay.each(p,function(e,t){var n=[d.year,d.month],i=0;t=lay(t),t.removeAttr("class"),e=a&&e=n.firstDate.year&&(r.month=a.max.month,r.date=a.max.date),n.limit(lay(i),r,t),x++}),lay(d[v?0:1]).attr("lay-ym",x-8+"-"+D[1]).html(b+T+" - "+(x-1+T))}else if("month"===e)lay.each(new Array(12),function(e){var i=lay.elem("li",{"lay-ym":e}),l={year:D[0],month:e};e+1==D[1]&&lay(i).addClass(s),i.innerHTML=r.month[e]+(v?"\u6708":""),o.appendChild(i),D[0]=n.firstDate.year&&(l.date=a.max.date),n.limit(lay(i),l,t)}),lay(d[v?0:1]).attr("lay-ym",D[0]+"-"+D[1]).html(D[0]+T);else if("time"===e){var M=function(){lay(o).find("ol").each(function(e,a){lay(a).find("li").each(function(a,i){n.limit(lay(i),[{hours:a},{hours:n[E].hours,minutes:a},{hours:n[E].hours,minutes:n[E].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(lay(n.footer).find(f),n[E],0,["hours","minutes","seconds"])};a.range?n[E]||(n[E]="startTime"===E?i:n.endDate):n[E]=i,lay.each([24,60,60],function(e,t){var a=lay.elem("li"),i=["

"+r.time[e]+"

    "];lay.each(new Array(t),function(t){i.push(""+lay.digit(t,2)+"")}),a.innerHTML=i.join("")+"
",o.appendChild(a)}),M()}if(h&&m.removeChild(h),m.appendChild(o),"year"===e||"month"===e)lay(n.elemMain[t]).addClass("laydate-ym-show"),lay(o).find("li").on("click",function(){var r=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(c)){0===t?(i[e]=r,n.limit(lay(n.footer).find(f),null,0)):n.endDate[e]=r;var y="year"===a.type||"month"===a.type;y?(lay(o).find("."+s).removeClass(s),lay(this).addClass(s),"month"===a.type&&"year"===e&&(n.listYM[t][0]=r,l&&(t?i.year=r:n.endDate.year=r),n.list("month",t))):(n.checkDate("limit").calendar(null,t),n.closeList()),n.setBtnStatus(),a.range||("month"===a.type&&"month"===e||"year"===a.type&&"year"===e)&&n.setValue(n.parse()).remove().done(),n.done(null,"change"),lay(n.footer).find("."+g).removeClass(c)}});else{var C=lay.elem("span",{"class":p}),S=function(){lay(o).find("ol").each(function(e){var t=this,a=lay(t).find("li");t.scrollTop=30*(n[E][w[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!lay(this).hasClass(c))return t.scrollTop=30*(e-2),!0})})},I=lay(y[2]).find("."+p);S(),C.innerHTML=a.range?[r.startTime,r.endTime][t]:r.timeTips,lay(n.elemMain[t]).addClass("laydate-time-show"),I[0]&&I.remove(),y[2].appendChild(C),lay(o).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var r=0|this.innerHTML;lay(this).hasClass(c)||(a.range?n[E][w[e]]=r:i[w[e]]=r,lay(t).find("."+s).removeClass(s),lay(this).addClass(s),M(),S(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},T.prototype.listYM=[],T.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,n){lay(this).find("."+u).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+p).remove()},T.prototype.setBtnStatus=function(e,t,n){var a,i=this,r=i.config,l=i.lang(),o=lay(i.footer).find(f);r.range&&"time"!==r.type&&(t=t||r.dateTime,n=n||i.endDate,a=i.newDate(t).getTime()>i.newDate(n).getTime(),i.limit(null,t)||i.limit(null,n)?o.addClass(c):o[a?"addClass":"removeClass"](c),e&&a&&i.hint("string"==typeof e?l.timeout.replace(/\u65e5\u671f/g,e):l.timeout))},T.prototype.parse=function(e,t){var n=this,a=n.config,r=t||("end"==e?lay.extend({},n.endDate,n.endTime):a.range?lay.extend({},a.dateTime,n.startTime):a.dateTime),l=i.parse(r,n.format,1);return a.range&&void 0===e?l+" "+n.rangeStr+" "+n.parse("end"):l},T.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)},T.prototype.setValue=function(e){var t=this,n=t.config,a=t.bindElem||n.elem[0];return"static"===n.position?t:(e=e||"",t.isInput(a)?lay(a).val(e):t.rangeElem?(t.rangeElem[0].val(e?t.parse("start"):""),t.rangeElem[1].val(e?t.parse("end"):"")):(0===lay(a).find("*").length&&lay(a).html(e),lay(a).attr("lay-date",e)),t)},T.prototype.preview=function(){var e=this,t=e.config;if(t.isPreview){var n=lay(e.elem).find("."+v),a=t.range?e.endDate?e.parse():"":e.parse();n.html(a).css({color:"#5FB878","font-size":"14px;"}),setTimeout(function(){n.css({color:"#666","font-size":"12px;"})},300)}},T.prototype.done=function(e,t){var n=this,a=n.config,i=lay.extend({},lay.extend(a.dateTime,n.startTime)),r=lay.extend({},lay.extend(n.endDate,n.endTime));return lay.each([i,r],function(e,t){"month"in t&&lay.extend(t,{month:t.month+1})}),n.preview(),e=e||[n.parse(),i,r],"function"==typeof a[t||"done"]&&a[t||"done"].apply(a,e),n},T.prototype.choose=function(e,t){var n=this,a=n.config,i=n.thisDateTime(t),r=(lay(n.elem).find("td"),e.attr("lay-ymd").split("-"));r={year:0|r[0],month:(0|r[1])-1,date:0|r[2]},e.hasClass(c)||(lay.extend(i,r),a.range?(lay.each(["startTime","endTime"],function(e,t){n[t]=n[t]||{hours:0,minutes:0,seconds:0}}),n.calendar(null,t).done(null,"change")):"static"===a.position?n.calendar().done().done(null,"change"):"date"===a.type?n.setValue(n.parse()).remove().done():"datetime"===a.type&&n.calendar().done(null,"change"))},T.prototype.tool=function(e,t){var n=this,a=n.config,i=n.lang(),r=a.dateTime,l="static"===a.position,o={datetime:function(){lay(e).hasClass(c)||(n.list("time",0),a.range&&n.list("time",1),lay(e).attr("lay-type","date").html(n.lang().dateTips))},date:function(){n.closeList(),lay(e).attr("lay-type","datetime").html(n.lang().timeTips)},clear:function(){l&&(lay.extend(r,n.firstDate),n.calendar()),a.range&&(delete a.dateTime,delete n.endDate,delete n.startTime,delete n.endTime),n.setValue("").remove(),n.done(["",{},{}])},now:function(){var e=new Date;lay.extend(r,n.systemDate(),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}),n.setValue(n.parse()).remove(),l&&n.calendar(),n.done()},confirm:function(){if(a.range){if(lay(e).hasClass(c))return n.hint("time"===a.type?i.timeout.replace(/\u65e5\u671f/g,"\u65f6\u95f4"):i.timeout)}else if(lay(e).hasClass(c))return n.hint(i.invalidDate);n.done(),n.setValue(n.parse()).remove()}};o[t]&&o[t]()},T.prototype.change=function(e){var t=this,n=t.config,a=t.thisDateTime(e),i=n.range&&("year"===n.type||"month"===n.type),r=t.elemCont[e||0],l=t.listYM[e],o=function(o){var s=lay(r).find(".laydate-year-list")[0],c=lay(r).find(".laydate-month-list")[0];return s&&(l[0]=o?l[0]-15:l[0]+15,t.list("year",e)),c&&(o?l[0]--:l[0]++,t.list("month",e)),(s||c)&&(lay.extend(a,{year:l[0]}),i&&(a.year=l[0]),n.range||t.done(null,"change"),n.range||t.limit(lay(t.footer).find(f),{year:l[0]})),t.setBtnStatus(),s||c};return{prevYear:function(){o("sub")||(a.year--,t.checkDate("limit").calendar(null,e),t.done(null,"change"))},prevMonth:function(){var n=t.getAsYM(a.year,a.month,"sub");lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextMonth:function(){var n=t.getAsYM(a.year,a.month);lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextYear:function(){o()||(a.year++,t.checkDate("limit").calendar(null,e),t.done(null,"change"))}}},T.prototype.changeEvent=function(){var e=this;e.config;lay(e.elem).on("click",function(e){lay.stope(e)}).on("mousedown",function(e){lay.stope(e)}),lay.each(e.elemHeader,function(t,n){lay(n[0]).on("click",function(n){e.change(t).prevYear()}),lay(n[1]).on("click",function(n){e.change(t).prevMonth()}),lay(n[2]).find("span").on("click",function(n){var a=lay(this),i=a.attr("lay-ym"),r=a.attr("lay-type");i&&(i=i.split("-"),e.listYM[t]=[0|i[0],0|i[1]],e.list(r,t),lay(e.footer).find("."+g).addClass(c))}),lay(n[3]).on("click",function(n){e.change(t).nextMonth()}),lay(n[4]).on("click",function(n){e.change(t).nextYear()})}),lay.each(e.table,function(t,n){var a=lay(n).find("td");a.on("click",function(){e.choose(lay(this),t)})}),lay(e.footer).find("span").on("click",function(){var t=lay(this).attr("lay-type");e.tool(this,t)})},T.prototype.isInput=function(e){return/input|textarea/.test(e.tagName.toLocaleLowerCase())},T.prototype.events=function(){var e=this,t=e.config,n=function(n,a){n.on(t.trigger,function(){a&&(e.bindElem=this),e.render()})};t.elem[0]&&!t.elem[0].eventHandler&&(n(t.elem,"bind"),n(t.eventElem),t.elem[0].eventHandler=!0)},r.that={},r.getThis=function(e){var t=r.that[e];return t||hint.error(e?l+" instance with ID '"+e+"' not found":"ID argument required"),t},n.run=function(t){t(document).on("mousedown",function(e){if(i.thisId){var n=r.getThis(i.thisId);if(n){var a=n.config;e.target!==a.elem[0]&&e.target!==a.eventElem[0]&&e.target!==t(a.closeStop)[0]&&n.remove()}}}).on("keydown",function(e){if(i.thisId){var n=r.getThis(i.thisId);n&&13===e.keyCode&&t("#"+n.elemID)[0]&&n.elemID===T.thisElemDate&&(e.preventDefault(),t(n.footer).find(f)[0].click())}}),t(e).on("resize",function(){if(i.thisId){var e=r.getThis(i.thisId);if(e)return!(!e.elem||!t(o)[0])&&void e.position()}})},i.render=function(e){var t=new T(e);return r.call(t)},i.parse=function(e,t,n){return e=e||{},"string"==typeof t&&(t=r.formatArr(t)),t=(t||[]).concat(),lay.each(t,function(a,i){/yyyy|y/.test(i)?t[a]=lay.digit(e.year,i.length):/MM|M/.test(i)?t[a]=lay.digit(e.month+(n||0),i.length):/dd|d/.test(i)?t[a]=lay.digit(e.date,i.length):/HH|H/.test(i)?t[a]=lay.digit(e.hours,i.length):/mm|m/.test(i)?t[a]=lay.digit(e.minutes,i.length):/ss|s/.test(i)&&(t[a]=lay.digit(e.seconds,i.length))}),t.join("")},i.getEndDate=function(e,t){var n=new Date;return n.setFullYear(t||n.getFullYear(),e||n.getMonth()+1,1),new Date(n.getTime()-864e5).getDate()},t?(i.ready(),layui.define("lay",function(e){i.path=layui.cache.dir,n.run(lay),e(l,i)})):"function"==typeof define&&define.amd?define(function(){return n.run(lay),i}):function(){i.ready(),n.run(e.lay),e.laydate=i}()}(window); \ No newline at end of file +/*! layDate v5.3.1 | 日期与时间组件 | MIT Licensed */ + ;!function(e){"use strict";var t=e.document,n={modules:{},status:{},timeout:10,event:{}},a=function(){this.v="2.6.7"},r=e.LAYUI_GLOBAL||{},i=function(){var e=t.currentScript?t.currentScript.src:function(){for(var e,n=t.scripts,a=n.length-1,r=a;r>0;r--)if("interactive"===n[r].readyState){e=n[r].src;break}return e||n[a].src}();return n.dir=r.dir||e.substring(0,e.lastIndexOf("/")+1)}(),o=function(t,n){n=n||"log",e.console&&console[n]&&console[n]("layui error hint: "+t)},l="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),s=n.builtin={lay:"lay",layer:"layer",laydate:"laydate",laypage:"laypage",laytpl:"laytpl",layedit:"layedit",form:"form",upload:"upload",dropdown:"dropdown",transfer:"transfer",tree:"tree",table:"table",element:"element",rate:"rate",colorpicker:"colorpicker",slider:"slider",carousel:"carousel",flow:"flow",util:"util",code:"code",jquery:"jquery",all:"all","layui.all":"layui.all"};a.prototype.cache=n,a.prototype.define=function(e,t){var a=this,r="function"==typeof e,i=function(){var e=function(e,t){u[e]=t,n.status[e]=!0};return"function"==typeof t&&t(function(a,r){e(a,r),n.callback[a]=function(){t(e)}}),this};return r&&(t=e,e=[]),a.use(e,i,null,"define"),a},a.prototype.use=function(a,r,c,y){function d(e,t){var a="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||a.test((e.currentTarget||e.srcElement).readyState))&&(n.modules[g]=t,p.removeChild(w),function r(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void(n.status[g]?m():setTimeout(r,4))}())}function m(){c.push(u[g]),a.length>1?f.use(a.slice(1),r,c,y):"function"==typeof r&&function(){return u.jquery&&"function"==typeof u.jquery&&"define"!==y?u.jquery(function(){r.apply(u,c)}):void r.apply(u,c)}()}var f=this,h=n.dir=n.dir?n.dir:i,p=t.getElementsByTagName("head")[0];a=function(){return"string"==typeof a?[a]:"function"==typeof a?(r=a,["all"]):a}(),e.jQuery&&jQuery.fn.on&&(f.each(a,function(e,t){"jquery"===t&&a.splice(e,1)}),u.jquery=u.$=jQuery);var g=a[0],v=0;if(c=c||[],n.host=n.host||(h.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===a.length||u["layui.all"]&&s[g])return m(),f;var T=(s[g]?h+"modules/":/^\{\/\}/.test(f.modules[g])?"":n.base||"")+(f.modules[g]||g)+".js";if(T=T.replace(/^\{\/\}/,""),!n.modules[g]&&u[g]&&(n.modules[g]=T),n.modules[g])!function D(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void("string"==typeof n.modules[g]&&n.status[g]?m():setTimeout(D,4))}();else{var w=t.createElement("script");w.async=!0,w.charset="utf-8",w.src=T+function(){var e=n.version===!0?n.v||(new Date).getTime():n.version||"";return e?"?v="+e:""}(),p.appendChild(w),!w.attachEvent||w.attachEvent.toString&&w.attachEvent.toString().indexOf("[native code")<0||l?w.addEventListener("load",function(e){d(e,T)},!1):w.attachEvent("onreadystatechange",function(e){d(e,T)}),n.modules[g]=T}return f},a.prototype.getStyle=function(t,n){var a=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return a[a.getPropertyValue?"getPropertyValue":"getAttribute"](n)},a.prototype.link=function(e,a,r){var i=this,l=t.getElementsByTagName("head")[0],s=t.createElement("link");"string"==typeof a&&(r=a);var c=(r||e).replace(/\.|\//g,""),u=s.id="layuicss-"+c,y="creating",d=0;return s.rel="stylesheet",s.href=e+(n.debug?"?v="+(new Date).getTime():""),s.media="all",t.getElementById(u)||l.appendChild(s),"function"!=typeof a?i:(function m(r){var l=100,s=t.getElementById(u);return++d>1e3*n.timeout/l?o(e+" timeout"):void(1989===parseInt(i.getStyle(s,"width"))?(r===y&&s.removeAttribute("lay-status"),s.getAttribute("lay-status")===y?setTimeout(m,l):a()):(s.setAttribute("lay-status",y),setTimeout(function(){m(y)},l)))}(),i)},a.prototype.addcss=function(e,t,a){return u.link(n.dir+"css/"+e,t,a)},n.callback={},a.prototype.factory=function(e){if(u[e])return"function"==typeof n.callback[e]?n.callback[e]:null},a.prototype.img=function(e,t,n){var a=new Image;return a.src=e,a.complete?t(a):(a.onload=function(){a.onload=null,"function"==typeof t&&t(a)},void(a.onerror=function(e){a.onerror=null,"function"==typeof n&&n(e)}))},a.prototype.config=function(e){e=e||{};for(var t in e)n[t]=e[t];return this},a.prototype.modules=function(){var e={};for(var t in s)e[t]=s[t];return e}(),a.prototype.extend=function(e){var t=this;e=e||{};for(var n in e)t[n]||t.modules[n]?o(n+" Module already exists","error"):t.modules[n]=e[n];return t},a.prototype.router=function(e){var t=this,e=e||location.hash,n={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),n.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),n.search[t[0]]=t[1]}():n.path.push(t)}),n):n},a.prototype.url=function(e){var t=this,n={pathname:function(){var t=e?function(){var t=(e.match(/\.[^.]+?\/.+/)||[])[0]||"";return t.replace(/^[^\/]+/,"").replace(/\?.+/,"")}():location.pathname;return t.replace(/^\//,"").split("/")}(),search:function(){var n={},a=(e?function(){var t=(e.match(/\?.+/)||[])[0]||"";return t.replace(/\#.+/,"")}():location.search).replace(/^\?+/,"").split("&");return t.each(a,function(e,t){var a=t.indexOf("="),r=function(){return a<0?t.substr(0,t.length):0!==a&&t.substr(0,a)}();r&&(n[r]=a>0?t.substr(a+1):null)}),n}(),hash:t.router(function(){return e?(e.match(/#.+/)||[])[0]||"/":location.hash}())};return n},a.prototype.data=function(t,n,a){if(t=t||"layui",a=a||localStorage,e.JSON&&e.JSON.parse){if(null===n)return delete a[t];n="object"==typeof n?n:{key:n};try{var r=JSON.parse(a[t])}catch(i){var r={}}return"value"in n&&(r[n.key]=n.value),n.remove&&delete r[n.key],a[t]=JSON.stringify(r),n.key?r[n.key]:r}},a.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},a.prototype.device=function(t){var n=navigator.userAgent.toLowerCase(),a=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(n.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(n)?"windows":/linux/.test(n)?"linux":/iphone|ipod|ipad|ios/.test(n)?"ios":/mac/.test(n)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((n.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:a("micromessenger")};return t&&!r[t]&&(r[t]=a(t)),r.android=/android/.test(n),r.ios="ios"===r.os,r.mobile=!(!r.android&&!r.ios),r},a.prototype.hint=function(){return{error:o}},a.prototype._typeof=function(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?function(){var t=Object.prototype.toString.call(e).match(/\s(.+)\]$/)||[],n="Function|Array|Date|RegExp|Object|Error|Symbol";return t=t[1]||"Object",new RegExp("\\b("+n+")\\b").test(t)?t.toLowerCase():"object"}():typeof e},a.prototype._isArray=function(t){var n,a=this,r=a._typeof(t);return!(!t||"object"!=typeof t||t===e)&&(n="length"in t&&t.length,"array"===r||0===n||"number"==typeof n&&n>0&&n-1 in t)},a.prototype.each=function(e,t){var n,a=this,r=function(e,n){return t.call(n[e],e,n[e])};if("function"!=typeof t)return a;if(e=e||[],a._isArray(e))for(n=0;n(window.innerHeight||d.documentElement.clientHeight)},m.position=function(e,t,n){if(t){n=n||{},e!==d&&e!==m("body")[0]||(n.clickType="right");var a="right"===n.clickType?function(){var e=n.e||window.event||{};return{left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY}}():e.getBoundingClientRect(),r=t.offsetWidth,i=t.offsetHeight,o=function(e){return e=e?"scrollLeft":"scrollTop",d.body[e]|d.documentElement[e]},l=function(e){return d.documentElement[e?"clientWidth":"clientHeight"]},s=5,c=a.left,u=a.bottom;c+r+s>l("width")&&(c=l("width")-r-s),u+i+s>l()&&(a.top>i+s?u=a.top-i-2*s:"right"===n.clickType&&(u=l()-i-2*s,u<0&&(u=0)));var y=n.position;if(y&&(t.style.position=y),t.style.left=c+("fixed"===y?0:o(1))+"px",t.style.top=u+("fixed"===y?0:o())+"px",!m.hasScrollbar()){var f=t.getBoundingClientRect();!n.SYSTEM_RELOAD&&f.bottom+s>l()&&(n.SYSTEM_RELOAD=!0,setTimeout(function(){m.position(e,t,n)},50))}}},m.options=function(e,t){var n=m(e),a=t||"lay-options";try{return new Function("return "+(n.attr(a)||"{}"))()}catch(r){return hint.error("parseerror\uff1a"+r,"error"),{}}},m.isTopElem=function(e){var t=[d,m("body")[0]],n=!1;return m.each(t,function(t,a){if(a===e)return n=!0}),n},f.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){new RegExp("\\b"+n+"\\b").test(e)||(e=e+" "+n)}),e.replace(/^\s|\s$/,"")},f.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){var a=new RegExp("\\b"+n+"\\b");a.test(e)&&(e=e.replace(a,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},f.prototype.find=function(e){var t=this,n=0,a=[],r="object"==typeof e;return this.each(function(i,o){for(var l=r?o.contains(e):o.querySelectorAll(e||null);n0)return n[0].style[e]}():n.each(function(n,r){"object"==typeof e?m.each(e,function(e,t){r.style[e]=a(t)}):r.style[e]=a(t)})},f.prototype.width=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetWidth}():t.each(function(n,a){t.css("width",e)})},f.prototype.height=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetHeight}():t.each(function(n,a){t.css("height",e)})},f.prototype.attr=function(e,t){var n=this;return void 0===t?function(){if(n.length>0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},f.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},f.prototype.html=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].innerHTML}():this.each(function(t,n){n.innerHTML=e})},f.prototype.val=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].value}():this.each(function(t,n){n.value=e})},f.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},f.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},f.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},f.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.removeEventListener(e,t,!1)})},window.lay=m,window.layui&&u.define&&u.define(function(e){e(y,m)})}(window,window.document),!function(e,t){"use strict";var n=e.layui&&layui.define,a={getPath:e.lay&&lay.getPath?lay.getPath:"",link:function(t,n,a){i.path&&e.lay&&lay.layui&&lay.layui.link(i.path+t,n,a)}},r=e.LAYUI_GLOBAL||{},i={v:"5.3.1",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:r.laydate_dir||a.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var t="laydate",r="",o=(n?"modules/laydate/":"theme/")+"default/laydate.css?v="+i.v+r;return n?layui.addcss(o,e,t):a.link(o,e,t),this}},o=function(){var e=this,t=e.config,n=t.id;return o.that[n]=e,{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",s=".layui-laydate",c="layui-this",u="laydate-disabled",y=[100,2e5],d="layui-laydate-static",m="layui-laydate-list",f="layui-laydate-hint",h="layui-laydate-footer",p=".laydate-btns-confirm",g="laydate-time-text",v="laydate-btns-time",T="layui-laydate-preview",w=function(e){var t=this;t.index=++i.index,t.config=lay.extend({},t.config,i.config,e),e=t.config,e.id="id"in e?e.id:t.index,i.ready(function(){t.init()})},D="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s";o.formatArr=function(e){return(e||"").match(new RegExp(D+"|.","g"))||[]},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:"click",show:!1,showBottom:!0,isPreview:!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,n={cn:{weeks:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],time:["\u65f6","\u5206","\u79d2"],timeTips:"\u9009\u62e9\u65f6\u95f4",startTime:"\u5f00\u59cb\u65f6\u95f4",endTime:"\u7ed3\u675f\u65f6\u95f4",dateTips:"\u8fd4\u56de\u65e5\u671f",month:["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"],tools:{confirm:"\u786e\u5b9a",clear:"\u6e05\u7a7a",now:"\u73b0\u5728"},timeout:"\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f00\u59cb\u65f6\u95f4
\u8bf7\u91cd\u65b0\u9009\u62e9",invalidDate:"\u4e0d\u5728\u6709\u6548\u65e5\u671f\u6216\u65f6\u95f4\u8303\u56f4\u5185",formatError:["\u65e5\u671f\u683c\u5f0f\u4e0d\u5408\u6cd5
\u5fc5\u987b\u9075\u5faa\u4e0b\u8ff0\u683c\u5f0f\uff1a
","
\u5df2\u4e3a\u4f60\u91cd\u7f6e"],preview:"\u5f53\u524d\u9009\u4e2d\u7684\u7ed3\u679c"},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"},timeout:"End time cannot be less than start Time
Please re-select",invalidDate:"Invalid date",formatError:["The date format error
Must be followed\uff1a
","
It has been reset"],preview:"The selected result"}};return n[t.lang]||n.cn},w.prototype.init=function(){var t=this,n=t.config,a="static"===n.position,r={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};n.elem=lay(n.elem),n.eventElem=lay(n.eventElem),n.elem[0]&&(t.rangeStr=n.range?"string"==typeof n.range?n.range:"-":"",n.range&&n.range.constructor===Array&&(t.rangeElem=[lay(n.range[0]),lay(n.range[1])]),r[n.type]||(e.console&&console.error&&console.error("laydate type error:'"+n.type+"' is not supported"),n.type="date"),n.format===r.date&&(n.format=r[n.type]||r.date),t.format=o.formatArr(n.format),t.EXP_IF="",t.EXP_SPLIT="",lay.each(t.format,function(e,n){var a=new RegExp(D).test(n)?"\\d{"+function(){return new RegExp(D).test(t.format[0===e?e+1:e-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;t.EXP_IF=t.EXP_IF+a,t.EXP_SPLIT=t.EXP_SPLIT+"("+a+")"}),t.EXP_IF_ONE=new RegExp("^"+t.EXP_IF+"$"),t.EXP_IF=new RegExp("^"+(n.range?t.EXP_IF+"\\s\\"+t.rangeStr+"\\s"+t.EXP_IF:t.EXP_IF)+"$"),t.EXP_SPLIT=new RegExp("^"+t.EXP_SPLIT+"$",""),t.isInput(n.elem[0])||"focus"===n.trigger&&(n.trigger="click"),n.elem.attr("lay-key")||(n.elem.attr("lay-key",t.index),n.eventElem.attr("lay-key",t.index)),n.mark=lay.extend({},n.calendar&&"cn"===n.lang?{"0-1-1":"\u5143\u65e6","0-2-14":"\u60c5\u4eba","0-3-8":"\u5987\u5973","0-3-12":"\u690d\u6811","0-4-1":"\u611a\u4eba","0-5-1":"\u52b3\u52a8","0-5-4":"\u9752\u5e74","0-6-1":"\u513f\u7ae5","0-9-10":"\u6559\u5e08","0-9-18":"\u56fd\u803b","0-10-1":"\u56fd\u5e86","0-12-25":"\u5723\u8bde"}:{},n.mark),lay.each(["min","max"],function(e,t){var a=[],r=[];if("number"==typeof n[t]){var i=n[t],o=(new Date).getTime(),l=864e5,s=new Date(i?i0)return!0;var t=lay.elem("div",{"class":"layui-laydate-header"}),r=[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"),n=lay.elem("span");return e.appendChild(t),e.appendChild(n),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}()],i=lay.elem("div",{"class":"layui-laydate-content"}),o=lay.elem("table"),y=lay.elem("thead"),d=lay.elem("tr");lay.each(r,function(e,n){t.appendChild(n)}),y.appendChild(d),lay.each(new Array(6),function(e){var t=o.insertRow(0);lay.each(new Array(7),function(n){if(0===e){var r=lay.elem("th");r.innerHTML=a.weeks[n],d.appendChild(r)}t.insertCell(n)})}),o.insertBefore(y,o.children[0]),i.appendChild(o),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(t),l[e].appendChild(i),s.push(r),c.push(i),u.push(o)}),lay(y).html(function(){var e=[],t=[];return"datetime"===n.type&&e.push(''+a.timeTips+""),(n.range||"datetime"!==n.type)&&e.push(''),lay.each(n.btns,function(e,i){var o=a.tools[i]||"btn";n.range&&"now"===i||(r&&"clear"===i&&(o="cn"===n.lang?"\u91cd\u7f6e":"Reset"),t.push(''+o+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){o.appendChild(t)}),n.showBottom&&o.appendChild(y),/^#/.test(n.theme)){var m=lay.elem("style"),f=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,n.theme);"styleSheet"in m?(m.setAttribute("type","text/css"),m.styleSheet.cssText=f):m.innerHTML=f,lay(o).addClass("laydate-theme-molv"),o.appendChild(m)}i.thisId=n.id,e.remove(w.thisElemDate),r?n.elem.append(o):(t.body.appendChild(o),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),w.thisElemDate=e.elemID,"function"==typeof n.ready&&n.ready(lay.extend({},n.dateTime,{month:n.dateTime.month+1})),e.preview()},w.prototype.remove=function(e){var t=this,n=(t.config,lay("#"+(e||t.elemID)));return n[0]?(n.hasClass(d)||t.checkDate(function(){n.remove()}),t):t},w.prototype.position=function(){var e=this,t=e.config;return lay.position(e.bindElem||t.elem[0],e.elem,{position:t.position}),e},w.prototype.hint=function(e){var t=this,n=(t.config,lay.elem("div",{"class":f}));t.elem&&(n.innerHTML=e||"",lay(t.elem).find("."+f).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+f).remove()},3e3))},w.prototype.getAsYM=function(e,t,n){return n?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,n,a=this,r=(new Date,a.config),o=a.lang(),l=r.dateTime=r.dateTime||a.systemDate(),s=a.bindElem||r.elem[0],c=(a.isInput(s)?"val":"html",function(){if(a.rangeElem){var e=[a.rangeElem[0].val(),a.rangeElem[1].val()];if(e[0]&&e[1])return e.join(" "+a.rangeStr+" ")}return a.isInput(s)?s.value:"static"===r.position?"":lay(s).attr("lay-date")}()),u=function(e){e.year>y[1]&&(e.year=y[1],n=!0),e.month>11&&(e.month=11,n=!0),e.hours>23&&(e.hours=0,n=!0),e.minutes>59&&(e.minutes=0,e.hours++,n=!0),e.seconds>59&&(e.seconds=0,e.minutes++,n=!0),t=i.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,n=!0)},d=function(e,t,i){var o=["startTime","endTime"];t=(t.match(a.EXP_SPLIT)||[]).slice(1),i=i||0,r.range&&(a[o[i]]=a[o[i]]||{}),lay.each(a.format,function(l,s){var c=parseFloat(t[l]);t[l].lengthf(r.max)||f(l)f(r.max))&&(a.endDate=lay.extend({},r.max)),e&&e(),a},w.prototype.mark=function(e,t){var n,a=this,r=a.config;return lay.each(r.mark,function(e,a){var r=e.split("-");r[0]!=t[0]&&0!=r[0]||r[1]!=t[1]&&0!=r[1]||r[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},w.prototype.limit=function(e,t,n,a){var r,i=this,o=i.config,l={},s=o[n>41?"endDate":"dateTime"],c=lay.extend({},s,t||{});return lay.each({now:c,min:o.min,max:o.max},function(e,t){l[e]=i.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),r=l.nowl.max,e&&e[r?"addClass":"removeClass"](u),r},w.prototype.thisDateTime=function(e){var t=this,n=t.config;return e?t.endDate:n.dateTime},w.prototype.calendar=function(e,t,n){var a,r,o,l=this,s=l.config,t=t?1:0,u=e||l.thisDateTime(t),d=new Date,m=l.lang(),f="date"!==s.type&&"datetime"!==s.type,h=lay(l.table[t]).find("td"),g=lay(l.elemHeader[t][2]).find("span");return u.yeary[1]&&(u.year=y[1],l.hint(m.invalidDate)),l.firstDate||(l.firstDate=lay.extend({},u)),d.setFullYear(u.year,u.month,1),a=d.getDay(),r=i.getEndDate(u.month||12,u.year),o=i.getEndDate(u.month+1,u.year),lay.each(h,function(e,t){var n=[u.year,u.month],i=0;t=lay(t),t.removeAttr("class"),e=a&&e=n.firstDate.year&&(i.month=a.max.month,i.date=a.max.date),n.limit(lay(r),i,t),E++}),lay(y[h?0:1]).attr("lay-ym",E-8+"-"+w[1]).html(x+T+" - "+(E-1+T))}else if("month"===e)lay.each(new Array(12),function(e){var r=lay.elem("li",{"lay-ym":e}),o={year:w[0],month:e};e+1==w[1]&&lay(r).addClass(c),r.innerHTML=i.month[e]+(h?"\u6708":""),l.appendChild(r),w[0]=n.firstDate.year&&(o.date=a.max.date),n.limit(lay(r),o,t)}),lay(y[h?0:1]).attr("lay-ym",w[0]+"-"+w[1]).html(w[0]+T);else if("time"===e){var C=function(){lay(l).find("ol").each(function(e,a){lay(a).find("li").each(function(a,r){n.limit(lay(r),[{hours:a},{hours:n[b].hours,minutes:a},{hours:n[b].hours,minutes:n[b].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(lay(n.footer).find(p),n[b],0,["hours","minutes","seconds"])};a.range?n[b]||(n[b]="startTime"===b?r:n.endDate):n[b]=r,lay.each([24,60,60],function(e,t){var a=lay.elem("li"),r=["

"+i.time[e]+"

    "];lay.each(new Array(t),function(t){r.push(""+lay.digit(t,2)+"")}),a.innerHTML=r.join("")+"
",l.appendChild(a)}),C()}if(f&&d.removeChild(f),d.appendChild(l),"year"===e||"month"===e)lay(n.elemMain[t]).addClass("laydate-ym-show"),lay(l).find("li").on("click",function(){var i=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(u)){0===t?(r[e]=i,n.limit(lay(n.footer).find(p),null,0)):n.endDate[e]=i;var s="year"===a.type||"month"===a.type;s?(lay(l).find("."+c).removeClass(c),lay(this).addClass(c),"month"===a.type&&"year"===e&&(n.listYM[t][0]=i,o&&((t?n.endDate:r).year=i),n.list("month",t))):(n.checkDate("limit").calendar(null,t),n.closeList()),n.setBtnStatus(),a.range||("month"===a.type&&"month"===e||"year"===a.type&&"year"===e)&&n.setValue(n.parse()).remove().done(),n.done(null,"change"),lay(n.footer).find("."+v).removeClass(u)}});else{var M=lay.elem("span",{"class":g}),S=function(){lay(l).find("ol").each(function(e){var t=this,a=lay(t).find("li");t.scrollTop=30*(n[b][D[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!lay(this).hasClass(u))return t.scrollTop=30*(e-2),!0})})},k=lay(s[2]).find("."+g);S(),M.innerHTML=a.range?[i.startTime,i.endTime][t]:i.timeTips,lay(n.elemMain[t]).addClass("laydate-time-show"),k[0]&&k.remove(),s[2].appendChild(M),lay(l).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var i=0|this.innerHTML;lay(this).hasClass(u)||(a.range?n[b][D[e]]=i:r[D[e]]=i,lay(t).find("."+c).removeClass(c),lay(this).addClass(c),C(),S(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},w.prototype.listYM=[],w.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,n){lay(this).find("."+m).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+g).remove()},w.prototype.setBtnStatus=function(e,t,n){var a,r=this,i=r.config,o=r.lang(),l=lay(r.footer).find(p);i.range&&"time"!==i.type&&(t=t||i.dateTime,n=n||r.endDate,a=r.newDate(t).getTime()>r.newDate(n).getTime(),r.limit(null,t)||r.limit(null,n)?l.addClass(u):l[a?"addClass":"removeClass"](u),e&&a&&r.hint("string"==typeof e?o.timeout.replace(/\u65e5\u671f/g,e):o.timeout))},w.prototype.parse=function(e,t){var n=this,a=n.config,r=t||("end"==e?lay.extend({},n.endDate,n.endTime):a.range?lay.extend({},a.dateTime,n.startTime):a.dateTime),o=i.parse(r,n.format,1);return a.range&&void 0===e?o+" "+n.rangeStr+" "+n.parse("end"):o},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,n=t.config,a=t.bindElem||n.elem[0];return"static"===n.position?t:(e=e||"",t.isInput(a)?lay(a).val(e):t.rangeElem?(t.rangeElem[0].val(e?t.parse("start"):""),t.rangeElem[1].val(e?t.parse("end"):"")):(0===lay(a).find("*").length&&lay(a).html(e),lay(a).attr("lay-date",e)),t)},w.prototype.preview=function(){var e=this,t=e.config;if(t.isPreview){var n=lay(e.elem).find("."+T),a=t.range?e.endDate?e.parse():"":e.parse();n.html(a).css({color:"#5FB878","font-size":"14px;"}),setTimeout(function(){ +n.css({color:"#666","font-size":"12px;"})},300)}},w.prototype.done=function(e,t){var n=this,a=n.config,r=lay.extend({},lay.extend(a.dateTime,n.startTime)),i=lay.extend({},lay.extend(n.endDate,n.endTime));return lay.each([r,i],function(e,t){"month"in t&&lay.extend(t,{month:t.month+1})}),n.preview(),e=e||[n.parse(),r,i],"function"==typeof a[t||"done"]&&a[t||"done"].apply(a,e),n},w.prototype.choose=function(e,t){var n=this,a=n.config,r=n.thisDateTime(t),i=(lay(n.elem).find("td"),e.attr("lay-ymd").split("-"));i={year:0|i[0],month:(0|i[1])-1,date:0|i[2]},e.hasClass(u)||(lay.extend(r,i),a.range?(lay.each(["startTime","endTime"],function(e,t){n[t]=n[t]||{hours:0,minutes:0,seconds:0}}),n.calendar(null,t).done(null,"change")):"static"===a.position?n.calendar().done().done(null,"change"):"date"===a.type?n.setValue(n.parse()).remove().done():"datetime"===a.type&&n.calendar().done(null,"change"))},w.prototype.tool=function(e,t){var n=this,a=n.config,r=n.lang(),i=a.dateTime,o="static"===a.position,l={datetime:function(){lay(e).hasClass(u)||(n.list("time",0),a.range&&n.list("time",1),lay(e).attr("lay-type","date").html(n.lang().dateTips))},date:function(){n.closeList(),lay(e).attr("lay-type","datetime").html(n.lang().timeTips)},clear:function(){o&&(lay.extend(i,n.firstDate),n.calendar()),a.range&&(delete a.dateTime,delete n.endDate,delete n.startTime,delete n.endTime),n.setValue("").remove(),n.done(["",{},{}])},now:function(){var e=new Date;lay.extend(i,n.systemDate(),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}),n.setValue(n.parse()).remove(),o&&n.calendar(),n.done()},confirm:function(){if(a.range){if(lay(e).hasClass(u))return n.hint("time"===a.type?r.timeout.replace(/\u65e5\u671f/g,"\u65f6\u95f4"):r.timeout)}else if(lay(e).hasClass(u))return n.hint(r.invalidDate);n.done(),n.setValue(n.parse()).remove()}};l[t]&&l[t]()},w.prototype.change=function(e){var t=this,n=t.config,a=t.thisDateTime(e),r=n.range&&("year"===n.type||"month"===n.type),i=t.elemCont[e||0],o=t.listYM[e],l=function(l){var s=lay(i).find(".laydate-year-list")[0],c=lay(i).find(".laydate-month-list")[0];return s&&(o[0]=l?o[0]-15:o[0]+15,t.list("year",e)),c&&(l?o[0]--:o[0]++,t.list("month",e)),(s||c)&&(lay.extend(a,{year:o[0]}),r&&(a.year=o[0]),n.range||t.done(null,"change"),n.range||t.limit(lay(t.footer).find(p),{year:o[0]})),t.setBtnStatus(),s||c};return{prevYear:function(){l("sub")||(a.year--,t.checkDate("limit").calendar(null,e),t.done(null,"change"))},prevMonth:function(){var n=t.getAsYM(a.year,a.month,"sub");lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextMonth:function(){var n=t.getAsYM(a.year,a.month);lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextYear:function(){l()||(a.year++,t.checkDate("limit").calendar(null,e),t.done(null,"change"))}}},w.prototype.changeEvent=function(){var e=this;e.config;lay(e.elem).on("click",function(e){lay.stope(e)}).on("mousedown",function(e){lay.stope(e)}),lay.each(e.elemHeader,function(t,n){lay(n[0]).on("click",function(n){e.change(t).prevYear()}),lay(n[1]).on("click",function(n){e.change(t).prevMonth()}),lay(n[2]).find("span").on("click",function(n){var a=lay(this),r=a.attr("lay-ym"),i=a.attr("lay-type");r&&(r=r.split("-"),e.listYM[t]=[0|r[0],0|r[1]],e.list(i,t),lay(e.footer).find("."+v).addClass(u))}),lay(n[3]).on("click",function(n){e.change(t).nextMonth()}),lay(n[4]).on("click",function(n){e.change(t).nextYear()})}),lay.each(e.table,function(t,n){var a=lay(n).find("td");a.on("click",function(){e.choose(lay(this),t)})}),lay(e.footer).find("span").on("click",function(){var t=lay(this).attr("lay-type");e.tool(this,t)})},w.prototype.isInput=function(e){return/input|textarea/.test(e.tagName.toLocaleLowerCase())},w.prototype.events=function(){var e=this,t=e.config,n=function(n,a){n.on(t.trigger,function(){a&&(e.bindElem=this),e.render()})};t.elem[0]&&!t.elem[0].eventHandler&&(n(t.elem,"bind"),n(t.eventElem),t.elem[0].eventHandler=!0)},o.that={},o.getThis=function(e){var t=o.that[e];return t||hint.error(e?l+" instance with ID '"+e+"' not found":"ID argument required"),t},a.run=function(n){n(t).on("mousedown",function(e){if(i.thisId){var t=o.getThis(i.thisId);if(t){var a=t.config;e.target!==a.elem[0]&&e.target!==a.eventElem[0]&&e.target!==n(a.closeStop)[0]&&t.remove()}}}).on("keydown",function(e){if(i.thisId){var t=o.getThis(i.thisId);t&&13===e.keyCode&&n("#"+t.elemID)[0]&&t.elemID===w.thisElemDate&&(e.preventDefault(),n(t.footer).find(p)[0].click())}}),n(e).on("resize",function(){if(i.thisId){var e=o.getThis(i.thisId);if(e)return!(!e.elem||!n(s)[0])&&void e.position()}})},i.render=function(e){var t=new w(e);return o.call(t)},i.parse=function(e,t,n){return e=e||{},"string"==typeof t&&(t=o.formatArr(t)),t=(t||[]).concat(),lay.each(t,function(a,r){/yyyy|y/.test(r)?t[a]=lay.digit(e.year,r.length):/MM|M/.test(r)?t[a]=lay.digit(e.month+(n||0),r.length):/dd|d/.test(r)?t[a]=lay.digit(e.date,r.length):/HH|H/.test(r)?t[a]=lay.digit(e.hours,r.length):/mm|m/.test(r)?t[a]=lay.digit(e.minutes,r.length):/ss|s/.test(r)&&(t[a]=lay.digit(e.seconds,r.length))}),t.join("")},i.getEndDate=function(e,t){var n=new Date;return n.setFullYear(t||n.getFullYear(),e||n.getMonth()+1,1),new Date(n.getTime()-864e5).getDate()},n?(i.ready(),layui.define("lay",function(e){i.path=layui.cache.dir,a.run(lay),e(l,i)})):"function"==typeof define&&define.amd?define(function(){return a.run(lay),i}):function(){i.ready(),a.run(e.lay),e.laydate=i}()}(window,window.document); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index e39b8da..7eea768 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,7 +29,7 @@ var task = { ascii_only: true //escape Unicode characters in strings and regexps } })) - .pipe(header('/*! <%= pkg.realname %> v<%= pkg.version %> | <%= pkg.description %> | The <%= pkg.license %> License */\n ;', {pkg: pkg})) + .pipe(header('/*! <%= pkg.realname %> v<%= pkg.version %> | <%= pkg.description %> | <%= pkg.license %> Licensed */\n ;', {pkg: pkg})) .pipe(gulp.dest('./dist')); } diff --git a/package.json b/package.json index d41587f..b5eebd7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "layui-laydate", "realname": "layDate", - "version": "5.3.0", + "version": "5.3.1", "description": "日期与时间组件", "main": "src/laydate.js", "license": "MIT", diff --git a/src/laydate.js b/src/laydate.js index 1c57735..0c04177 100644 --- a/src/laydate.js +++ b/src/laydate.js @@ -1,13 +1,734 @@ /*! - * layDate 日期与时间组件 + * layDate 日期与时间组件(单独版) * MIT Licensed */ -/*! lay 基础 DOM 操作 */ +/*! + * Layui + * Classic modular Front-End UI library + * MIT Licensed + */ + +;!function(win){ + "use strict"; + + var doc = win.document, config = { + modules: {} //记录模块物理路径 + ,status: {} //记录模块加载状态 + ,timeout: 10 //符合规范的模块请求最长等待秒数 + ,event: {} //记录模块自定义事件 + } + + ,Layui = function(){ + this.v = '2.6.7'; // layui 版本号 + } + + //识别预先可能定义的指定全局对象 + ,GLOBAL = win.LAYUI_GLOBAL || {} + + //获取 layui 所在目录 + ,getPath = function(){ + var jsPath = doc.currentScript ? doc.currentScript.src : function(){ + var js = doc.scripts + ,last = js.length - 1 + ,src; + for(var i = last; i > 0; i--){ + if(js[i].readyState === 'interactive'){ + src = js[i].src; + break; + } + } + return src || js[last].src; + }(); + + return config.dir = GLOBAL.dir || jsPath.substring(0, jsPath.lastIndexOf('/') + 1); + }() + + //异常提示 + ,error = function(msg, type){ + type = type || 'log'; + win.console && console[type] && console[type]('layui error hint: ' + msg); + } + + ,isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]' + + //内置模块 + ,modules = config.builtin = { + lay: 'lay' //基础 DOM 操作 + ,layer: 'layer' //弹层 + ,laydate: 'laydate' //日期 + ,laypage: 'laypage' //分页 + ,laytpl: 'laytpl' //模板引擎 + ,layedit: 'layedit' //富文本编辑器 + ,form: 'form' //表单集 + ,upload: 'upload' //上传 + ,dropdown: 'dropdown' //下拉菜单 + ,transfer: 'transfer' //穿梭框 + ,tree: 'tree' //树结构 + ,table: 'table' //表格 + ,element: 'element' //常用元素操作 + ,rate: 'rate' //评分组件 + ,colorpicker: 'colorpicker' //颜色选择器 + ,slider: 'slider' //滑块 + ,carousel: 'carousel' //轮播 + ,flow: 'flow' //流加载 + ,util: 'util' //工具块 + ,code: 'code' //代码修饰器 + ,jquery: 'jquery' //DOM 库(第三方) + + ,all: 'all' + ,'layui.all': 'layui.all' //聚合标识(功能性的,非真实模块) + }; + + //记录基础数据 + Layui.prototype.cache = config; + + //定义模块 + Layui.prototype.define = function(deps, factory){ + var that = this + ,type = typeof deps === 'function' + ,callback = function(){ + var setApp = function(app, exports){ + layui[app] = exports; + config.status[app] = true; + }; + typeof factory === 'function' && factory(function(app, exports){ + setApp(app, exports); + config.callback[app] = function(){ + factory(setApp); + } + }); + return this; + }; + + type && ( + factory = deps, + deps = [] + ); + + that.use(deps, callback, null, 'define'); + return that; + }; + + //使用特定模块 + Layui.prototype.use = function(apps, callback, exports, from){ + var that = this + ,dir = config.dir = config.dir ? config.dir : getPath + ,head = doc.getElementsByTagName('head')[0]; + + apps = function(){ + if(typeof apps === 'string'){ + return [apps]; + } + //当第一个参数为 function 时,则自动加载所有内置模块,且执行的回调即为该 function 参数; + else if(typeof apps === 'function'){ + callback = apps; + return ['all']; + } + return apps; + }(); + + //如果页面已经存在 jQuery 1.7+ 库且所定义的模块依赖 jQuery,则不加载内部 jquery 模块 + if(win.jQuery && jQuery.fn.on){ + that.each(apps, function(index, item){ + if(item === 'jquery'){ + apps.splice(index, 1); + } + }); + layui.jquery = layui.$ = jQuery; + } + + var item = apps[0] + ,timeout = 0; + exports = exports || []; + + //静态资源host + config.host = config.host || (dir.match(/\/\/([\s\S]+?)\//)||['//'+ location.host +'/'])[0]; + + //加载完毕 + function onScriptLoad(e, url){ + var readyRegExp = navigator.platform === 'PLaySTATION 3' ? /^complete$/ : /^(complete|loaded)$/ + if (e.type === 'load' || (readyRegExp.test((e.currentTarget || e.srcElement).readyState))) { + config.modules[item] = url; + head.removeChild(node); + (function poll() { + if(++timeout > config.timeout * 1000 / 4){ + return error(item + ' is not a valid module', 'error'); + }; + config.status[item] ? onCallback() : setTimeout(poll, 4); + }()); + } + } + + //回调 + function onCallback(){ + exports.push(layui[item]); + apps.length > 1 ? + that.use(apps.slice(1), callback, exports, from) + : ( typeof callback === 'function' && function(){ + //保证文档加载完毕再执行回调 + if(layui.jquery && typeof layui.jquery === 'function' && from !== 'define'){ + return layui.jquery(function(){ + callback.apply(layui, exports); + }); + } + callback.apply(layui, exports); + }() ); + } + + //如果引入了聚合板,内置的模块则不必重复加载 + if( apps.length === 0 || (layui['layui.all'] && modules[item]) ){ + return onCallback(), that; + } + + //获取加载的模块 URL + //如果是内置模块,则按照 dir 参数拼接模块路径 + //如果是扩展模块,则判断模块路径值是否为 {/} 开头, + //如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。 + //否则,则按照 base 参数拼接模块路径 + + var url = ( modules[item] ? (dir + 'modules/') + : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || '')) + ) + (that.modules[item] || item) + '.js'; + url = url.replace(/^\{\/\}/, ''); + + //如果扩展模块(即:非内置模块)对象已经存在,则不必再加载 + if(!config.modules[item] && layui[item]){ + config.modules[item] = url; //并记录起该扩展模块的 url + } + + //首次加载模块 + if(!config.modules[item]){ + var node = doc.createElement('script'); + + node.async = true; + node.charset = 'utf-8'; + node.src = url + function(){ + var version = config.version === true + ? (config.v || (new Date()).getTime()) + : (config.version||''); + return version ? ('?v=' + version) : ''; + }(); + + head.appendChild(node); + + if(node.attachEvent && !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !isOpera){ + node.attachEvent('onreadystatechange', function(e){ + onScriptLoad(e, url); + }); + } else { + node.addEventListener('load', function(e){ + onScriptLoad(e, url); + }, false); + } + + config.modules[item] = url; + } else { //缓存 + (function poll() { + if(++timeout > config.timeout * 1000 / 4){ + return error(item + ' is not a valid module', 'error'); + }; + (typeof config.modules[item] === 'string' && config.status[item]) + ? onCallback() + : setTimeout(poll, 4); + }()); + } + + return that; + }; + + //获取节点的 style 属性值 + Layui.prototype.getStyle = function(node, name){ + var style = node.currentStyle ? node.currentStyle : win.getComputedStyle(node, null); + return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); + }; + + //css外部加载器 + Layui.prototype.link = function(href, fn, cssname){ + var that = this + ,head = doc.getElementsByTagName('head')[0] + ,link = doc.createElement('link'); + + if(typeof fn === 'string') cssname = fn; + + var app = (cssname || href).replace(/\.|\//g, '') + ,id = link.id = 'layuicss-'+ app + ,STAUTS_NAME = 'creating' + ,timeout = 0; + + link.rel = 'stylesheet'; + link.href = href + (config.debug ? '?v='+new Date().getTime() : ''); + link.media = 'all'; + + if(!doc.getElementById(id)){ + head.appendChild(link); + } + + if(typeof fn !== 'function') return that; + + //轮询 css 是否加载完毕 + (function poll(status) { + var delay = 100 + ,getLinkElem = doc.getElementById(id); //获取动态插入的 link 元素 + + //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范 + if(++timeout > config.timeout * 1000 / delay){ + return error(href + ' timeout'); + }; + + //css 加载就绪 + if(parseInt(that.getStyle(getLinkElem, 'width')) === 1989){ + //如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态 + if(status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status'); + //如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调 + getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn(); + } else { + getLinkElem.setAttribute('lay-status', STAUTS_NAME); + setTimeout(function(){ + poll(STAUTS_NAME); + }, delay); + } + }()); + + //轮询css是否加载完毕 + /* + (function poll() { + if(++timeout > config.timeout * 1000 / 100){ + return error(href + ' timeout'); + }; + parseInt(that.getStyle(doc.getElementById(id), 'width')) === 1989 ? function(){ + fn(); + }() : setTimeout(poll, 100); + }()); + */ + + return that; + }; + + //css 内部加载器 + Layui.prototype.addcss = function(firename, fn, cssname){ + return layui.link(config.dir + 'css/' + firename, fn, cssname); + }; + + //存储模块的回调 + config.callback = {}; + + //重新执行模块的工厂函数 + Layui.prototype.factory = function(modName){ + if(layui[modName]){ + return typeof config.callback[modName] === 'function' + ? config.callback[modName] + : null; + } + }; + + //图片预加载 + Layui.prototype.img = function(url, callback, error) { + var img = new Image(); + img.src = url; + if(img.complete){ + return callback(img); + } + img.onload = function(){ + img.onload = null; + typeof callback === 'function' && callback(img); + }; + img.onerror = function(e){ + img.onerror = null; + typeof error === 'function' && error(e); + }; + }; + + //全局配置 + Layui.prototype.config = function(options){ + options = options || {}; + for(var key in options){ + config[key] = options[key]; + } + return this; + }; + + //记录全部模块 + Layui.prototype.modules = function(){ + var clone = {}; + for(var o in modules){ + clone[o] = modules[o]; + } + return clone; + }(); + + //拓展模块 + Layui.prototype.extend = function(options){ + var that = this; + + //验证模块是否被占用 + options = options || {}; + for(var o in options){ + if(that[o] || that.modules[o]){ + error(o+ ' Module already exists', 'error'); + } else { + that.modules[o] = options[o]; + } + } + + return that; + }; + + // location.hash 路由解析 + Layui.prototype.router = function(hash){ + var that = this + ,hash = hash || location.hash + ,data = { + path: [] + ,search: {} + ,hash: (hash.match(/[^#](#.*$)/) || [])[1] || '' + }; + + if(!/^#\//.test(hash)) return data; //禁止非路由规范 + hash = hash.replace(/^#\//, ''); + data.href = '/' + hash; + hash = hash.replace(/([^#])(#.*$)/, '$1').split('/') || []; + + //提取 Hash 结构 + that.each(hash, function(index, item){ + /^\w+=/.test(item) ? function(){ + item = item.split('='); + data.search[item[0]] = item[1]; + }() : data.path.push(item); + }); + + return data; + }; + + //URL 解析 + Layui.prototype.url = function(href){ + var that = this + ,data = { + //提取 url 路径 + pathname: function(){ + var pathname = href + ? function(){ + var str = (href.match(/\.[^.]+?\/.+/) || [])[0] || ''; + return str.replace(/^[^\/]+/, '').replace(/\?.+/, ''); + }() + : location.pathname; + return pathname.replace(/^\//, '').split('/'); + }() + + //提取 url 参数 + ,search: function(){ + var obj = {} + ,search = (href + ? function(){ + var str = (href.match(/\?.+/) || [])[0] || ''; + return str.replace(/\#.+/, ''); + }() + : location.search + ).replace(/^\?+/, '').split('&'); //去除 ?,按 & 分割参数 + + //遍历分割后的参数 + that.each(search, function(index, item){ + var _index = item.indexOf('=') + ,key = function(){ //提取 key + if(_index < 0){ + return item.substr(0, item.length); + } else if(_index === 0){ + return false; + } else { + return item.substr(0, _index); + } + }(); + //提取 value + if(key){ + obj[key] = _index > 0 ? item.substr(_index + 1) : null; + } + }); + + return obj; + }() + + //提取 Hash + ,hash: that.router(function(){ + return href + ? ((href.match(/#.+/) || [])[0] || '/') + : location.hash; + }()) + }; + + return data; + }; + + //本地持久性存储 + Layui.prototype.data = function(table, settings, storage){ + table = table || 'layui'; + storage = storage || localStorage; + + if(!win.JSON || !win.JSON.parse) return; + + //如果settings为null,则删除表 + if(settings === null){ + return delete storage[table]; + } + + settings = typeof settings === 'object' + ? settings + : {key: settings}; + + try{ + var data = JSON.parse(storage[table]); + } catch(e){ + var data = {}; + } + + if('value' in settings) data[settings.key] = settings.value; + if(settings.remove) delete data[settings.key]; + storage[table] = JSON.stringify(data); + + return settings.key ? data[settings.key] : data; + }; + + //本地会话性存储 + Layui.prototype.sessionData = function(table, settings){ + return this.data(table, settings, sessionStorage); + } + + //设备信息 + Layui.prototype.device = function(key){ + var agent = navigator.userAgent.toLowerCase() + + //获取版本号 + ,getVersion = function(label){ + var exp = new RegExp(label + '/([^\\s\\_\\-]+)'); + label = (agent.match(exp)||[])[1]; + return label || false; + } + + //返回结果集 + ,result = { + os: function(){ //底层操作系统 + if(/windows/.test(agent)){ + return 'windows'; + } else if(/linux/.test(agent)){ + return 'linux'; + } else if(/iphone|ipod|ipad|ios/.test(agent)){ + return 'ios'; + } else if(/mac/.test(agent)){ + return 'mac'; + } + }() + ,ie: function(){ //ie版本 + return (!!win.ActiveXObject || "ActiveXObject" in win) ? ( + (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 + ) : false; + }() + ,weixin: getVersion('micromessenger') //是否微信 + }; + + //任意的key + if(key && !result[key]){ + result[key] = getVersion(key); + } + + //移动设备 + result.android = /android/.test(agent); + result.ios = result.os === 'ios'; + result.mobile = (result.android || result.ios) ? true : false; + + return result; + }; + + //提示 + Layui.prototype.hint = function(){ + return { + error: error + }; + }; + + + //typeof 类型细分 -> string/number/boolean/undefined/null、object/array/function/… + Layui.prototype._typeof = function(operand){ + if(operand === null) return String(operand); + + //细分引用类型 + return (typeof operand === 'object' || typeof operand === 'function') ? function(){ + var type = Object.prototype.toString.call(operand).match(/\s(.+)\]$/) || [] //匹配类型字符 + ,classType = 'Function|Array|Date|RegExp|Object|Error|Symbol'; //常见类型字符 + + type = type[1] || 'Object'; + + //除匹配到的类型外,其他对象均返回 object + return new RegExp('\\b('+ classType + ')\\b').test(type) + ? type.toLowerCase() + : 'object'; + }() : typeof operand; + }; + + //对象是否具备数组结构(此处为兼容 jQuery 对象) + Layui.prototype._isArray = function(obj){ + var that = this + ,len + ,type = that._typeof(obj); + + if(!obj || (typeof obj !== 'object') || obj === win) return false; + + len = 'length' in obj && obj.length; //兼容 ie + return type === 'array' || len === 0 || ( + typeof len === 'number' && len > 0 && (len - 1) in obj //兼容 jQuery 对象 + ); + }; + + //遍历 + Layui.prototype.each = function(obj, fn){ + var key + ,that = this + ,callFn = function(key, obj){ //回调 + return fn.call(obj[key], key, obj[key]) + }; + + if(typeof fn !== 'function') return that; + obj = obj || []; + + //优先处理数组结构 + if(that._isArray(obj)){ + for(key = 0; key < obj.length; key++){ + if(callFn(key, obj)) break; + } + } else { + for(key in obj){ + if(callFn(key, obj)) break; + } + } + + return that; + }; + + //将数组中的对象按其某个成员排序 + Layui.prototype.sort = function(obj, key, desc){ + var clone = JSON.parse( + JSON.stringify(obj || []) + ); + + if(!key) return clone; + + //如果是数字,按大小排序;如果是非数字,则按字典序排序 + clone.sort(function(o1, o2){ + var isNum = /^-?\d+$/ + ,v1 = o1[key] + ,v2 = o2[key]; + + if(isNum.test(v1)) v1 = parseFloat(v1); + if(isNum.test(v2)) v2 = parseFloat(v2); + + return v1 - v2; + + /* + if(v1 && !v2){ + return 1; + } else if(!v1 && v2){ + return -1; + } + + if(v1 > v2){ + return 1; + } else if (v1 < v2) { + return -1; + } else { + return 0; + } + */ + + }); + + desc && clone.reverse(); //倒序 + return clone; + }; + + //阻止事件冒泡 + Layui.prototype.stope = function(thisEvent){ + thisEvent = thisEvent || win.event; + try { thisEvent.stopPropagation() } catch(e){ + thisEvent.cancelBubble = true; + } + }; + + //字符常理 + var EV_REMOVE = 'LAYUI-EVENT-REMOVE'; + + //自定义模块事件 + Layui.prototype.onevent = function(modName, events, callback){ + if(typeof modName !== 'string' + || typeof callback !== 'function') return this; + + return Layui.event(modName, events, null, callback); + }; + + //执行自定义模块事件 + Layui.prototype.event = Layui.event = function(modName, events, params, fn){ + var that = this + ,result = null + ,filter = (events || '').match(/\((.*)\)$/)||[] //提取事件过滤器字符结构,如:select(xxx) + ,eventName = (modName + '.'+ events).replace(filter[0], '') //获取事件名称,如:form.select + ,filterName = filter[1] || '' //获取过滤器名称,,如:xxx + ,callback = function(_, item){ + var res = item && item.call(that, params); + res === false && result === null && (result = false); + }; + + //如果参数传入特定字符,则执行移除事件 + if(params === EV_REMOVE){ + delete (that.cache.event[eventName] || {})[filterName]; + return that; + } + + //添加事件 + if(fn){ + config.event[eventName] = config.event[eventName] || {}; + + //这里不再对重复事件做支持 + //config.event[eventName][filterName] ? config.event[eventName][filterName].push(fn) : + config.event[eventName][filterName] = [fn]; + return this; + } + + //执行事件回调 + layui.each(config.event[eventName], function(key, item){ + //执行当前模块的全部事件 + if(filterName === '{*}'){ + layui.each(item, callback); + return; + } + + //执行指定事件 + key === '' && layui.each(item, callback); + (filterName && key === filterName) && layui.each(item, callback); + }); + + return result; + }; + + //新增模块事件 + Layui.prototype.on = function(events, modName, callback){ + var that = this; + return that.onevent.call(that, modName, events, callback); + } + + //移除模块事件 + Layui.prototype.off = function(events, modName){ + var that = this; + return that.event.call(that, modName, events, EV_REMOVE); + }; + + //exports layui + var layui = new Layui(); + + + + +/*! lay 基础 DOM 操作 | MIT Licensed */ + -;!function(){ "use strict"; var MOD_NAME = 'lay' //模块名 @@ -62,59 +783,37 @@ }; //lay 模块版本 - lay.v = '1.0.6'; + lay.v = '1.0.7'; //ie版本 lay.ie = function(){ var agent = navigator.userAgent.toLowerCase(); return (!!window.ActiveXObject || "ActiveXObject" in window) ? ( - (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 + (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于 ie11 并没有 msie 的标识 ) : false; }(); - //获取当前 JS 所在目录 - lay.getPath = function(){ - var jsPath = document.currentScript ? document.currentScript.src : function(){ - var js = document.scripts - ,last = js.length - 1 - ,src; - for(var i = last; i > 0; i--){ - if(js[i].readyState === 'interactive'){ - src = js[i].src; - break; - } - } - return src || js[last].src; - }(); - return jsPath.substring(0, jsPath.lastIndexOf('/') + 1); - } - //中止冒泡 - lay.stope = function(e){ - e = e || window.event; - e.stopPropagation - ? e.stopPropagation() - : e.cancelBubble = true; - }; - //对象遍历 - lay.each = function(obj, fn){ - var key - ,that = this; - if(typeof fn !== 'function') return that; - obj = obj || []; - if(obj.constructor === Object){ - for(key in obj){ - if(fn.call(obj[key], key, obj[key])) break; - } - } else { - for(key = 0; key < obj.length; key++){ - if(fn.call(obj[key], key, obj[key])) break; - } - } - return that; + + + + /** + * 获取 layui 常见方法,以便用于组件单独版 + */ + + lay.layui = layui; + lay.getPath = layui.cache.dir; //获取当前 JS 所在目录 + lay.stope = layui.stope; //中止冒泡 + lay.each = function(){ //遍历 + layui.each.apply(layui, arguments); + return this; }; + + + + //数字前置补零 lay.digit = function(num, length, end){ var str = ''; @@ -134,62 +833,7 @@ }); return elem; }; - - //获取节点的 style 属性值 - lay.getStyle = function(node, name){ - var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null); - return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); - }; - - //载入 CSS 依赖 - lay.link = function(href, fn, cssname){ - var head = document.getElementsByTagName("head")[0] - ,link = document.createElement('link'); - - if(typeof fn === 'string') cssname = fn; - - var app = (cssname || href).replace(/\.|\//g, ''); - var id = 'layuicss-'+ app - ,STAUTS_NAME = 'creating' - ,timeout = 0; - - - - link.rel = 'stylesheet'; - link.href = href; - link.id = id; - - if(!document.getElementById(id)){ - head.appendChild(link); - } - if(typeof fn !== 'function') return; - - //轮询 css 是否加载完毕 - (function poll(status) { - var delay = 100 - ,getLinkElem = document.getElementById(id); //获取动态插入的 link 元素 - - //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范 - if(++timeout > 10 * 1000 / delay){ - return window.console && console.error(app +'.css: Invalid'); - }; - - //css 加载就绪 - if(parseInt(lay.getStyle(getLinkElem, 'width')) === 1989){ - //如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态 - if(status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status'); - //如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调 - getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn(); - } else { - getLinkElem.setAttribute('lay-status', STAUTS_NAME); - setTimeout(function(){ - poll(STAUTS_NAME); - }, delay); - } - }()); - }; - //当前页面是否存在滚动条 lay.hasScrollbar = function(){ return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight); @@ -488,19 +1132,16 @@ }); } -}(); +}(window, window.document); -/*! - * layDate 日期与时间控件 - * MIT Licensed - */ +/*! layDate 日期与时间控件 | MIT Licensed */ -;!function(window){ +;!function(window, document){ "use strict"; var isLayui = window.layui && layui.define, ready = { - getPath: (window.lay && lay.getPath) ? lay.getPath() : '' + getPath: (window.lay && lay.getPath) ? lay.getPath : '' //载入 CSS 依赖 ,link: function(href, fn, cssname){ @@ -509,8 +1150,8 @@ if(!laydate.path) return; //加载 css - if(window.lay && lay.link){ - lay.link(laydate.path + href, fn, cssname); + if(window.lay && lay.layui){ + lay.layui.link(laydate.path + href, fn, cssname); } } } @@ -520,7 +1161,7 @@ //外部调用 ,laydate = { - v: '5.3.0' + v: '5.3.1' //layDate 版本号 ,config: {} //全局配置项 ,index: (window.laydate && window.laydate.v) ? 100000 : 0 ,path: GLOBAL.laydate_dir || ready.getPath @@ -1173,7 +1814,7 @@ } }; getEndDate(); - + if(typeof value === 'string' && value){ if(that.EXP_IF.test(value)){ //校验日期格式 if(options.range){ @@ -1552,13 +2193,7 @@ //如果为年月选择器,点击了年列表,则切换到月选择器 if(options.type === 'month' && type === 'year'){ that.listYM[index][0] = ym; - if(isAlone){ - if(index){ - dateTime.year = ym; - } else { - that.endDate.year = ym; - } - } + isAlone && ((index ? that.endDate : dateTime).year = ym); that.list('month', index); } } else { @@ -2174,5 +2809,5 @@ }() ); -}(window); +}(window, window.document);