/************************************************************** @name: layer v1.8.1 弹层组件压缩版 @author: 贤心 @date: 2014-05-16 @blog: http://sentsin.com @qq群:78803422 (layer组件群3) @copyright: sentsin xu(贤心) @官网:http://sentsin.com/jquery/layer @授权: http://item.taobao.com/item.htm?id=37295654589 *************************************************************/ !function(a,b){ "use strict"; var e,f,h,i, c=!0, //是否采用自动获取绝对路径。!1:将采用下述变量中的配置 d="lily/lib/layer/", //上述变量为!1才有效,当前layerjs所在目录(不用填写host,相对站点的根目录即可)。 g={hosts:function(){var a=location.href.match(/\:\d+/);return a=a?a[0]:"","http://"+document.domain+a+"/"}(),getpath:function(){var a=document.scripts,b=a[a.length-1].src;return c?b.substring(0,b.lastindexof("/")+1):this.hosts+d}};a.layer={v:"1.8.1",ie6:!-[1,]&&!a.xmlhttprequest,index:0,path:g.getpath(),use:function(a,b){var f,g,h,d=e("head")[0];a=a.replace(/\s/g,""),f=/\.css$/.test(a),g=document.createelement(f?"link":"script"),h=a.replace(/\.|\//g,""),f&&(g.setattribute("type","text/css"),g.setattribute("rel","stylesheet")),g.setattribute(f?"href":"src",/^http:\/\//.test(a)?a:layer.path+a),g.setattribute("id",h),e("#"+h)[0]||d.appendchild(g),b&&(document.all?e(g).ready(b):e(g).load(b))},ready:function(a){layer.use("skin/layer.css",a)},alert:function(a,b,c,d){var f="function"==typeof c,g={dialog:{msg:a,type:b,yes:f?c:d},area:["auto","auto"]};return f||(g.title=c),e.layer(g)},confirm:function(a,b,c,d){var f="function"==typeof c,g={dialog:{msg:a,type:4,btns:2,yes:b,no:f?c:d}};return f||(g.title=c),e.layer(g)},msg:function(a,c,d,f){var g={title:!1,closebtn:!1,time:c===b?2:c,dialog:{msg:""===a||a===b?" ":a},end:f};return"object"==typeof d?(g.dialog.type=d.type,g.shade=d.shade,g.success=function(){layer.shift(d.rate)}):"function"==typeof d?g.end=d:g.dialog.type=d,e.layer(g)},load:function(a,b){return"string"==typeof a?this.msg(a,b,16):e.layer({time:a,loading:{type:b},bgcolor:b?"#fff":"",shade:b?[.1,"#000"]:[0],border:3!==b&&b?[6,.3,"#000"]:!1,type:3,title:["",!1],closebtn:[0,!1]})},tips:function(a,b,c,d,f,g){var h={type:4,shade:!1,success:function(a){this.closebtn||a.find(".xubox_tips").css({"padding-right":10})},bgcolor:"",tips:{msg:a,follow:b}};return c=c||{},h.time=c.time||c,h.closebtn=c.closebtn||!1,h.maxwidth=c.maxwidth||d,h.tips.guide=c.guide||f,h.tips.style=c.style||g,e.layer(h)}},h=function(a){var b=this.config;layer.index++,this.index=layer.index,this.config=e.extend({},b,a),this.config.dialog=e.extend({},b.dialog,a.dialog),this.config.page=e.extend({},b.page,a.page),this.config.iframe=e.extend({},b.iframe,a.iframe),this.config.loading=e.extend({},b.loading,a.loading),this.config.tips=e.extend({},b.tips,a.tips),this.creat()},h.pt=h.prototype,h.pt.config=layer.config||{type:0,shade:[.3,"#000"],shadeclose:!1,fix:!0,move:".xubox_title",moveout:!1,title:["信息",!0],offset:["200px","50%"],area:["310px","auto"],closebtn:[0,!0],time:0,bgcolor:"#fff",border:[6,.3,"#000"],zindex:19891014,maxwidth:400,dialog:{btns:1,btn:["确定","取消"],type:3,msg:"",yes:function(a){layer.close(a)},no:function(a){layer.close(a)}},page:{dom:"#xulayer",html:"",url:""},iframe:{src:"http://sentsin.com",scrolling:"auto"},loading:{type:0},tips:{msg:"",follow:"",guide:0,isguide:!0,style:["background-color:#ff9900; color:#fff;","#ff9900"]},success:function(){},close:function(a){layer.close(a)},end:function(){}},h.pt.type=["dialog","page","iframe","loading","tips"],h.pt.space=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return a=a||"",b=this.index,c=this.config,d=c.dialog,e=this.dom,f=-1===d.type?"":'',g=['
'+f+''+d.msg+"
",'
'+a+"
",'','','
'+c.tips.msg+'
'],h="",i="",j=c.zindex+b,k="z-index:"+j+"; background-color:"+c.shade[1]+"; opacity:"+c.shade[0]+"; filter:alpha(opacity="+100*c.shade[0]+");",c.shade[0]&&(h='
'),c.zindex=j,l="",m="",n="z-index:"+(j-1)+"; background-color: "+c.border[2]+"; opacity:"+c.border[1]+"; filter:alpha(opacity="+100*c.border[1]+"); top:-"+c.border[0]+"px; left:-"+c.border[0]+"px;",c.border[0]&&(i='
'),!c.maxmin||1!==c.type&&2!==c.type||/^\d+%$/.test(c.area[0])&&/^\d+%$/.test(c.area[1])||(m=''),c.closebtn[1]&&(m+=''),c.title[1]&&(l='
'+c.title[0]+"
"),[h,'
'+'
'+g[c.type]+l+''+m+""+''+"
"+i+"
"]},h.pt.dom={lay:"xubox_layer",ifr:"xubox_iframe",title:".xubox_title",text:".xubox_text",page:".xubox_page"},h.pt.creat=function(){var l,m,n,a=this,b="",c=a.config,d=c.dialog,g=a.dom,h=a.index,i=c.page,j=e("body"),k=function(c){var c=c||"";b=a.space(c),j.append(e(b[0]))};switch(c.title===!1?c.title=[]:"string"==typeof c.title&&(c.title=[c.title,!0]),c.type){case 0:c.title[1]||(c.area=["auto","auto"]),e(".xubox_dialog")[0]&&layer.close(e(".xubox_dialog").parents("."+g.lay).attr("times"));break;case 1:if(""!==i.html)k('
'+i.html+"
"),j.append(e(b[1]));else if(""!==i.url)k('
'+i.html+"
"),j.append(e(b[1])),e.get(i.url,function(a){e("#xuboxpagehtml"+h).html(a.tostring()),i.ok&&i.ok(a)});else{if(0!=e(i.dom).parents(g.page).length)return;k(),e(i.dom).show().wrap(e(b[1]))}break;case 3:c.title=[],c.area=["auto","auto"],c.closebtn=["",!1],e(".xubox_loading")[0]&&layer.close(e(".xubox_loading").parents("."+g.lay).attr("times"));break;case 4:c.title=[],c.area=["auto","auto"],c.fix=!1,c.border=[0],e(".xubox_tips")[0]&&layer.close(e(".xubox_tips").parents("."+g.lay).attr("times"))}if(1!==c.type&&(k(),j.append(e(b[1]))),l=a.layere=e("#"+g.lay+h),a.offsettop=-1!=c.offset[0].indexof("px")?parsefloat(c.offset[0]):parsefloat(c.offset[0])/100*f.height(),a.offsettop=a.offsettop+c.border[0]+(c.fix?0:f.scrolltop()),-1!=c.offset[1].indexof("px")?a.offsetleft=parsefloat(c.offset[1])+c.border[0]:(c.offset[1]=""===c.offset[1]?"50%":c.offset[1],a.offsetleft="50%"===c.offset[1]?c.offset[1]:parsefloat(c.offset[1])/100*f.width()+c.border[0]),l.css({left:a.offsetleft,top:a.offsettop,width:c.area[0],height:c.area[1]}),c.fix||l.css({position:"absolute"}),c.title[1]&&(3!==c.type||4!==c.type))switch(m=0===c.type?d:c,n=l.find(".xubox_botton"),m.btn=c.btn||d.btn,m.btns){case 0:n.html("").hide();break;case 1:n.html(''+m.btn[0]+"");break;case 2:n.html(''+m.btn[0]+""+''+m.btn[1]+"")}"auto"===l.css("left")?(l.hide(),settimeout(function(){l.show(),a.set(h)},500)):a.set(h),c.time<=0||a.autoclose(),a.callback()},h.pt.set=function(a){var l,m,n,o,p,q,b=this,c=b.dom,d=b.layere,g=d.find(c.title),h=b.config,j=(h.dialog,h.page);switch(h.loading,b.autoarea(a),h.title[1]?0===h.type&&layer.ie6&&g.css({width:d.outerwidth()}):4!=h.type&&d.find(".xubox_close").addclass("xubox_close1"),d.attr({type:b.type[h.type]}),h.type){case 0:d.find(".xubox_main").css({"background-color":"#fff"}),h.title[1]?d.find(c.text).css({paddingtop:18+g.outerheight()}):(d.find(".xubox_msgico").css({top:8}),d.find(c.text).css({margintop:11}));break;case 1:d.find(j.dom).addclass("layer_pagecontent"),h.shade[0]&&d.css({zindex:h.zindex+1}),h.title[1]&&d.find(c.page).css({top:g.outerheight()});break;case 2:l=d.find("."+c.ifr),m=d.height(),l.addclass("xubox_load").css({width:d.width()}),h.title[1]?l.css({top:g.height(),height:m-g.height()}):l.css({top:0,height:m}),layer.ie6&&l.attr("src",h.iframe.src);break;case 4:n=[0,d.outerheight()],o=e(h.tips.follow),p={width:o.outerwidth(),height:o.outerheight(),top:o.offset().top,left:o.offset().left},q=d.find(".layertipsg"),h.tips.isguide||q.remove(),d.outerwidth()>h.maxwidth&&d.width(h.maxwidth),p.tipcolor=h.tips.style[1],n[0]=d.outerwidth(),p.where=[function(){p.tipleft=p.left,p.tiptop=p.top-n[1]-10,q.removeclass("layertipsb").addclass("layertipst").css({"border-right-color":p.tipcolor})},function(){p.tipleft=p.left+p.width+10,p.tiptop=p.top,q.removeclass("layertipsl").addclass("layertipsr").css({"border-bottom-color":p.tipcolor})},function(){p.tipleft=p.left,p.tiptop=p.top+p.height+10,q.removeclass("layertipst").addclass("layertipsb").css({"border-right-color":p.tipcolor})},function(){p.tipleft=p.left-n[0]+10,p.tiptop=p.top,q.removeclass("layertipsr").addclass("layertipsl").css({"border-bottom-color":p.tipcolor})}],p.where[h.tips.guide](),0===h.tips.guide?p.top-(f.scrolltop()+n[1]+16)<0&&p.where[2]():1===h.tips.guide?f.width()-(p.left+p.width+n[0]+16)>0||p.where[3]():2===h.tips.guide?p.top-f.scrolltop()+p.height+n[1]+16-f.height()>0&&p.where[0]():3===h.tips.guide&&n[0]+16-p.left>0&&p.where[1](),d.css({left:p.tipleft,top:p.tiptop})}h.fadein&&d.css({opacity:0}).animate({opacity:1},h.fadein),b.move()},h.pt.autoarea=function(a){var c,d,f,g,h,i,k,j,l,m,n,o,b=this;switch(a=a||b.index,c=b.dom,d=b.config,f=d.page,g=e("#"+c.lay+a),h=g.find(c.title),i=g.find(".xubox_main"),j=d.title[1]?h.innerheight():0,l=0,"auto"===d.area[0]&&i.outerwidth()>=d.maxwidth&&g.css({width:d.maxwidth}),d.type){case 0:m=g.find(".xubox_botton>a"),k=g.find(c.text).outerheight()+20,m.length>0&&(l=m.outerheight()+20);break;case 1:n=g.find(c.page),k=e(f.dom).outerheight(),"auto"===d.area[0]&&g.css({width:n.outerwidth()}),(""!==f.html||""!==f.url)&&(k=n.outerheight());break;case 2:g.find("iframe").css({width:g.outerwidth(),height:g.outerheight()-(d.title[1]?h.innerheight():0)});break;case 3:o=g.find(".xubox_loading"),k=o.outerheight(),i.css({width:o.width()})}"auto"===d.area[1]&&i.css({height:j+k+l}),e("#xubox_border"+a).css({width:g.outerwidth()+2*d.border[0],height:g.outerheight()+2*d.border[0]}),layer.ie6&&"auto"!==d.area[0]&&i.css({width:g.outerwidth()}),"50%"!==d.offset[1]&&""!=d.offset[1]||4===d.type?g.css({marginleft:0}):g.css({marginleft:-g.outerwidth()/2})},h.pt.move=function(){var a=this,b=this.config,c=a.dom,d={sety:0,movelayer:function(){var a;a=0==parseint(d.layere.css("margin-left"))?parseint(d.move.css("left")):parseint(d.move.css("left"))+-parseint(d.layere.css("margin-left")),"fixed"!==d.layere.css("position")&&(a-=d.layere.parent().offset().left,d.sety=0),d.layere.css({left:a,top:parseint(d.move.css("top"))-d.sety})}};b.move&&a.layere.find(b.move).attr("move","ok"),b.move?a.layere.find(b.move).css({cursor:"move"}):a.layere.find(b.move).css({cursor:"auto"}),e(b.move).on("mousedown",function(a){if(a.preventdefault(),"ok"===e(this).attr("move")){d.ismove=!0,d.layere=e(this).parents("."+c.lay);var g=d.layere.offset().left,h=d.layere.offset().top,i=d.layere.width()-6,j=d.layere.height()-6;e("#xubox_moves")[0]||e("body").append('
'),d.move=e("#xubox_moves"),b.movetype&&d.move.css({opacity:0}),d.movex=a.pagex-d.move.position().left,d.movey=a.pagey-d.move.position().top,"fixed"!==d.layere.css("position")||(d.sety=f.scrolltop())}}),e(document).mousemove(function(a){var c,e,g,h;d.ismove&&(c=a.pagex-d.movex,e=a.pagey-d.movey,a.preventdefault(),b.moveout||(d.sety=f.scrolltop(),g=f.width()-d.move.outerwidth()-b.border[0],h=b.border[0]+d.sety,cg&&(c=g),h>e&&(e=h),e>f.height()-d.move.outerheight()-b.border[0]+d.sety&&(e=f.height()-d.move.outerheight()-b.border[0]+d.sety)),d.move.css({left:c,top:e}),b.movetype&&d.movelayer(),c=null,e=null,g=null,h=null)}).mouseup(function(){try{d.ismove&&(d.movelayer(),d.move.remove()),d.ismove=!1}catch(a){d.ismove=!1}b.moveend&&b.moveend()})},h.pt.autoclose=function(){var a=this,b=this.config.time,c=function(){b--,0===b&&(layer.close(a.index),clearinterval(a.autotime))};this.autotime=setinterval(c,1e3)},g.config={end:{}},h.pt.callback=function(){var a=this,b=a.layere,c=a.config,d=c.dialog;a.openlayer(),a.config.success(b),layer.ie6&&a.ie6(b),b.find(".xubox_close").on("click",function(){c.close(a.index),layer.close(a.index)}),b.find(".xubox_yes").on("click",function(){c.yes?c.yes(a.index):d.yes(a.index)}),b.find(".xubox_no").on("click",function(){c.no?c.no(a.index):d.no(a.index),layer.close(a.index)}),a.config.shadeclose&&e("#xubox_shade"+a.index).on("click",function(){layer.close(a.index)}),b.find(".xubox_min").on("click",function(){layer.min(a.index,c),c.min&&c.min(b)}),b.find(".xubox_max").on("click",function(){e(this).hasclass("xubox_maxmin")?(layer.restore(a.index),c.restore&&c.restore(b)):(layer.full(a.index,c),c.full&&c.full(b))}),g.config.end[a.index]=c.end},h.pt.ie6=function(a){var h,b=this,c=e("select"),d=b.dom,g=a.offset().top;h=b.config.fix?function(){a.css({top:f.scrolltop()+g})}:function(){a.css({top:g})},h(),f.scroll(h),e.each(c,function(){var c=e(this);c.parents("."+d.lay)[0]||"none"==c.css("display")||c.attr({layer:"1"}).hide(),c=null}),b.reselect=function(){e.each(c,function(){var c=e(this);c.parents("."+d.lay)[0]||1==c.attr("layer")&&e("."+d.lay).length<1&&c.removeattr("layer").show(),c=null})}},h.pt.openlayer=function(){var a=this,b=a.dom,c={};b.html=e("html"),layer.autoarea=function(b){return a.autoarea(b)},layer.getindex=function(a){return e(a).parents("."+b.lay).attr("times")},layer.getchildframe=function(a,c){return c=c||e("."+b.ifr).parents("."+b.lay).attr("times"),e("#"+b.lay+c).find("."+b.ifr).contents().find(a)},layer.getframeindex=function(a){return e(a?"#"+a:"."+b.ifr).parents("."+b.lay).attr("times")},layer.iframeauto=function(a){var c,d,f,g,h;a=a||e("."+b.ifr).parents("."+b.lay).attr("times"),c=this.getchildframe("body",a).outerheight(),d=e("#"+b.lay+a),f=d.find(b.title),g=0,f&&(g=f.height()),d.css({height:c+g}),h=-parseint(e("#xubox_border"+a).css("top")),e("#xubox_border"+a).css({height:c+2*h+g}),e("#"+b.ifr+a).css({height:c})},c.isauto=function(a,b,c){"auto"===b.area[0]&&(b.area[0]=a.outerwidth()),"auto"===b.area[1]&&(b.area[1]=a.outerheight()),a.attr({area:b.area+","+c}),a.find(".xubox_max").addclass("xubox_maxmin")},c.rescollbar=function(a){b.html.attr("layer-full")==a&&(b.html[0].style.removeproperty?b.html[0].style.removeproperty("overflow"):b.html[0].style.removeattribute("overflow"),b.html.removeattr("layer-full"))},layer.min=function(a,d){var f=e("#"+b.lay+a),g=[f.position().top,f.position().left+parsefloat(f.css("margin-left"))];c.isauto(f,d,g),layer.area(a,{width:180,height:35}),f.find(".xubox_min").hide(),"page"===f.attr("type")&&f.find(b.page).hide(),c.rescollbar(a)},layer.restore=function(a){var d=e("#"+b.lay+a),f=d.attr("area").split(",");d.attr("type"),layer.area(a,{width:parsefloat(f[0]),height:parsefloat(f[1]),top:parsefloat(f[2]),left:parsefloat(f[3])}),d.find(".xubox_max").removeclass("xubox_maxmin"),d.find(".xubox_min").show(),"page"===d.attr("type")&&d.find(b.page).show(),c.rescollbar(a)},layer.full=function(a,d){var i,g=e("#"+b.lay+a),h=2*d.border[0],j=[g.position().top,g.position().left+parsefloat(g.css("margin-left"))];c.isauto(g,d,j),b.html.attr("layer-full")||b.html.css("overflow","hidden").attr("layer-full",a),cleartimeout(i),i=settimeout(function(){layer.area(a,{top:"fixed"===g.css("position")?0:f.scrolltop(),left:"fixed"===g.css("position")?0:f.scrollleft(),width:f.width()-h,height:f.height()-h})},100)},layer.close=function(d){var j,f=e("#"+b.lay+d),h=f.attr("type"),i=e("#xubox_moves, #xubox_shade"+d);if(f[0]){if(h==a.type[1])if(f.find(".xuboxpagehtml")[0])f[0].innerhtml="",f.remove();else for(f.find(".xubox_setwin,.xubox_close,.xubox_botton,.xubox_title,.xubox_border").remove(),j=0;3>j;j++)f.find(".layer_pagecontent").unwrap().hide();else f[0].innerhtml="",f.remove();i.remove(),layer.ie6&&a.reselect(),c.rescollbar(d),"function"==typeof g.config.end[d]&&g.config.end[d](),delete g.config.end[d]}},layer.closeload=function(){var a=e(".xubox_loading").parents("."+b.lay),c=a.attr("times");layer.close(c)},layer.closetips=function(){var a=e(".xubox_tips");a[0]&&layer.close(a.parents(".xubox_layer").attr("times"))},layer.closeall=function(){var a=e("."+b.lay);e.each(a,function(){var a=e(this).attr("times");layer.close(a)})},layer.shift=function(b,c,d){var e,g,h,i,j,k;if(!layer.ie6)switch(e=a.config,g=a.layere,h=0,i=f.width(),j=f.height()+(e.fix?0:f.scrolltop()),h="50%"==e.offset[1]||""==e.offset[1]?g.outerwidth()/2:g.outerwidth(),k={t:{top:a.offsettop},b:{top:j-g.outerheight()-e.border[0]},cl:h+e.border[0],ct:-g.outerheight(),cr:i-h-e.border[0]},b){case"left-top":g.css({left:k.cl,top:k.ct}).animate(k.t,c);break;case"top":g.css({top:k.ct}).animate(k.t,c);break;case"right-top":g.css({left:k.cr,top:k.ct}).animate(k.t,c);break;case"right-bottom":g.css({left:k.cr,top:j}).animate(d?k.t:k.b,c);break;case"bottom":g.css({top:j}).animate(d?k.t:k.b,c);break;case"left-bottom":g.css({left:k.cl,top:j}).animate(d?k.t:k.b,c);break;case"left":g.css({left:-g.outerwidth()}).animate({left:a.offsetleft},c)}},layer.setmove=function(){return a.move()},layer.area=function(c,d){var j,f=[e("#"+b.lay+c),e("#xubox_border"+c)],g=f[0].attr("type"),h=f[0].find(".xubox_main"),i=f[0].find(b.title);(g===a.type[1]||g===a.type[2])&&(f[0].css(d),h.css({width:d.width,height:d.height}),g===a.type[2]&&(j=f[0].find("iframe"),j.css({width:d.width,height:i?d.height-i.innerheight():d.height})),"0px"!==f[0].css("margin-left")&&(d.hasownproperty("top")&&f[0].css({top:d.top-(f[1][0]&&parsefloat(f[1].css("top")))}),d.hasownproperty("left")&&f[0].css({left:d.left+f[0].outerwidth()/2-(f[1][0]&&parsefloat(f[1].css("left")))}),f[0].css({marginleft:-f[0].outerwidth()/2})),f[1][0]&&f[1].css({width:parsefloat(d.width)-2*parsefloat(f[1].css("left")),height:parsefloat(d.height)-2*parsefloat(f[1].css("top"))}))},layer.iframesrc=function(a,c){e("#"+b.lay+a).find("iframe").attr("src",c)},layer.zindex=a.config.zindex,layer.settop=function(a){var b=function(){layer.zindex++,a.css("z-index",layer.zindex+1)};return layer.zindex=parseint(a[0].style.zindex),a.on("mousedown",b),layer.zindex}},g.run=function(){e=jquery,f=e(a),layer.use("skin/layer.css"),e.layer=function(a){var b=new h(a);return b.index},(new image).src=layer.path+"skin/default/xubox_ico0.png"},i="../../init/jquery",a.seajs?define([i],function(b,c){g.run(),c.layer=[a.layer,a.$.layer]}):g.run()}(window);