|
|
|
|
!function(e){var j=document,h="querySelectorAll",d="getElementsByClassName",c=function(k){return j[h](k)};var a={type:0,shade:true,shadeClose:true,fixed:true,anim:"scale"};var i={extend:function(m){var l=JSON.parse(JSON.stringify(a));for(var k in m){l[k]=m[k]}return l},timer:{},end:{}};i.touch=function(l,k){l.addEventListener("click",function(m){k.call(this,m)},false)};var f=0,g=["layui-m-layer"],b=function(k){var l=this;l.config=i.extend(k);l.view()};b.prototype.view=function(){var p=this,l=p.config,k=j.createElement("div");p.id=k.id=g[0]+f;k.setAttribute("class",g[0]+" "+g[0]+(l.type||0));k.setAttribute("index",f);var q=(function(){var s=typeof l.title==="object";return l.title?'<h3 style="'+(s?l.title[1]:"")+'">'+(s?l.title[0]:l.title)+"</h3>":""}());var m=(function(){typeof l.btn==="string"&&(l.btn=[l.btn]);var t=(l.btn||[]).length,s;if(t===0||!l.btn){return""}s='<span yes type="1">'+l.btn[0]+"</span>";if(t===2){s='<span no type="0">'+l.btn[1]+"</span>"+s}return'<div class="layui-m-layerbtn">'+s+"</div>"}());if(!l.fixed){l.top=l.hasOwnProperty("top")?l.top:100;l.style=l.style||"";l.style+=" top:"+(j.body.scrollTop+l.top)+"px"}if(l.type===2){l.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(l.content||"")+"</p>"}if(l.skin){l.anim="up"}if(l.skin==="msg"){l.shade=false}k.innerHTML=(l.shade?"<div "+(typeof l.shade==="string"?'style="'+l.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(!l.fixed?'style="position:static;"':"")+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(l.skin?"layui-m-layer-"+l.skin+" ":"")+(l.className?l.className:"")+" "+(l.anim?"layui-m-anim-"+l.anim:"")+'" '+(l.style?'style="'+l.style+'"':"")+">"+q+'<div class="layui-m-layercont">'+l.content+"</div>"+m+"</div></div></div>";if(!l.type||l.type===2){var o=j[d](g[0]+l.type),r=o.length;if(r>=1){layer.close(o[0].getAttribute("index"))}}document.body.appendChild(k);var n=p.elem=c("#"+p.id)[0];l.success&&l.success(n);p.index=f++;p.action(l,n)};b.prototype.action=function(l,r){var q=this;if(l.time){i.timer[q.index]=setTimeout(function(){layer.close(q.index)},l.time*1000)}var m=function(){var s=this.getAttribute("type");if(s==0){l.no&&l.no();layer.close(q.index)}else{l.yes?l.yes(q.index):layer.close(q.index)}};if(l.btn){var p=r[d]("layui-m-layerbtn")[0].children,o=p.length;for(var n=0;n<o;n++){i.touch(p[n],m)}}if(l.shade&&l.shadeClose){var k=r[d]("layui-m-layershade")[0];i.touch(k,function(){layer.close(q.index,l.end)})}l.end&&(i.end[q.index]=l.end)};e.layer={v:"2.0",index:f,open:function(k){var l=new b(k||{});return l.index},close:function(k){var l=c("#"+g[0]+k)[0];if(!l){return}l.innerHTML="";j.body.removeChild(l);clearTimeout(i.timer[k]);delete i.timer[k];typeof i.end[k]==="function"&&i.end[k]();delete i.end[k]},closeAll:function(){var l=j[d](g[0]);for(var m=0,k=l.length;m<k;m++){layer.close((l[0].getAttribute("index")|0))}}};"function"==typeof define?define(function(){return layer}):function(){var n=document.scripts,k=n[n.length-1],m=k.src;var l=m.substring(0,m.lastIndexOf("/")+1);if(k.getAttribute("merge")){return}document.head.appendChild(function(){var o=j.createElement("link");o.href=l+"need/layer.css?2.0";o.type="text/css";o.rel="styleSheet";o.id="layermcss";return o}())}()}(window);
|