2011-06-01 14:54:40| 分类: javascript技术 | 标签: |字号大中小 订阅
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
*@Generator -> LiHuiGang - Email:[email protected] - QQ:463214570 Ver:1.2.2
*@Copyright (c) 2009 LiHuiGang Compostion - Blog:http://www.cnblogs.com/lhgstudio
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>lhgdialog - samples</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body{margin:0;padding:0;font:14px Verdana, Arial, sans-serif;line-height:200%;}
#content{padding-left:50px;padding-right:50px;}
#content h2{font-size:18px;color:#1E9300;padding-top:8px;margin-bottom:8px;}
#content h3{margin-top:8px;margin-bottom:8px;FONT:bold 14px 宋体,tahoma,arial,sans-serif;COLOR:#0033CC;}
#content div{margin-top:10px;margin-bottom:10px;border:#666 solid 1px;padding:10px;}
#content span{color:#f00;font-weight:bold;}
ul, ol{color:#000000;}
</style>
<script type="text/javascript" src="lhgdialog.js"></script>
<script type="text/javascript">
function open1()
{
lhgdialog.opendlg( '不带遮罩层的普通窗口', '_content/content1.html', 400, 300 );
}
function open2()
{
lhgdialog.opendlg( '带遮罩层的普通窗口', '_content/content1.html', 400, 300, true );
}
function open3()
{
lhgdialog.opendlg( '内容页为外部连接的窗口', 'http://www.google.com', 640, 480, false, true );
}
function open4()
{
lhgdialog.opendlg( '内容页为html代码的窗口', '<div style="color:red;font-size:14px;">lhgdialog弹出窗口</div>', 400, 300, false, 'hcode' );
}
function open5()
{
lhgdialog.opendlg( '带遮罩层带子窗口的窗口', '_content/content2.html', 400, 300, true );
}
function open6()
{
lhgdialog.opendlg( '被调用页面关闭的窗口', '_content/content1.html', 400, 300, false, false, 'win1' );
}
function closdlg()
{
lhgdialog.closdlg('win1');
}
function open7()
{
lhgdialog.opendlg( '在指定位置弹出窗口并随滚动条滚动', '_content/content1.html', 400, 300, false, false, '', true, { top:100, left:100 } );
}
function open8()
{
lhgdialog.opendlg( '返回值到调用页面', '_content/content3.html', 400, 300 );
}
function open9()
{
lhgdialog.opendlg( '窗口1', '_content/content4.html', 400, 300, false, false, 'dlg1' );
}
function open10()
{
lhgdialog.opendlg( '窗口2', '_content/content5.html', 400, 300, false, false, 'dlg2' );
}
function open11()
{
lhgdialog.opendlg( '创建其它按钮', '_content/content6.html', 400, 300 );
}
function open12()
{
//tool.getev()函数为取得触发事件,用这个函数可以不需要在open12()函数加任何参数。
//e为取得事件触发对象,w为取得对象宽度,h为取得对象高度。
//tool.getepos()函数为取得触发对象的相对于body的定位。
var ev = tool.getev(), e = ev.srcElement || ev.target;
var l, t, w = e.offsetWidth, h = e.offsetHeight;
var pos = tool.getepos(e);
//使窗口显示在触发对象的右边
l = pos.x + w; t = pos.y;
//使窗口显示在触发对象的下边
//l = pos.x; t = pos.y + h;
lhgdialog.opendlg( '在按钮的右边或下边弹出窗口', '_content/content1.html', 400, 300, false, false, '', false, { top : t, left : l } );
//如果你不想用到窗口在触发对象位置弹出窗口可把lhgdailog.js里的tool对象的tool.getev()和tool.getepos()2个函数删除。
}
</script>
</head>
<body>
<div id="content">
<h2>lhgdialog - samples</h2><hr />
<h3>1. 不带遮罩层的普通窗口 </h3>
<div>
<input type="button" id="a" value="不带遮罩层的普通窗口" onclick="open1()"/><br/>
<span>调用代码:lhgdialog.opendlg( '不带遮罩层的普通窗口', '_content/content1.html', 400, 300 );</span>
</div>
<h3>2. 带遮罩层的普通窗口 </h3>
<div>
<input type="button" id="b" value="带遮罩层的普通窗口" onclick="open2()"/><br/>
<span>调用代码:lhgdialog.opendlg( '带遮罩层的普通窗口', '_content/content1.html', 400, 300, true );</span>
</div>
<h3>3. 内容页为外部连接的窗口</h3>
<div>
<input type="button" id="c" value="内容页为外部连接的窗口" onclick="open3()"/><br/>
<span>调用代码:lhgdialog.opendlg( '内容页为外部连接的窗口', 'http://www.google.com', 640, 480, '', true );</span>
</div>
<h3>4. 内容页为html代码的窗口</h3>
<div>
<input type="button" id="d" value="内容页为html代码的窗口" onclick="open4()"/><br/>
<span>调用代码:lhgdialog.opendlg( '内容页为html代码的窗口', '<div style="color:red;font-size:14px;">lhgdialog弹出窗口</div>', 400, 300, '', 'hcode' );</span>
</div>
<h3>5. 带遮罩层带子窗口的窗口</h3>
<div>
<input type="button" id="e" value="带遮罩层带子窗口的窗口" onclick="open5()"/><br/>
<span>调用代码:lhgdialog.opendlg( '带遮罩层带子窗口的窗口', '_content/content2.html', 400, 300, true );</span><br/>
<span>子窗口的调用代码(写在content2.html里):D.lhgdialog.opendlg( '我是子窗口', '', 400, 300, true );</span>
</div>
<h3>6. 在调用页面按钮关闭弹出窗口</h3>
<div>
<input type="button" id="f" value="被调用页面关闭的窗口" onclick="open6()"/><input type="button" value="关闭弹出窗口" onclick="closdlg();"/><br/>
<span>调用代码:lhgdialog.opendlg( '被调用页面关闭的窗口', '_content/content1.html', 400, 300, false, false, 'win1' );</span><br/>
<span>关闭窗口按钮代码:lhgdialog.closdlg('win1');</span>
</div>
<h3>7. 在指定位置弹出窗口并随滚动条滚动</h3>
<div>
<input type="button" id="g" value="在指定位置弹出窗口并随滚动条滚动" onclick="open7()"/><br/>
<span>调用代码:lhgdialog.opendlg( '窗口在右下角弹出并随滚动条滚动', '_content/content1.html', 400, 300, false, false, '', true, { top:100, left:100 } );</span><br/>
<span>注:可指定为右下角和右上角,最后一个参数为1时为右上角,为2时为右下角。</span>
</div>
<h3>8. 返回值到调用页面</h3>
<div>
<input type="button" id="h" value="返回值到调用页面" onclick="open8()"/><input type="text" id="getval" value="窗口的值返回到这里"/><br/>
<span>调用代码:lhgdialog.opendlg( '返回值到调用页面', '_content/content3.html', 400, 300 );</span><br/>
<span>注:返回值的代码都在conent3.html里,你可打开这个文件查看</span>
</div>
<h3>9. 多窗口之间的传值</h3>
<div>
<input type="button" id="i" value="窗口1" onclick="open9()"/><input type="button" id="j" value="窗口2" onclick="open10();"/><br/>
<span>调用代码:窗口1:lhgdialog.opendlg( '窗口1', '_content/content4.html', 400, 300, false, false, 'dlg1');</span><br/>
<span>窗口2:lhgdialog.opendlg( '窗口2', '_content/content5.html', 400, 300, false, false, 'dlg2' );</span><br/>
<span>注:传值操作的代码都在content4.html和content5.html里,可打开查看。</span>
</div>
<h3>10. 创建其它按钮</h3>
<div>
<input type="button" id="h" value="创建其它按钮" onclick="open11()"/><br/>
<span>调用代码:lhgdialog.opendlg( '创建其它按钮', '_content/content6.html', 400, 300 );</span><br/>
<span>注:创建其它按钮的方法都在content6.html里,可打开查看。</span>
</div>
<h3>11. 在按钮的右边或下边弹出窗口</h3>
<div>
<input type="button" id="h" value="在按钮的右边或下边弹出窗口" onclick="open12()"/><br/>
<span>调用代码:lhgdialog.opendlg( '在按钮的右边或下边弹出窗口', '_content/content1.html', 400, 300, false, false, '', false, { top : t, left : l } );</span><br/>
<span>注:详细的方法请看open12函数</span>
</div>
</div>
</body>
</html>
//==========================================================================css文件==============
/*
*@Generator -> LiHuiGang - Email:[email protected] - QQ:463214570 Ver:1.2.2
*@Copyright (c) 2009 LiHuiGang Compostion Blog:http://www.cnblogs.com/lhgstudio/
*/
body
{
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #fff;
font: 11px Verdana, Arial, sans-serif;
}
.contain
{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
border: 1px solid #0fa0db;
}
.dlgtit
{
height: 26px;
margin: 1px;
cursor: move;
background-image: url(images/d_bg.gif);
background-repeat: repeat-x;
background-position: 0 0;
border: 1px solid #4297d7;
}
.dlgtit #txt
{
position: relative;
left: 15px;
top: 4px;
color: #fff;
font: 14px Tahoma, Arial, sans-serif;
font-weight: bold;
}
.dlgtit>#txt{ +top: 6px; }
#xbtn
{
position: absolute;
top: 5px;
right: 15px;
width: 21px;
height: 20px;
cursor: default;
background-image: url(images/btn_bg.gif);
background-repeat: no-repeat;
background-position: -22px 0;
}
.dlginner{ padding: 2px; }
.dlgfoot
{
position: absolute;
height: 29px;
_width: 100%;
right: 0;
bottom: 0;
left: 0;
background-image: url(images/d_bg.gif);
background-repeat: repeat-x;
background-position: 0 -26px;
}
.dlgfoot ul
{
list-style: none;
margin-top: 5px;
margin-right: 10px !important;
margin-right: 0;
}
.dlgfoot ul li
{
width: 60px;
height: 21px;
float: right;
cursor: default;
margin-right: 10px;
text-align: center;
background-image: url(images/btn_bg.gif);
background-repeat: no-repeat;
background-position: 0 -21px;
}
.dlgfoot ul li span
{
position: relative;
top: 3px;
_top: 5px;
font: 12px Verdana, Arial, sans-serif;
}
.dlgfoot>ul li span{ +top: 5px; }
#dark
{
position: absolute;
right: 2px;
bottom: 2px;
_bottom: 1px;
font-size: 0;
margin-right: 0;
height: 7px;
width: 7px;
cursor: nw-resize;
background-image: url(images/btn_bg.gif);
background-repeat: no-repeat;
background-position: -45px -13px;
}
#throbber
{
width: 180px;
height: 25px;
top: 50%;
left: 50%;
margin-left: -90px;
margin-top: -12px;
z-index: 2;
text-align: right;
font: 12px Verdana, Arial, sans-serif;
background-image: url(images/wait.gif);
background-repeat: no-repeat;
}
//========================================================css lhgdialog.css==============================
//===============================中间层页面lhgdialog.html===================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
*@Generator -> LiHuiGang - Email:[email protected] - QQ:463214570 Ver:1.2.2
*@Copyright (c) 2009 LiHuiGang Compostion Blog:http://www.cnblogs.com/lhgstudio/
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var W = frameElement._dlgargs.win, dlgcover = W.lhgdialog.gcover();
function A(){ return frameElement._dlgargs; }
window.focus(); W.tool.regdoll(window);
document.write( W.tool.getlink('lhgdialog.css') );
if(W.binfo.ie)
{
try{ document.execCommand('BackgroundImageCache', false, true); }catch(e){}
}
var recontze = function()
{
if( W.binfo.ie && !W.binfo.i7 )
{
$('contain').style.height = document.body.offsetHeight - 2;
$('contain').style.width = document.body.offsetWidth - 2;
}
var h = $('contain').offsetHeight; h -= $('dtit').offsetHeight;
h -= $('dfoot').offsetHeight; $('dinner').style.height = Math.max( h - 9, 0 ) + 'px';
};
var crtel = function( t, l, w, h )
{
var o = A().topw.document.createElement('div');
W.tool.ststyle(o,
{
'position' : 'absolute', 'top' : t + 'px', 'left' : l + 'px', border : '1px solid #000',
'width' : w + 'px', 'height' : h + 'px', 'zIndex' : W.config.bzi + 1, 'backgroundColor' : '#666'
});
W.tool.stopac( o, 0.30 ); A().topw.document.body.appendChild(o); return o;
};
var drag = function()
{
var regwin = [], lacoor, curpos, tdark;
var cluphdl = function()
{
for( var i = 0; i < regwin.length; i++ )
{
W.tool.remevt( regwin[i].document, 'mousemove', dragmovehdl );
W.tool.remevt( regwin[i].document, 'mouseup', draguphdl );
}
};
var dragmovehdl = function(evt)
{
if(!lacoor) return;
if(!evt) evt = W.tool.getedoc(this).parentWindow.event;
var curcoor = { x : evt.screenX, y : evt.screenY };
curpos =
{
x : curpos.x + ( curcoor.x - lacoor.x ),
y : curpos.y + ( curcoor.y - lacoor.y )
};
lacoor = curcoor;
tdark.style.left = curpos.x + 'px'; tdark.style.top = curpos.y + 'px';
};
var draguphdl = function(evt)
{
if(!lacoor) return;
if(!evt) evt = W.tool.getedoc(this).parentWindow.event; cluphdl();
W.tool.remnode(tdark); lacoor = null; tdark = null;
W.tool.ststyle( frameElement, { top : curpos.y + 'px', left : curpos.x + 'px' } );
if(A().sc){ var tp = W.tool.getspos(A().topw); W.config.it = curpos.y - tp.Y; W.config.il = curpos.x - tp.X; };
};
return {
downhdl : function(evt)
{
var view = null;
if(!evt){ view = W.tool.getedoc(this).parentWindow; evt = view.event; } else view = evt.view;
var tget = evt.srcElement || evt.target; if( tget.id == 'xbtn' ) return;
var fw = frameElement.offsetWidth, fh = frameElement.offsetHeight;
curpos = { x : frameElement.offsetLeft, y : frameElement.offsetTop };
lacoor = { x : evt.screenX, y : evt.screenY }; tdark = crtel( curpos.y, curpos.x, fw, fh );
for( var i = 0; i < regwin.length; i++ )
{
W.tool.addevt( regwin[i].document, 'mousemove', dragmovehdl );
W.tool.addevt( regwin[i].document, 'mouseup', draguphdl );
}
if(evt.preventDefault) evt.preventDefault(); else evt.returnValue = false;
},
reghdl : function(w){ regwin.push(w); }
};
}();
var resize = function()
{
var regwin = [], lacoor, curpos, tdark, frsize;
var movehdl = function(evt)
{
if(!lacoor) return;
if(!evt) evt = W.tool.getedoc(this).parentWindow.event;
var curcoor = { x : evt.screenX, y : evt.screenY };
frsize = { w : curcoor.x - lacoor.x, h : curcoor.y - lacoor.y };
if( frsize.w < 200 || frsize.h < 100 ){ frsize.w = 200; frsize.h = 100 };
W.tool.ststyle( tdark, { width : frsize.w + 'px', height: frsize.h + 'px', top : curpos.y + 'px', left : curpos.x + 'px' } );
};
var uphdl = function(evt)
{
if(!lacoor) return;
if(!evt) evt = W.tool.getedoc(this).parentWindow.event;
for( var i = 0; i < regwin.length; i++ )
{
W.tool.remevt( regwin[i].document, 'mousemove', movehdl );
W.tool.remevt( regwin[i].document, 'mouseup', uphdl );
}
W.tool.ststyle( frameElement, { width : frsize.w + 'px', height : frsize.h + 'px' } );
recontze(); W.tool.remnode(tdark); lacoor = null; tdark = null;
if( W.binfo.ie && !W.binfo.i7 && $('frmain') ) $('frmain').height = $('dinner').style.height;
};
return {
downhdl : function(evt)
{
var view = null;
if(!evt){ view = W.tool.getedoc(this).parentWindow; evt = view.event; } else view = evt.view;
var fw = frameElement.offsetWidth, fh = frameElement.offsetHeight;
curpos = { x : frameElement.offsetLeft, y : frameElement.offsetTop }; frsize = { w : fw, h : fh };
lacoor = { x : evt.screenX - fw, y : evt.screenY - fh }; tdark = crtel( curpos.y, curpos.x, fw, fh );
for( var i = 0; i < regwin.length; i++ )
{
W.tool.addevt( regwin[i].document, 'mousemove', movehdl );
W.tool.addevt( regwin[i].document, 'mouseup', uphdl );
}
if(evt.preventDefault) evt.preventDefault(); else evt.returnValue = false;
},
reghdl : function(w){ regwin.push(w); }
};
}();
(function()
{
window.onload = function()
{
recontze(); loadbtnevt(); $('throbber').style.visibility = ''; loadinnfrm();
if(W.binfo.ie) window.document.onmousedown = setop; else window.onmousedown = setop;
$('dtit').onmousedown = drag.downhdl; drag.reghdl(window); drag.reghdl(A().topw); drag.reghdl(W);
$('dark').onmousedown = resize.downhdl; resize.reghdl(window); resize.reghdl(A().topw); resize.reghdl(W);
if(A().link) $('throbber').style.visibility = 'hidden'; W.tool.disctmenu(document);
};
var setop = function(evt)
{
if(!evt) evt = event || this.parentWindow.event;
W.tool.ststyle( frameElement, {'zIndex':parseInt(W.config.bzi,10) + 1} );
W.config.bzi = frameElement.style.zIndex; evt.cancelBubble = true;
};
var loadinnfrm = function()
{
if( A().link == 'hcode' ){ $('dinner').innerHTML = A().page; }
else
{
var sy = A().link ? '' : 'style="visibility:hidden;" ';
$('dinner').innerHTML = '<iframe id="frmain" src="' + A().page + '" name="frmain" frameborder="0" ' +
'width="100%" height="100%" scrolling="auto" ' + sy + 'allowtransparency="true"><\/iframe>';
}
};
window.loadinndlg = function()
{
if( !frameElement.parentNode ) return null;
var frmain = $('frmain'), innwin = frmain.contentWindow, inndoc = innwin.document;
$('throbber').style.visibility = 'hidden'; frmain.style.visibility = '';
if(W.binfo.ie) inndoc.onmousedown = setop; else innwin.onmousedown = setop;
drag.reghdl(innwin); resize.reghdl(innwin); innwin.focus(); return W;
};
window.cancel = function(){ return closedlg(); };
window.closedlg = function()
{
if( $('frmain') ) $('frmain').src = W.tool.getvoid();
$('throbber').style.visibility = 'hidden'; W.lhgdialog.closdlg( window, dlgcover );
};
var loadbtnevt = function()
{
if(W.binfo.ie){ var img = new Image(); img.src="images/btn_bg.gif"; }; crebtn( 'cbtn', '取 消', cancel );
$('txt').innerHTML = A().tit; $('xbtn').onmouseover = function(){ this.style.backgroundPosition = '0 0'; };
$('xbtn').onmouseout = function(){ this.style.backgroundPosition = '-22px 0'; }; $('xbtn').onclick = cancel;
};
window.crebtn = function( i, t, f )
{
if($(i)){ $(i).innerHTML = '<span>' + t + '</span>'; $(i).onclick = f; }
else
{
var li = document.createElement('li'), span = document.createElement('span');
li.id = i; span.innerHTML = t; li.appendChild(span);
li.onmouseover = function(){ this.style.backgroundPosition = '0 -42px'; };
li.onmouseout = function(){ this.style.backgroundPosition = '0 -21px'; };
li.onclick = f; $('btns').appendChild(li); li = span = null;
}
};
window.rembtn = function(id){ if($(id)) $('btns').removeChild($(id)); };
})();
</script>
</head>
<body>
<div id="contain" class="contain">
<div id="dtit" class="dlgtit"><span id="txt"></span><div id="xbtn"></div></div>
<div id="dinner" class="dlginner"></div>
<div id="dfoot" class="dlgfoot"><ul id="btns"><li id="dark"></li></ul></div>
</div>
<div id="throbber" style="position:absolute;visibility:hidden;">正在加载窗口内容,请稍等....</div>
</body>
</html>
//=========================================================================================
//===============================================js lhgdialog.js==========================================
/*
*@Generator -> LiHuiGang - Email:[email protected] - QQ:463214570 Ver:1.2.2
*@Copyright (c) 2009 LiHuiGang Compostion Blog:http://www.cnblogs.com/lhgstudio/
*/
var binfo = (function()
{
var ua = navigator.userAgent.toLowerCase();
return {
ie : /*@cc_on!@*/false,
i7 : /*@cc_on!@*/false && (parseInt(ua.match(/msie (\d+)/)[1],10) >= 7)
};
})();
var config = { opac : 0.50, bgcolor : '#fff', bzi : null, it : null, il : null };
var tool =
{
restyle : function(e)
{
e.style.cssText = 'margin:0;padding:0;background-image:none;background-color:transparent;border:0;';
},
ststyle : function( e, dict )
{
var style = e.style;
for( var n in dict ) style[n] = dict[n];
},
getestyle : function( e, p )
{
if( binfo.ie )
return e.currentStyle[p];
else
return e.ownerDocument.defaultView.getComputedStyle(e, '').getPropertyValue(p);
},
stopac : function( e, opac )
{
if( binfo.ie )
{
opac = Math.round( opac * 100 );
e.style.filter = ( opac > 100 ? '' : 'alpha(opacity=' + opac + ')' );
}
else
e.style.opacity = opac;
},
getvoid : function()
{
if( binfo.ie )
return ( binfo.i7 ? '' : 'javascript:\'\'' );
return 'javascript:void(0)';
},
addevt : function( o, e, l )
{
if( binfo.ie )
o.attachEvent( 'on' + e, l );
else
o.addEventListener( e, l, false );
},
remevt : function( o, e, l )
{
if( binfo.ie )
o.detachEvent( 'on' + e, l );
else
o.removeEventListener( e, l, false );
},
isdtd : function(doc)
{
return ( 'CSS1Compat' == ( doc.compatMode || 'CSS1Compat' ) );
},
getclsize : function(w)
{
if( binfo.ie )
{
var oSize, doc = w.document.documentElement;
oSize = ( doc && doc.clientWidth ) ? doc : w.document.body;
if(oSize)
return { w : oSize.clientWidth, h : oSize.clientHeight };
else
return { w : 0, h : 0 };
}
else
return { w : w.innerWidth, h : w.innerHeight };
},
getev : function()
{
if(binfo.ie) return window.event;
var func = tool.getev.caller;
while( func != null )
{
var arg = func.arguments[0];
if( arg && (arg + '').indexOf('Event') >= 0 ) return arg;
func = func.caller;
}
return null;
},
getepos : function(o)
{
var l, t;
if( o.getBoundingClientRect )
{
var el = o.getBoundingClientRect(); l = el.left; t = el.top;
}
else
{
l = o.offsetLeft - Math.max( document.documentElement.scrollLeft, document.body.scrollLeft );
t = o.offsetTop - Math.max( document.documentElement.scrollTop, document.body.scrollTop );
}
return { x : l, y : t };
},
getspos : function(w)
{
if( binfo.ie )
{
var doc = w.document;
var oPos = { X : doc.documentElement.scrollLeft, Y : doc.documentElement.scrollTop };
if( oPos.X > 0 || oPos.Y > 0 ) return oPos;
return { X : doc.body.scrollLeft, Y : doc.body.scrollTop };
}
else
return { X : w.pageXOffset, Y : w.pageYOffset };
},
getlink : function(c)
{
if( c.length == 0 ) return;
return '<' + 'link href="' + c + '" type="text/css" rel="stylesheet"/>';
},
regdoll : function(w)
{
if( binfo.ie )
w.$ = w.document.getElementById;
else
w.$ = function(id){ return w.document.getElementById(id); };
},
getedoc : function(e)
{
return e.ownerDocument || e.document;
},
disctmenu : function(doc)
{
doc.oncontextmenu = function(e)
{
e = e || event || this.parentWindow.event;
var o = e.srcElement || e.target;
if( !( o.type == 'password' || o.type == 'text' || o.type == 'textarea' ) )
{
if( binfo.ie ) e.returnValue = false; else e.preventDefault();
}
};
},
getpath : function()
{
var bp, len, sc = document.getElementsByTagName('script');
for( var i = 0; i < sc.length; i++ )
{
bp = sc[i].src.substring( 0, sc[i].src.toLowerCase().indexOf('lhgdialog.js') );
len = bp.lastIndexOf('/'); if(len>0) bp = bp.substring( 0, len + 1 ); if(bp) break;
}
if( binfo.ie && bp.indexOf('../') != -1 )
{
var fp = window.location.href;
fp = fp.substring( 0, fp.lastIndexOf('/') );
while( bp.indexOf('../') >= 0 )
{
bp = bp.substring(3);
fp = fp.substring( 0, fp.lastIndexOf('/') );
} return fp + '/' + bp;
}else return bp;
},
remnode : function(n){ return n.parentNode.removeChild(n); }
};
var lhgdialog = (function()
{
var twin = window.parent, cover;
while( twin.parent && twin.parent != twin )
{
try{ if( twin.parent.document.domain != document.domain ) break; } catch(e){break;}
twin = twin.parent;
}
var tdoc = twin.document;
var getzi = function()
{
if(!config.bzi) config.bzi = 999; return ++config.bzi;
};
var resizehdl = function()
{
if(!cover) return;
var rel = tool.isdtd(tdoc) ? tdoc.documentElement : tdoc.body;
tool.ststyle(cover,
{
'width' : Math.max( rel.scrollWidth, rel.clientWidth, tdoc.scrollWidth || 0 ) - 1 + 'px',
'height' : Math.max( rel.scrollHeight, rel.clientHeight, tdoc.scrollHeight || 0 ) - 1 + 'px'
});
};
return {
opendlg : function( t, p, w, h, c, i, n, s, l )
{
if(c) this.dcover(); else{ if(cover) cover = null; }
var dinfo = { tit : t, page : p, win : window, topw : twin, link : i, sc : s };
var clsize = tool.getclsize(twin), spos = tool.getspos(twin);
var schdl = function()
{
var rel = tool.getspos(twin);
tool.ststyle( dfrm, { 'top' : rel.Y + config.it + 'px', 'left' : rel.X + config.il + 'px' } );
};
var it = ( l && l.top ) ? spos.Y + l.top : Math.max( spos.Y + ( clsize.h - h - 20 ) / 2, 0 );
var il = ( l && l.left ) ? spos.X + l.left : Math.max( spos.X + ( clsize.w - w - 20 ) / 2, 0 );
var dfrm = tdoc.createElement('iframe'); tool.restyle(dfrm); if(n) dfrm.id = n;
dfrm.frameBorder = 0; dfrm.src = tool.getpath() + 'lhgdialog.html';
tool.ststyle(dfrm,
{
'position' : 'absolute', 'top' : it + 'px', 'left' : il + 'px',
'width' : w + 'px', 'height' : h + 'px', 'zIndex' : getzi()
}); if(s){ config.it = it - spos.Y; config.il = il - spos.X; };
if(s) tool.addevt( twin, 'scroll', schdl ); tdoc.body.appendChild(dfrm); dfrm._dlgargs = dinfo;
},
closdlg : function( d, c )
{
var dlg = ( 'object' == typeof(d) ) ? d.frameElement : document.getElementById(d);
if(dlg) tool.remnode(dlg); if(c) this.hcover(c);
},
dcover : function()
{
cover = tdoc.createElement('div'); tool.restyle(cover);
tool.ststyle(cover,
{
'position' : 'absolute', 'zIndex' : getzi(), 'top' : '0px',
'left' : '0px', 'backgroundColor' : config.bgcolor
});
tool.stopac( cover, config.opac );
if( binfo.ie && !binfo.i7 )
{
var ifrm = tdoc.createElement('iframe');
tool.restyle(ifrm); ifrm.hideFocus = true;
ifrm.frameBorder = 0; ifrm.src = tool.getvoid();
tool.ststyle(ifrm,
{
'width' : '100%', 'height' : '100%', 'position' : 'absolute', 'left' : '0px',
'top' : '0px', 'filter' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'
});
cover.appendChild(ifrm);
}
tool.addevt( twin, 'resize', resizehdl ); resizehdl(); tdoc.body.appendChild(cover);
},
gcover : function(){ return cover; },
hcover : function(o){ tool.remnode(o); cover = null; o = null; }
};
})();