/*! * lhgcore dialog plugin v3.0.2 * date : 2010-04-21 09:03:11 * copyright (c) 2009 - 2010 by li hui gang */ (function(a){function e(){for(var f=a("script"),r="",c=0,d=f.length;c=0){r=document.queryselector?f[c].src:f[c].getattribute("src",4);break}return r.substr(0,r.lastindexof("/")+1)}function w(){return a.browser.ie?a.browser.i7?"":"javascript:''":"javascript:void(0);"}function a(){v||(v=999);return++v}function b(){var f=a.root(m);a(q).css({width:math.max(f.scrollwidth,f.clientwidth||0)-1+"px",height:math.max(f.scrollheight,f.clientheight||0)-1+"px"})}function x(f){f=f||window;if("pagexoffset"in f)return{x:f.pagexoffset||0,y:f.pageyoffset||0};else{f=a.root(f.document);return{x:f.scrollleft||0,y:f.scrolltop||0}}}function y(f){f=f||window;f=a.root(f.document);return{w:f.clientwidth||0,h:f.clientheight||0}}function f(){a(k).remove();k=null;if(q){a(q).remove();q=null}}for(var j=window,q,m,k,v;j.parent!=j;)j=j.parent;m=j.document;a.fn.dialog=function(f){var r=false;if(this[0])r=new a.dialog(f,this[0]);return r};a.dialog=function(f,r){var c=this.opt=a.extend({height:300,width:400,id:"lhgdlgid",event:"click",link:false,btns:true,drag:true,resize:true,title:"lhgdialog",regdragwindow:[]},f||{});if(c.settopwindow){j=c.settopwindow;m=j.document}a("#lhgdlgcss",m)[0]||a("head",m).prepend('');var d=this,z="",c,d=a.browser.ie&&!a.browser.i7?'':"";if(c.html&&typeof c.html==="string")z=c.html;else if(c.page)z=[''].join("");c=['
',c.title,'
',z,"
",c.btns?'
':"",'
',d,'
loading...
'].join("");k||(k=a('',m).css("opacity",0.3).appendto("body").bind("contextmenu",function(b){b.preventdefault()})[0]);this.showdialog=function(){if(!a("#"+c.id,m)[0]){c.cover&&this.showcover();var b=y(j),e=x(j),o=c.top?c.top:math.max(e.y+(b.h-c.height-20)/2,0);b=c.left?c.left:math.max(e.x+(b.w-c.width-20)/2,0);this.dlg=a(c,m).css({top:o+"px",left:b+"px",zindex:a()}).appendto(m.body)[0];this.resizecontent();this.setdialog(this.dlg);c.html&&c.cusfn&&c.cusfn();c.drag&&this.initdrag(a("#drag",this.dlg)[0]);c.resize&&this.initsize(a("#drop",this.dlg)[0]);if(c.link||c.html)a("#throbber",this.dlg).css("display","none")}};this.showcover=function(){if(!q){var b=['
',d,"
"].join("");q=a(b,m).css("opacity",0.5).appendto(m.body)[0]}a(j).bind("resize",b);b();a(q).css({display:"",zindex:a()})};this.cancel=function(){var b=a("#lhgfrm",d.dlg)[0];if(b){d.opt.link||a(b.contentwindow).unbind("load");b.src=w()}d.regwindow=[];a(d.dlg).remove();d.dlg=null;if(q)if(d.opt.parent&&d.opt.parent.opt.cover)q.style.zindex=parseint(d.opt.parent.dlg.style.zindex,10)-1;else q.style.display="none"};this.reload=function(b,e){b=b||window;d.cancel();b.location.href=e?e:b.location.href};this.resizecontent=function(b){var e=this.dlg;b=b?b:e.offsetheight;var o=a("#top",e)[0].offsetheight,p=a("#foot",e)[0].offsetheight;b=b-o-p;a("#middle,#throbber",e).css("height",b+"px");a("#context,#throbber",e).css("width",e.offsetwidth-a("#m_l",e)[0].offsetwidth*2+"px");a("#inbox",e).css("height",b-(c.btns?a("#btns",e)[0].offsetheight:0)+"px");a.browser.ie&&m.compatmode!=="css1compat"&&a("#context",e).css("top","0px");a.browser.i8&&c.page&&a("#lhgfrm",e).css("height",a("#inbox",e)[0].style.height)};this.redialogsize=function(b,e){a(this.dlg).css({width:b+"px",height:e+"px"});this.resizecontent(a.browser.ie&&!a.browser.i7?e:"")};this.setdialog=function(b){this.win=window;this.top=j;a(b).bind("contextmenu",function(e){e.preventdefault()}).bind("mousedown",d.setindex);a("#xbtn",b).hover(function(){a(this).addclass("xbtnover")},function(){a(this).removeclass("xbtnover")}).click(d.cancel);c.html&&c.html.nodetype&&a("#inbox",b).html(c.html);this.regwindow=[window];c.regdragwindow.length>0&&this.regwindow.push(c.regdragwindow);j!=window&&this.regwindow.push(j);if(c.page&&!c.link){this.inwin=a("#lhgfrm",b)[0].contentwindow;this.inwin.dg=this;this.regwindow.push(this.inwin);b=this.inwin.document;a(a.browser.ie?b:this.inwin).bind("mousedown",d.setindex);a(this.inwin).bind("load",function(){d.indoc=d.inwin.document;a("#throbber",d.dlg).css("display","none")})}};this.setindex=function(b){d.dlg.style.zindex=parseint(v,10)+1;v=parseint(d.dlg.style.zindex,10);b.stoppropagation()};this.addbtn=function(b,e,o){a("#"+b,this.dlg)[0]?a("#"+b,this.dlg).html(e).click(o):a('
'+e+"
",m).click(o).hover(function(){a(this).addclass("btnover")},function(){a(this).removeclass("btnover")}).appendto("#btns")};this.removebtn=function(b){(b=a("#"+b,this.dlg)[0])&&a(b).remove()};this.initdrag=function(b){function e(h){h={x:h.screenx,y:h.screeny};g={x:g.x+(h.x-p.x),y:g.y+(h.y-p.y)};p=h;if(c.rang){if(g.xl.w+i.x)g.x=l.w+i.x-s;if(g.y+t>l.h+i.y)g.y=l.h+i.y-t}a(k).css({left:g.x+"px",top:g.y+"px"})}function o(){for(var h=0,u=n.length;h