(function(window,$,undefined){ window.popup = { numbers : 0, index : 1000, domname : ['','alert','confirm','prompt','layer','iframe','loading','taps'] } var fun = function(j_){ var that = this, jd = { addtarget : $('body'), type : 1, cname : "", shade :{yes : 1, bgcolor : '#000000', opacity : 0.5, animate : {type : 1 , target : 0.6}, close : false}, area : {w : 'auto', h : 'auto'}, offset : {fix : 1, t : 'auto',r : 'auto', b : 'auto', l : 'auto'}, zindex :{yes:0,val:1000}, animate : {type : 1, target : 1}, autoclose : {yes : 0, time : 0}, move : {yes : 1, handle : '.evpopuphead'}, head : {yes : 1, text : 'ϵͳ��ʾ'}, opbut : {yes : 1, close : 1, min : 0, max : 0}, con : { text : [1,"��ʾ��ϣ"], img : [1,"wran"], src : 'http://www.ev123.net', html : "
����html����
" }, but : { yes : 0, button : {} }, bfun : function(){} }; //�ж��������ĭ��ֵ switch(j_.type){ case 1 : jd.but.yes = 1; jd.but.button = { but_1 : {text:"ȷ��" ,fun : function(){}} } break; case 2 : jd.but.yes = 1; jd.but.button = { but_1 : {text:"ȷ��" ,fun : function(){}}, but_2 : {text:"ȡ��" ,fun : function(){}} } break; case 3 : jd.but.yes = 1; jd.but.button = { but_1 : {text:"ȷ��" ,fun : function(){}}, but_2 : {text:"ȡ��" ,fun : function(){}} } break; case 4 : break; case 5 : break; case 6 : jd.head.yes = 0; jd.opbut.yes = 0; jd.con.img[0] = 1; jd.con.img[1] = "loading"; break; case 7 : jd.head.yes = 0; jd.opbut.yes = 0; break; } that.j = $.extend(true,{},jd,j_); popup.numbers++; that.numbers = popup.numbers; if(that.j.zindex.yes){ that.index = that.j.zindex.val }else{ that.index = popup.index; } that.createdom(); }; //fun���캯��ԭ�� fun.pt = fun.prototype; //�õ����ڵŀ�ߣ�dom�ŀ�ߣ�elemnet�ŀ�� fun.pt.winattr = function(o){ this.winw = $(window).width(); this.winh = $(window).height(); this.domw = $(document).width(); this.domh = $(document).height(); this.domst = $(document).scrolltop(); this.domsl = $(document).scrollleft(); this.popupw = o.width(); this.popuph = o.height(); }; //���dom������ fun.pt.createdom = function(){ var that = this, j = that.j, evshade = $(''), evpopup = $(''), evremovepopup = $(''), evhidepopup = $(''), evshowpopup = $(''), evpopupopbut = $(''), evpopuphead =$(''+ j.con.text[1] +'
'); evpopupcon.append(tops); break; } //������ݵ������� evpopupbody.find(".evpopupbodycc").append(evpopupcon); //��ӵ�����ť if(j.but.yes){ if(j.type == 1 || j.type == 2 || j.type == 3){ var butlength = 0,butwidth = 0,x = "",cname=""; //���ݴ���i�ť����ѭ����ӱ�ť for(x in j.but.button){ butlength++; cname = j.but.button[x]["cname"] || ""; var popupbut = $(''+ j.but.button[x]['text'] +''); popupbut.data("data-name",x).appendto(evpopupbut.children(".evpopupbut")); } //����ť���ÿ�� evpopupbut.find(".popupbut").each(function(){ $(this).width(100/butlength+"%"); }); //����ť���¼� evpopupbut.on({ click : function(){ var dataname = $(this).data('data-name'); if(typeof(j.but.button[dataname]['fun'])==='function'){ j.but.button[dataname]['fun'](); } evremovepopup.trigger("click"); } },".popupbut"); } evpopupbut.appendto(evpopup); } //�жϵ������� j.head.yes ? evpopuphead.prependto(evpopup) : "";//����������ӱ��� evpopup.append(evpopupbody).appendto(j.addtarget);//�ѵ�������ӵ�ҳ���� that.popupcountwh(evpopup); //���ú������㵯������ that.winattr(evpopup); //��ⴰ�ں�dom�ŀ�ߡ� //���� if(j.shade.yes){ evshade.appendto(j.addtarget);//�ж�������� that.shadecountwh(evshade);//�������ֵŀ�� that.openanimate(evshade,j.shade.animate);//���ֶ��� //�ж��ƿ��������ӵ���¼� j.shade.close ? evshade.on("click",function(){ that.closeanimate(evshade,j.shade.animate); that.closeanimate(evpopup,j.animate); }) : ""; } that.popupoffset(evpopup); that.openanimate(evpopup,j.animate); //�զ��ر� if(j.autoclose.yes){ settimeout(function(){ evremovepopup.trigger("click"); },j.autoclose.time*1000); //that.autoclose(evpopup); } if(j.move.yes){ that.popupmove(evpopup); } }; //���������� fun.pt.popupcountwh = function(evpopup){ var that = this, j = that.j, hh = 0, buth = 0, ch = 0, lh= 0, evpopupbodycc = evpopup.find(".evpopupbodycc"); if(j.head.yes){ hh = evpopup.find(".evpopuphead").height(); var padt = hh - evpopup.children("div.evpopupbody").children('div.evpopupbodyt').height(); evpopupbodycc.css({"padding-top":padt+"px"}); ch -=hh; } if(j.but.yes){ buth = evpopup.find(".evpopupbutarea").height(); evpopupbodycc.css({"padding-bottom":buth+"px"}); ch = ch-buth; } if(j.area.w != "auto"){ evpopup.css({"width":j.area.w+"px"}); } if(j.area.h != "auto"){ evpopup.css({"height":j.area.h+"px"}); ch = j.area.h - evpopup.children("div.evpopupbody").children('div.evpopupbodyt').height() - evpopup.children("div.evpopupbody").children('.evpopupbodyb').height()+ch; }else{ ch = evpopup.height()-evpopup.children("div.evpopupbody").children('div.evpopupbodyt').height() - evpopup.children("div.evpopupbody").children('.evpopupbodyb').height()+ch; } evpopupbodycc.css({"height":ch+"px"}); if(j.type == 5){ if(j.area.w == 'auto' && j.area.h == 'auto'){ var loadingwait = $(''), loadh = evpopupbodycc.outerheight(), iframes = evpopupbodycc.find("iframe"); loadingwait.css({"height":loadh + "px"}).appendto(evpopupbodycc); iframes.load(function(){ loadingwait.remove(); iframes[0].contentwindow.iframenumber = that.numbers; var iw = iframes.contents().width(), ih = iframes.contents().height(); evpopupbodycc.children("div.eviframecon").css({"width":iw+"px","height":ih+"px"}); iframes.css({"width":iw+"px","height":ih+"px"}); var iew = evpopup.find(".evpopupbodyc").outerwidth(); evpopup.css({"width":iew+"px"}); that.winattr(evpopup); that.popupoffset(evpopup); }); }else{ var iw = evpopup.children(".evpopupbody").find("div.eviframecon").width(), ih = evpopup.children(".evpopupbody").find("div.eviframecon").height(), loadingwait = $(''), loadh = evpopupbodycc.outerheight(), iframes = evpopupbodycc.find("iframe"); loadingwait.css({"height":loadh + "px","width":"100%"}).appendto(evpopupbodycc); iframes.css({"width":iw+"px","height":ih+"px","top":"10px"}); iframes.load(function(){ iframes[0].contentwindow.iframenumber = that.numbers; loadingwait.remove(); }); } }else{ if ( $.browser.msie){ if( $.browser.version == 7 || $.browser.version == 6){ var iew = evpopup.find(".evpopupbodyc").outerwidth(); evpopup.css({"width":(iew+10)+"px"}); } } } if(j.type == 6){ if(j.area.w == 'auto' && j.area.h == 'auto'){ var img = evpopupbodycc.find("img"); img.load(function(){ var iw = img.width(), ih = img.width(); evpopupbodycc.children("div.evloadingcon").css({"width":iw+"px","height":ih+"px"}); that.winattr(evpopup); that.popupoffset(evpopup); }) } } }; //���ֵŀ���� fun.pt.shadecountwh = function(evshade){ var that = this, j = that.j; if(j.offset.fix){ evshade.css({"position":"fixed","left":"0px","top":"0px","width":that.winw+"px","height":that.winh+"pc"}); }else{ evshade.css({"position":"absolute","left":"0px","top":"0px","width":that.winw+"px","height":that.domh+"px"}); } } fun.pt.popupoffset = function(evpopup){ var that = this, j = that.j, t = 0, l = 0; if(j.offset.fix){ evpopup.css({"position":"fixed"}); if(j.offset.t == "auto"){ t = (that.winh - that.popuph)/2; }else{ t = j.offset.t; } }else{ if(j.offset.t == "auto"){ t = that.domst + (that.winh - that.popuph)/2; }else{ t = that.domst+j.offset.t; } } if(j.offset.l!="auto"){ l = j.offset.l; }else{ l = (that.winw - that.popupw)/2; } if(t<0){t=0;} evpopup.css({"left":l+"px","top":t+"px"}); }; fun.pt.openanimate = function(o,an){//����ч�� switch (an.type){ case 0 : break; case 1 : o.css({"opacity":0}); o.animate({"opacity":an.target},300); break; case 2 : var objh = o.height(); o.css({"margin-top":-objh+"px","opacity":0}); o.animate({margintop:0,opacity:1},300); break; case 3 : var objw = o.width(); o.css({"margin-left":objw+"px","opacity":0}); o.animate({marginleft:0,opacity:1},300); break; case 4 : var objh = o.height(); o.css({"margin-top":objh+"px","opacity":0}); o.animate({margintop:0,opacity:1},300); break; case 5 : var objw = o.width(); o.css({"margin-left":-objw+"px","opacity":0}); o.animate({marginleft:0,opacity:1},300); break; } }; fun.pt.closeanimate = function(o,an){//�رն���ч�� switch (an.type){ case 0 : o.remove(); break; case 1 : o.animate({"opacity":0},300,function(){ o.remove(); }); break; case 2 : var objh = o.height(); o.animate({margintop:-objh,opacity:0},300,function(){ o.remove(); }); break; case 3 : var objw = o.width(); o.animate({marginleft:objw,opacity:0},300,function(){ o.remove(); }); break; case 4 : var objh = o.height(); o.animate({margintop:objh,opacity:0},300,function(){ o.remove(); }); break; case 5 : var objw = o.width(); o.animate({marginleft:-objw,opacity:0},300,function(){ o.remove(); }); break; } }; //�����϶��¼� fun.pt.popupmove = function(evpopup){ var that = this, j = that.j; evpopup.find(j.move.handle).on({ mousedown : function(ev){ that.winattr(evpopup); var ev = ev || window.event, objw = evpopup.width(), objh = evpopup.height(), objl = evpopup.offset().left, objt = evpopup.offset().top, zindex = evpopup.css("z-index")*1+1, startx = ev.pagex, starty = ev.pagey, clickw = startx - objl, clickh = starty - objt, movex = 0, movey = 0, endl = 0, endt = 0, movepx = 0, moveobj = $('