2 lines
54 KiB
JavaScript
2 lines
54 KiB
JavaScript
|
/*! laydate-v5.5.0 日期与时间组件 */
|
||
|
!function(window){var MOD_NAME="lay";var document=window.document;var lay=function(selector){return new Class(selector)};var Class=function(selector){var that=this;var elem=typeof selector==="object"?function(){return layui.isArray(selector)?selector:[selector]}():(this.selector=selector,document.querySelectorAll(selector||null));lay.each(elem,function(index,item){that.push(elem[index])})};Array.prototype.indexOf=Array.prototype.indexOf||function(searchElement,fromIndex){var rst=-1;fromIndex=fromIndex||0;layui.each(this,function(index,val){if(searchElement===val&&index>=fromIndex){rst=index;return !0}});return rst};Class.fn=Class.prototype=[];Class.fn.constructor=Class;lay.extend=function(){var ai=1;var length;var args=arguments;var clone=function(target,obj){target=target||(layui.type(obj)==="array"?[]:{});for(var i in obj){target[i]=(obj[i]&&obj[i].constructor===Object)?clone(target[i],obj[i]):obj[i]}return target};args[0]=typeof args[0]==="object"?args[0]:{};length=args.length;for(;ai<length;ai++){if(typeof args[ai]==="object"){clone(args[0],args[ai])}}return args[0]};lay.ie=function(){var agent=navigator.userAgent.toLowerCase();return(!!window.ActiveXObject||"ActiveXObject" in window)?((agent.match(/msie\s(\d+)/)||[])[1]||"11"):false}();lay.layui=layui||{};lay.getPath=layui.cache.dir;lay.stope=layui.stope;lay.each=function(){layui.each.apply(layui,arguments);return this};lay.digit=function(num,length){if(!(typeof num==="string"||typeof num==="number")){return""}var str="";num=String(num);length=length||2;for(var i=num.length;i<length;i++){str+="0"}return num<Math.pow(10,length)?str+num:num};lay.elem=function(elemName,attr){var elem=document.createElement(elemName);lay.each(attr||{},function(key,value){elem.setAttribute(key,value)});return elem};lay.hasScrollbar=function(){return document.body.scrollHeight>(window.innerHeight||document.documentElement.clientHeight)};lay.getStyleRules=function(style,callback){if(!style){return}var sheet=style.sheet||style.styleSheet||{};var rules=sheet.cssRules||sheet.rules;if(typeof callback==="function"){layui.each(rules,function(i,item){if(callback(item,i)){return true}})}return rules};lay.style=function(options){options=options||{};var style=lay.elem("style");var styleText=options.text||"";var target=options.target;if(!styleText){return}if("styleSheet" in style){style.setAttribute("type","text/css");style.styleSheet.cssText=styleText}else{style.innerHTML=styleText}style.id="LAY-STYLE-"+(options.id||function(index){lay.style.index++;return"DF-"+index}(lay.style.index||0));if(target){var styleElem=lay(target).find("#"+style.id);styleElem[0]&&styleElem.remove();lay(target).append(style)}return style};lay.position=function(target,elem,opts){if(!elem){return}opts=opts||{};if(target===document||target===lay("body")[0]){opts.clickType="right"}var rect=opts.clickType==="right"?function(){var e=opts.e||window.event||{};return{left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY}}():target.getBoundingClientRect();var elemWidth=elem.offsetWidth;var elemHeight=elem.offsetHeight;var scrollArea=function(type){type=type?"scrollLeft":"scrollTop";return document.body[type]|document.documentElement[type]};var winArea=function(type){return document.documentElement[type?"clientWidth":"clientHeight"]};var margin="margin" in opts?opts.margin:5;var left=rect.left;var top=rect.bottom;if(opts.align==="center"){left=left-(elemWidth-target.offsetWidth)/2}else{if(opts.align==="right"){left=left-elemWidth+target.offsetWidth}}if(left+elemWidth+margin>winArea("width")){left=winArea("width")-elemWidth-margin}if(left<margin){left=margin}if(rect.bottom+elemHeight+margin>winArea()){if(rect.top>elemHeight+margin&&rect.top<=winArea()){top=rect.top-elemHeight-margin*2}else{if(!opts.allowBottomOut){top=winArea()-elemHeight-margin*2;if(top<0){top=0}}}}var position=opts.position;if(position){elem.style.position=position}elem.style.left=left+(position==="fixed"?0:scrollArea(1))+"px";elem.style.top=top+(position==="fixed"?0:scrollArea())+"px";if(!lay.hasScrollbar()){var rect1=elem.getBoundingClientRect();if(!opts.
|