1 |
- /*! layer-v1.9.3 弹层组件 License LGPL http://layer.layui.com/ By 贤心 */!function(m,n){var g,k,h={getPath:function(){var b=document.scripts,b=b[b.length-1],a=b.src;if(!b.getAttribute("merge"))return a.substring(0,a.lastIndexOf("/")+1)}(),config:{},end:{},btn:["\x26#x786E;\x26#x5B9A;","\x26#x53D6;\x26#x6D88;"],type:["dialog","page","iframe","loading","tips"]};m.layer={v:"1.9.3",ie6:!!m.ActiveXObject&&!m.XMLHttpRequest,index:0,path:h.getPath,config:function(b,a){var d=0;return b=b||{},layer.cache=h.config=g.extend(h.config,b),layer.path=h.config.path||layer.path,"string"==typeof b.extend&&(b.extend=[b.extend]),layer.use("skin/layer.css",b.extend&&0<b.extend.length?function f(){var e=b.extend;layer.use(e[e[d]?d:d-1],d<e.length?(++d,f):a)}():a),this},use:function(b,a,d){var c=g("head")[0];b=b.replace(/\s/g,"");var f=/\.css$/.test(b),e=document.createElement(f?"link":"script"),h="layui_layer_"+b.replace(/\.|\//g,"");return layer.path?(f&&(e.rel="stylesheet"),e[f?"href":"src"]=/^http:\/\//.test(b)?b:layer.path+b,e.id=h,g("#"+h)[0]||c.appendChild(e),function q(){if(f?1989===parseInt(g("#"+h).css("width")):layer[d||h]){a&&a();try{f||c.removeChild(e)}catch(b){}}else setTimeout(q,100)}(),this):void 0},ready:function(b,a){var d="function"==typeof b;return d&&(a=b),layer.config(g.extend(h.config,d?{}:{path:b}),a),this},alert:function(b,a,d){var c="function"==typeof a;return c&&(d=a),layer.open(g.extend({content:b,yes:d},c?{}:a))},confirm:function(b,a,d,c){var f="function"==typeof a;return f&&(c=d,d=a),layer.open(g.extend({content:b,btn:h.btn,yes:d,cancel:c},f?{}:a))},msg:function(b,a,d){var c="function"==typeof a,f=h.config.skin,f=(f?f+" "+f+"-msg":"")||"layui-layer-msg",p=e.anim.length-1;return c&&(d=a),layer.open(g.extend({content:b,time:3E3,shade:!1,skin:f,title:!1,closeBtn:!1,btn:!1,end:d},c&&!h.config.skin?{skin:f+" layui-layer-hui",shift:p}:(a=a||{},(-1===a.icon||a.icon===n&&!h.config.skin)&&(a.skin=f+" "+(a.skin||"layui-layer-hui")),a)))},load:function(b,a){return layer.open(g.extend({type:3,icon:b||0,shade:.01},a))},tips:function(b,a,d){return layer.open(g.extend({type:4,content:[b,a],closeBtn:!1,time:3E3,maxWidth:210},d))}};var l=function(b){this.index=++layer.index;this.config=g.extend({},this.config,h.config,b);this.creat()};l.pt=l.prototype;var e="layui-layer .layui-layer-title .layui-layer-main .layui-layer-dialog layui-layer-iframe layui-layer-content layui-layer-btn layui-layer-close".split(" ");e.anim="layui-anim layui-anim-01 layui-anim-02 layui-anim-03 layui-anim-04 layui-anim-05 layui-anim-06".split(" ");l.pt.config={type:0,shade:.3,fix:!0,move:e[1],title:"\x26#x4FE1;\x26#x606F;",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,shift:0,icon:-1,scrollbar:!0,tips:2};l.pt.vessel=function(b,a){var d=this.index,c=this.config,f=c.zIndex+d,g="object"==typeof c.title,k=c.maxmin&&(1===c.type||2===c.type),g=c.title?'\x3cdiv class\x3d"layui-layer-title" style\x3d"'+(g?c.title[1]:"")+'"\x3e'+(g?c.title[0]:c.title)+"\x3c/div\x3e":"";return c.zIndex=f,a([c.shade?'\x3cdiv class\x3d"layui-layer-shade" id\x3d"layui-layer-shade'+d+'" times\x3d"'+d+'" style\x3d"'+("z-index:"+(f-1)+"; background-color:"+(c.shade[1]||"#000")+"; opacity:"+(c.shade[0]||c.shade)+"; filter:alpha(opacity\x3d"+(100*c.shade[0]||100*c.shade)+");")+'"\x3e\x3c/div\x3e':"",'\x3cdiv class\x3d"'+e[0]+" "+(e.anim[c.shift]||"")+(" layui-layer-"+h.type[c.type])+(0!=c.type&&2!=c.type||c.shade?"":" layui-layer-border")+" "+(c.skin||"")+'" id\x3d"'+e[0]+d+'" type\x3d"'+h.type[c.type]+'" times\x3d"'+d+'" showtime\x3d"'+c.time+'" conType\x3d"'+(b?"object":"string")+'" style\x3d"z-index: '+f+"; width:"+c.area[0]+";height:"+c.area[1]+(c.fix?"":";position:absolute;")+'"\x3e'+(b&&2!=c.type?"":g)+'\x3cdiv class\x3d"layui-layer-content'+(0==c.type&&-1!==c.icon?" layui-layer-padding":"")+(3==c.type?" layui-layer-loading"+c.icon:"")+'"\x3e'+(0==c.type&&-1!==c.icon?'\x3ci class\x3d"layui-layer-ico layui-layer-ico'+c.icon+'"\x3e\x3c/i\x3e':"")+(1==c.type&&b?"":c.content||"")+'\x3c/div\x3e\x3cspan class\x3d"layui-layer-setwin"\x3e'+function(){var a=k?'\x3ca class\x3d"layui-layer-min" href\x3d"javascript:;"\x3e\x3ccite\x3e\x3c/cite\x3e\x3c/a\x3e\x3ca class\x3d"layui-layer-ico layui-layer-max" href\x3d"javascript:;"\x3e\x3c/a\x3e':"";return c.closeBtn&&(a+='\x3ca class\x3d"layui-layer-ico '+e[7]+" "+e[7]+(c.title?c.closeBtn:4==c.type?"1":"2")+'" href\x3d"javascript:;"\x3e\x3c/a\x3e'),a}()+"\x3c/span\x3e"+(c.btn?function(){var a="";"string"==typeof c.btn&&(c.btn=[c.btn]);for(var b=0,d=c.btn.length;d>b;b++)a+='\x3ca class\x3d"'+e[6]+b+'"\x3e'+c.btn[b]+"\x3c/a\x3e";return'\x3cdiv class\x3d"'+e[6]+'"\x3e'+a+"\x3c/div\x3e"}():"")+"\x3c/div\x3e"],g),this};l.pt.creat=function(){var b=this,a=b.config,d=b.index,c=a.content,f="object"==typeof c;switch("string"==typeof a.area&&(a.area="auto"===a.area?["",""]:[a.area,""]),a.type){case 0:a.btn="btn"in a?a.btn:h.btn[0];layer.closeAll("dialog");break;case 2:c=a.content=f?a.content:[a.content||"http://sentsin.com?from\x3dlayer","auto"];a.content='\x3ciframe scrolling\x3d"'+(a.content[1]||"auto")+'" allowtransparency\x3d"true" id\x3d"'+e[4]+d+'" name\x3d"'+e[4]+d+'" onload\x3d"this.className\x3d\'\';" class\x3d"layui-layer-load" frameborder\x3d"0" src\x3d"'+a.content[0]+'"\x3e\x3c/iframe\x3e';break;case 3:a.title=!1;a.closeBtn=!1;-1===a.icon&&0===a.icon;layer.closeAll("loading");break;case 4:f||(a.content=[a.content,"body"]),a.follow=a.content[1],a.content=a.content[0]+'\x3ci class\x3d"layui-layer-TipsG"\x3e\x3c/i\x3e',a.title=!1,a.shade=!1,a.fix=!1,a.tips="object"==typeof a.tips?a.tips:[a.tips,!0],a.tipsMore||layer.closeAll("tips")}b.vessel(f,function(h,k){g("body").append(h[0]);f?2==a.type||4==a.type?g("body").append(h[1]):c.parents("."+e[0])[0]||(c.show().addClass("layui-layer-wrap").wrap(h[1]),g("#"+e[0]+d).find("."+e[5]).before(k)):g("body").append(h[1]);b.layero=g("#"+e[0]+d);a.scrollbar||e.html.css("overflow","hidden").attr("layer-full",d)}).auto(d);2==a.type&&layer.ie6&&b.layero.find("iframe").attr("src",c[0]);4==a.type?b.tips():b.offset();a.fix&&k.on("resize",function(){b.offset();(/^\d+%$/.test(a.area[0])||/^\d+%$/.test(a.area[1]))&&b.auto(d);4==a.type&&b.tips()});0>=a.time||setTimeout(function(){layer.close(b.index)},a.time);b.move().callback()};l.pt.auto=function(b){function a(a){a=c.find(a);a.height(f[1]-h-l-2*(0|parseFloat(a.css("padding"))))}var d=this.config,c=g("#"+e[0]+b);""===d.area[0]&&0<d.maxWidth&&(/MSIE 7/.test(navigator.userAgent)&&d.btn&&c.width(c.innerWidth()),c.outerWidth()>d.maxWidth&&c.width(d.maxWidth));var f=[c.innerWidth(),c.innerHeight()],h=c.find(e[1]).outerHeight()||0,l=c.find("."+e[6]).outerHeight()||0;switch(d.type){case 2:a("iframe");break;default:""===d.area[1]?d.fix&&f[1]>k.height()&&(f[1]=k.height(),a("."+e[5])):a("."+e[5])}return this};l.pt.offset=function(){var b=this.config,a=this.layero,d=[a.outerWidth(),a.outerHeight()],c="object"==typeof b.offset;this.offsetTop=(k.height()-d[1])/2;this.offsetLeft=(k.width()-d[0])/2;c?(this.offsetTop=b.offset[0],this.offsetLeft=b.offset[1]||this.offsetLeft):"auto"!==b.offset&&(this.offsetTop=b.offset,"rb"===b.offset&&(this.offsetTop=k.height()-d[1],this.offsetLeft=k.width()-d[0]));b.fix||(this.offsetTop=/%$/.test(this.offsetTop)?k.height()*parseFloat(this.offsetTop)/100:parseFloat(this.offsetTop),this.offsetLeft=/%$/.test(this.offsetLeft)?k.width()*parseFloat(this.offsetLeft)/100:parseFloat(this.offsetLeft),this.offsetTop+=k.scrollTop(),this.offsetLeft+=k.scrollLeft());a.css({top:this.offsetTop,left:this.offsetLeft})};l.pt.tips=function(){var b=this.config,a=this.layero,d=[a.outerWidth(),a.outerHeight()],c=g(b.follow);c[0]||(c=g("body"));var f={width:c.outerWidth(),height:c.outerHeight(),top:c.offset().top,left:c.offset().left},h=a.find(".layui-layer-TipsG"),c=b.tips[0];b.tips[1]||h.remove();f.autoLeft=function(){0<f.left+d[0]-k.width()?(f.tipLeft=f.left+f.width-d[0],h.css({right:12,left:"auto"})):f.tipLeft=f.left};f.where=[function(){f.autoLeft();f.tipTop=f.top-d[1]-10;h.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",b.tips[1])},function(){f.tipLeft=f.left+f.width+10;f.tipTop=f.top;h.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",b.tips[1])},function(){f.autoLeft();f.tipTop=f.top+f.height+10;h.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",b.tips[1])},function(){f.tipLeft=f.left-d[0]-10;f.tipTop=f.top;h.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",b.tips[1])}];f.where[c-1]();1===c?0>f.top-(k.scrollTop()+d[1]+16)&&f.where[2]():2===c?0<k.width()-(f.left+f.width+d[0]+16)||f.where[3]():3===c?0<f.top-k.scrollTop()+f.height+d[1]+16-k.height()&&f.where[0]():4===c&&0<d[0]+16-f.left&&f.where[1]();a.find("."+e[5]).css({"background-color":b.tips[1],"padding-right":b.closeBtn?"30px":""});a.css({left:f.tipLeft,top:f.tipTop})};l.pt.move=function(){var b=this.config,a={setY:0,moveLayer:function(){var b=a.layero,d=parseInt(b.css("margin-left")),e=parseInt(a.move.css("left"));0===d||(e-=d);"fixed"!==b.css("position")&&(e-=b.parent().offset().left,a.setY=0);b.css({left:e,top:parseInt(a.move.css("top"))-a.setY})}},d=this.layero.find(b.move);return b.move&&d.attr("move","ok"),d.css({cursor:b.move?"move":"auto"}),g(b.move).on("mousedown",function(c){if(c.preventDefault(),"ok"===g(this).attr("move")){a.ismove=!0;a.layero=g(this).parents("."+e[0]);var d=a.layero.offset().left,h=a.layero.offset().top,l=a.layero.outerWidth()-6,m=a.layero.outerHeight()-6;g("#layui-layer-moves")[0]||g("body").append('\x3cdiv id\x3d"layui-layer-moves" class\x3d"layui-layer-moves" style\x3d"left:'+d+"px; top:"+h+"px; width:"+l+"px; height:"+m+'px; z-index:2147483584"\x3e\x3c/div\x3e');a.move=g("#layui-layer-moves");b.moveType&&a.move.css({visibility:"hidden"});a.moveX=c.pageX-a.move.position().left;a.moveY=c.pageY-a.move.position().top;"fixed"!==a.layero.css("position")||(a.setY=k.scrollTop())}}),g(document).mousemove(function(c){if(a.ismove){var d=c.pageX-a.moveX,e=c.pageY-a.moveY;if(c.preventDefault(),!b.moveOut){a.setY=k.scrollTop();c=k.width()-a.move.outerWidth();var g=a.setY;0>d&&(d=0);d>c&&(d=c);g>e&&(e=g);e>k.height()-a.move.outerHeight()+a.setY&&(e=k.height()-a.move.outerHeight()+a.setY)}a.move.css({left:d,top:e});b.moveType&&a.moveLayer()}}).mouseup(function(){try{a.ismove&&(a.moveLayer(),a.move.remove()),a.ismove=!1}catch(c){a.ismove=!1}b.moveEnd&&b.moveEnd()}),this};l.pt.callback=function(){function b(){!1===(c.cancel&&c.cancel(a.index))||layer.close(a.index)}var a=this,d=a.layero,c=a.config;a.openLayer();c.success&&(2==c.type?d.find("iframe")[0].onload=function(){this.className="";c.success(d,a.index)}:c.success(d,a.index));layer.ie6&&a.IE6(d);d.find("."+e[6]).children("a").on("click",function(){var e=g(this).index();0===e?c.yes?c.yes(a.index,d):layer.close(a.index):1===e?b():c["btn"+(e+1)]?c["btn"+(e+1)](a.index,d):layer.close(a.index)});d.find("."+e[7]).on("click",b);c.shadeClose&&g("#layui-layer-shade"+a.index).on("click",function(){layer.close(a.index)});d.find(".layui-layer-min").on("click",function(){layer.min(a.index,c);c.min&&c.min(d)});d.find(".layui-layer-max").on("click",function(){g(this).hasClass("layui-layer-maxmin")?(layer.restore(a.index),c.restore&&c.restore(d)):(layer.full(a.index,c),c.full&&c.full(d))});c.end&&(h.end[a.index]=c.end)};h.reselect=function(){g.each(g("select"),function(b,a){var d=g(this);d.parents("."+e[0])[0]||1==d.attr("layer")&&1>g("."+e[0]).length&&d.removeAttr("layer").show()})};l.pt.IE6=function(b){function a(){b.css({top:c+(d.config.fix?k.scrollTop():0)})}var d=this,c=b.offset().top;a();k.scroll(a);g("select").each(function(a,b){var c=g(this);c.parents("."+e[0])[0]||"none"===c.css("display")||c.attr({layer:"1"}).hide()})};l.pt.openLayer=function(){layer.zIndex=this.config.zIndex;layer.setTop=function(b){return layer.zIndex=parseInt(b[0].style.zIndex),b.on("mousedown",function(){layer.zIndex++;b.css("z-index",layer.zIndex+1)}),layer.zIndex}};h.record=function(b){var a=[b.outerWidth(),b.outerHeight(),b.position().top,b.position().left+parseFloat(b.css("margin-left"))];b.find(".layui-layer-max").addClass("layui-layer-maxmin");b.attr({area:a})};h.rescollbar=function(b){e.html.attr("layer-full")==b&&(e.html[0].style.removeProperty?e.html[0].style.removeProperty("overflow"):e.html[0].style.removeAttribute("overflow"),e.html.removeAttr("layer-full"))};layer.getChildFrame=function(b,a){return a=a||g("."+e[4]).attr("times"),g("#"+e[0]+a).find("iframe").contents().find(b)};layer.getFrameIndex=function(b){return g("#"+b).parents("."+e[4]).attr("times")};layer.iframeAuto=function(b){if(b){var a=layer.getChildFrame("body",b).outerHeight();b=g("#"+e[0]+b);var d=b.find(e[1]).outerHeight()||0,c=b.find("."+e[6]).outerHeight()||0;b.css({height:a+d+c});b.find("iframe").css({height:a})}};layer.iframeSrc=function(b,a){g("#"+e[0]+b).find("iframe").attr("src",a)};layer.style=function(b,a){var d=g("#"+e[0]+b),c=d.attr("type"),f=d.find(e[1]).outerHeight()||0,k=d.find("."+e[6]).outerHeight()||0;c!==h.type[1]&&c!==h.type[2]||(d.css(a),c!==h.type[2]||d.find("iframe").css({height:parseFloat(a.height)-f-k}))};layer.min=function(b,a){var d=g("#"+e[0]+b),c=d.find(e[1]).outerHeight()||0;h.record(d);layer.style(b,{width:180,height:c,overflow:"hidden"});d.find(".layui-layer-min").hide();"page"===d.attr("type")&&d.find(e[4]).hide();h.rescollbar(b)};layer.restore=function(b){var a=g("#"+e[0]+b),d=a.attr("area").split(",");a.attr("type");layer.style(b,{width:parseFloat(d[0]),height:parseFloat(d[1]),top:parseFloat(d[2]),left:parseFloat(d[3]),overflow:"visible"});a.find(".layui-layer-max").removeClass("layui-layer-maxmin");a.find(".layui-layer-min").show();"page"===a.attr("type")&&a.find(e[4]).show();h.rescollbar(b)};layer.full=function(b){var a,d=g("#"+e[0]+b);h.record(d);e.html.attr("layer-full")||e.html.css("overflow","hidden").attr("layer-full",b);clearTimeout(a);a=setTimeout(function(){var a="fixed"===d.css("position");layer.style(b,{top:a?0:k.scrollTop(),left:a?0:k.scrollLeft(),width:k.width(),height:k.height()});d.find(".layui-layer-min").hide()},100)};layer.title=function(b,a){g("#"+e[0]+(a||layer.index)).find(e[1]).html(b)};layer.close=function(b){var a=g("#"+e[0]+b),d=a.attr("type");if(a[0]){if(d===h.type[1]&&"object"===a.attr("conType"))for(a.children(":not(."+e[5]+")").remove(),d=0;2>d;d++)a.find(".layui-layer-wrap").unwrap().hide();else{if(d===h.type[2])try{var c=g("#"+e[4]+b)[0];c.contentWindow.document.write("");c.contentWindow.close();a.find("."+e[5])[0].removeChild(c)}catch(f){}a[0].innerHTML="";a.remove()}g("#layui-layer-moves, #layui-layer-shade"+b).remove();layer.ie6&&h.reselect();h.rescollbar(b);"function"==typeof h.end[b]&&h.end[b]();delete h.end[b]}};layer.closeAll=function(b){g.each(g("."+e[0]),function(){var a=g(this);(b?a.attr("type")===b:1)&&layer.close(a.attr("times"))})};h.run=function(){g=jQuery;k=g(m);e.html=g("html");layer.open=function(b){return(new l(b)).index}};"function"==typeof define?define(function(){return h.run(),layer}):(h.run(),layer.use("skin/layer.css"))}(window);
|