layui-js/build/lay/modules/layer.js

2 lines
19 KiB
JavaScript
Raw Normal View History

2016-10-18 08:23:17 +08:00
/** layui-v1.0.2 经典模块化前端框架 LGPL license By www.layui.com */
2016-10-14 16:23:52 +08:00
;!function(e,t){"use strict";var i,n,a={getPath:function(){var e=document.scripts,t=e[e.length-1],i=t.src;if(!t.getAttribute("merge"))return i.substring(0,i.lastIndexOf("/")+1)}(),config:{},end:{},btn:["&#x786E;&#x5B9A;","&#x53D6;&#x6D88;"],type:["dialog","page","iframe","loading","tips"]},o={v:"2.5",ie6:!!e.ActiveXObject&&!e.XMLHttpRequest,index:e.layer&&e.layer.v?1e5:0,path:a.getPath,config:function(e,t){return e=e||{},o.cache=a.config=i.extend(a.config,e),"string"==typeof e.extend&&(e.extend=[e.extend]),t&&t(),this},use:function(e,t,n){var a=i("head")[0],e=e.replace(/\s/g,""),r=/\.css$/.test(e),l=document.createElement(r?"link":"script"),s="layui_layer_"+e.replace(layui.cache.extend_dir,"").replace(/\.|\//g,"");if(o.path)return r&&(l.rel="stylesheet"),l[r?"href":"src"]=/^http:\/\//.test(e)?e:o.path+e,l.id=s,i("#"+s)[0]||a.appendChild(l),function c(){(r?1989===parseInt(i("#"+s).css("width")):o[n||s])?function(){t&&t();try{r||a.removeChild(l)}catch(e){}}():setTimeout(c,100)}(),this},ready:function(e){return layui.addcss("pc/layer/layer.css",e,"skinlayercss"),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),o.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,r){var l="function"==typeof t;return l&&(r=n,n=t),o.open(i.extend({content:e,btn:a.btn,yes:n,btn2:r},l?{}:t))},msg:function(e,n,r){var s="function"==typeof n,c=a.config.skin,f=(c?c+" "+c+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(r=n),o.open(i.extend({content:e,time:3e3,shade:!1,skin:f,title:!1,closeBtn:!1,btn:!1,end:r},s&&!a.config.skin?{skin:f+" layui-layer-hui",shift:u}:function(){return n=n||{},(n.icon===-1||n.icon===t&&!a.config.skin)&&(n.skin=f+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return o.open(i.extend({type:3,icon:e||0,shade:.01},t))},tips:function(e,t,n){return o.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,fix:!1,maxWidth:210},n))}},r=function(e){var t=this;t.index=++o.index,t.config=i.extend({},t.config,a.config,e),t.creat()};r.pt=r.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],r.pt.config={type:0,shade:.3,fix:!0,move:l[1],title:"&#x4FE1;&#x606F;",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,shift:0,icon:-1,scrollbar:!0,tips:2},r.pt.vessel=function(e,t){var i=this,n=i.index,o=i.config,r=o.zIndex+n,s="object"==typeof o.title,c=o.maxmin&&(1===o.type||2===o.type),f=o.title?'<div class="layui-layer-title" style="'+(s?o.title[1]:"")+'">'+(s?o.title[0]:o.title)+"</div>":"";return o.zIndex=r,t([o.shade?'<div class="layui-layer-shade" id="layui-layer-shade'+n+'" times="'+n+'" style="'+("z-index:"+(r-1)+"; background-color:"+(o.shade[1]||"#000")+"; opacity:"+(o.shade[0]||o.shade)+"; filter:alpha(opacity="+(100*o.shade[0]||100*o.shade)+");")+'"></div>':"",'<div class="'+l[0]+(" layui-layer-"+a.type[o.type])+(0!=o.type&&2!=o.type||o.shade?"":" layui-layer-border")+" "+(o.skin||"")+'" id="'+l[0]+n+'" type="'+a.type[o.type]+'" times="'+n+'" showtime="'+o.time+'" conType="'+(e?"object":"string")+'" style="z-index: '+r+"; width:"+o.area[0]+";height:"+o.area[1]+(o.fix?"":";position:absolute;")+'">'+(e&&2!=o.type?"":f)+'<div id="'+(o.id||"")+'" class="layui-layer-content'+(0==o.type&&o.icon!==-1?" layui-layer-padding":"")+(3==o.type?" layui-layer-loading"+o.icon:"")+'">'+(0==o.type&&o.icon!==-1?'<i class="layui-layer-ico layui-layer-ico'+o.icon+'"></i>':"")+(1==o.type&&e?"":o.content||"")+'</div><span class="layui-layer-setwin">'+function(){var e=c?'<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>':"";return o.closeBtn&&(e+='<a class="layui-layer-ico '+l[7]+" "+l[7]+(o.title?o.closeBtn:4==o.type?"1":"2")+'" href="javascript:;"></a>'),e}()+"</span>"+(o.btn?function(){var e="";"string"==typeof o.btn&&(o.btn=[o.btn]);for(var t