You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
5 years ago
|
/** layui-v1.0.9_rls MIT License By http://www.layui.com */
|
||
|
;layui.define(function(e){"use strict";var t=window,a={path:"",skin:"default",format:"YYYY-MM-DD",min:"1900-01-01 00:00:00",max:"2099-12-31 23:59:59",isv:!1,init:!0},n={},s=document,i="createElement",o="getElementById",l="getElementsByTagName",d=["laydate_box","laydate_void","laydate_click","LayDateSkin","skins/","/laydate.css"];t.laydate=function(e){return e=e||{},n.run(e),laydate},laydate.v="1.1",n.trim=function(e){return e=e||"",e.replace(/^\s|\s$/g,"").replace(/\s+/g," ")},n.digit=function(e){return e<10?"0"+(0|e):e},n.stopmp=function(e){return e=e||t.event,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,this},n.each=function(e,t){for(var a=0,n=e.length;a<n&&t(a,e[a])!==!1;a++);},n.hasClass=function(e,t){return e=e||{},new RegExp("\\b"+t+"\\b").test(e.className)},n.addClass=function(e,t){return e=e||{},n.hasClass(e,t)||(e.className+=" "+t),e.className=n.trim(e.className),this},n.removeClass=function(e,t){if(e=e||{},n.hasClass(e,t)){var a=new RegExp("\\b"+t+"\\b");e.className=e.className.replace(a,"")}return this},n.removeCssAttr=function(e,t){var a=e.style;a.removeProperty?a.removeProperty(t):a.removeAttribute(t)},n.shde=function(e,t){e.style.display=t?"none":"block"},n.query=function(e){if(e&&1===e.nodeType){if("input"!==e.tagName.toLowerCase())throw new Error("选择器elem错误");return e}var t,e=n.trim(e).split(" "),a=s[o](e[0].substr(1));if(a){if(e[1]){if(/^\./.test(e[1])){var i,d=e[1].substr(1),r=new RegExp("\\b"+d+"\\b");return t=[],i=s.getElementsByClassName?a.getElementsByClassName(d):a[l]("*"),n.each(i,function(e,a){r.test(a.className)&&t.push(a)}),t[0]?t:""}return t=a[l](e[1]),t[0]?a[l](e[1]):""}return a}},n.on=function(e,a,s){return e.attachEvent?e.attachEvent("on"+a,function(){s.call(e,t.even)}):e.addEventListener(a,s,!1),n},n.stopMosup=function(e,t){"mouseup"!==e&&n.on(t,"mouseup",function(e){n.stopmp(e)})},n.run=function(e){var t=(n.query,e.elem);t&&(d.elemv=/textarea|input/.test(t.tagName.toLocaleLowerCase())?"value":"innerHTML",("init"in e?e.init:a.init)&&!t[d.elemv]&&(t[d.elemv]=laydate.now(null,e.format||a.format)),n.view(t,e),n.reshow())},n.scroll=function(e){return e=e?"scrollLeft":"scrollTop",s.body[e]|s.documentElement[e]},n.winarea=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},n.isleap=function(e){return e%4===0&&e%100!==0||e%400===0},n.checkVoid=function(e,t,a){var s=[];return e=0|e,t=0|t,a=0|a,e<n.mins[0]?s=["y"]:e>n.maxs[0]?s=["y",1]:e>=n.mins[0]&&e<=n.maxs[0]&&(e==n.mins[0]&&(t<n.mins[1]?s=["m"]:t==n.mins[1]&&a<n.mins[2]&&(s=["d"])),e==n.maxs[0]&&(t>n.maxs[1]?s=["m",1]:t==n.maxs[1]&&a>n.maxs[2]&&(s=["d",1]))),s},n.timeVoid=function(e,t){if(n.ymd[1]+1==n.mins[1]&&n.ymd[2]==n.mins[2]){if(0===t&&e<n.mins[3])return 1;if(1===t&&e<n.mins[4])return 1;if(2===t&&e<n.mins[5])return 1}else if(n.ymd[1]+1==n.maxs[1]&&n.ymd[2]==n.maxs[2]){if(0===t&&e>n.maxs[3])return 1;if(1===t&&e>n.maxs[4])return 1;if(2===t&&e>n.maxs[5])return 1}if(e>(t?59:23))return 1},n.check=function(){var e=n.options.format.replace(/YYYY|MM|DD|hh|mm|ss/g,"\\d+\\").replace(/\\$/g,""),t=new RegExp(e),a=n.elem[d.elemv],s=a.match(/\d+/g)||[],i=n.checkVoid(s[0],s[1],s[2]);if(""!==a.replace(/\s/g,"")){if(!t.test(a))return n.elem[d.elemv]="",n.msg("日期不符合格式,请重新选择。"),1;if(i[0])return n.elem[d.elemv]="",n.msg("日期不在有效期内,请重新选择。"),1;i.value=n.elem[d.elemv].match(t).join(),s=i.value.match(/\d+/g),s[1]<1?(s[1]=1,i.auto=1):s[1]>12?(s[1]=12,i.auto=1):s[1].length<2&&(i.auto=1),s[2]<1?(s[2]=1,i.auto=1):s[2]>n.months[(0|s[1])-1]?(s[2]=31,i.auto=1):s[2].length<2&&(i.auto=1),s.length>3&&(n.timeVoid(s[3],0)&&(i.auto=1),n.timeVoid(s[4],1)&&(i.auto=1),n.timeVoid(s[5],2)&&(i.auto=1)),i.auto?n.creation([s[0],0|s[1],0|s[2]],1):i.value!==n.elem[d.elemv]&&(n.elem[d.elemv]=i.value)}},n.months=[31,null,31,30,31,30,31,31,30,31,30,31],n.viewDate=function(e,t,a){var s=(n.query,{}),i=new Date;e<(0|n.mins[0])&&(e=0|n.mins[0]),e>(0|n.maxs[0])&&(e=0|n.maxs[0]),i.setFullYear(e,t,a),s.ymd=[i.getFullYear(),i.getMonth(),i.getDate()],n.months[1]=n.isleap(s.ymd[0])?29:28,i.setF
|