📄 utillayer.js
字号:
var _lCurtain=null;
var _lDiv=null;
var _lInnerDiv=null;
var _lTitleDiv=null;
var _divContainer=null;
var _curDiv=null;
var _lArguments=null;
var _lHideCallback=null;
var _lHideCallbackPersistent=false;
var _lShow=false;
var _divs=[];
function lGo(subDivId, argument) {
if (!_divContainer)
_divContainer=document.getElementById('layerContainer');
if (!_divContainer) return;
if (!_lCurtain) {
_lCurtain=document.createElement('DIV');
_lCurtain.style.top=0;
_lCurtain.style.left=0;
_lCurtain.style.width='100%';
_lCurtain.style.height='100%';
_lCurtain.style.position='absolute';
_lCurtain.style.zIndex=3000;
_lCurtain.style.visibility='hidden';
_lCurtain.style.backgroundColor='white';
document.body.appendChild(_lCurtain);
}
if (!_lDiv) {
_lDiv=document.createElement('DIV');
with (_lDiv.style) {
position='absolute';
zIndex=3100;
width='600px';
height='450px';
visibility='hidden';
}
document.body.appendChild(_lDiv);
var table=appendNew(_lDiv, 'TABLE');
table.cellPadding=0;
with (table.style) {
borderCollapse='collapse';
width='600px';
height='450px';
}
var row=table.insertRow(0);
_lTitleDiv=row.insertCell(0);
_lTitleDiv.colSpan=3;
with (_lTitleDiv.style) {
verticalAlign='top';
height='65px';
fontSize='18pt';
fontWeight='bold';
padding='25px 0px 0px 65px';
color='#444';
}
if (_isIE) _lTitleDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/layer_top.png')";
else{
_lTitleDiv.style.backgroundImage='url(img/layer_top.png)';
_lTitleDiv.style.backgroundRepeat='no-repeat';
}
row=table.insertRow(1);
var cell=row.insertCell(0);
with (cell.style) {
width='20px';
height='355px';
}
if (_isIE) cell.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/layer_left.png')";
else cell.style.backgroundImage='url(img/layer_left.png)';
_lInnerDiv=row.insertCell(1);
with (_lInnerDiv.style) {
verticalAlign='top';
width='560px';
height='355px';
overflow='auto';
backgroundColor='white';
}
var cell=row.insertCell(2);
with (cell.style) {
height='355px';
width='20px';
}
if (_isIE) cell.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/layer_right.png')";
else cell.style.backgroundImage='url(img/layer_right.png)';
row=table.insertRow(2);
cell=row.insertCell(0);
cell.colSpan=3;
with (cell.style) {
width='600px';
height='30px';
}
if (_isIE) cell.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/layer_bottom.png')";
else{
cell.style.backgroundImage='url(img/layer_bottom.png)';
cell.style.backgroundRepeat='no-repeat';
}
}
if (_curDiv) {
_divContainer.appendChild(_curDiv);
_curDiv=null;
}
_lTitleDiv.innerHTML='';
if (subDivId) {
_curDiv=oFindChild(_divContainer, 'DIV', subDivId);
if (_curDiv) {
_lInnerDiv.appendChild(_curDiv);
if (_curDiv.title)
_lTitleDiv.innerHTML=_curDiv.title;
}
}
_lDiv.style.display='';
_lCurtain.style.display='';
_lDiv.style.visibility='visible';
lResize();
if (_isIE) _lCurtain.style.filter='alpha(opacity=70)';
else _lCurtain.style.opacity=0.7;
_lCurtain.style.visibility='visible';
if (argument) _lArguments=argument;
_lShow=true;
return _curDiv;
}
function lResize() {
_lCurtain.style.display='none';
lCenter();
_lCurtain.style.width=Math.max(document.body.scrollWidth,document.body.clientWidth);
_lCurtain.style.height=Math.max(document.body.scrollHeight,document.body.clientHeight);
_lCurtain.style.display='';
}
function lCenter(div) {
if (!div) div=_lDiv;
if (div) {
div.style.display='none';
div.style.top=0;
div.style.left=0;
var y=document.body.clientHeight;
var x=document.body.clientWidth;
div.style.visibility='hidden';
div.style.display='';
div.style.top=Math.max(0,document.body.scrollTop+((y-div.childNodes[0].offsetHeight)/2));
div.style.left=Math.max(0,document.body.scrollLeft+((x-div.childNodes[0].offsetWidth)/2));
div.style.visibility='visible';
}
//lShowControl(div);
//lHideControl('SELECT',div);
}
function lHideCallback(callback, persistent) {
_lHideCallback=callback;
_lHideCallbackPersistent=persistent;
}
function lSetMaxSize() {
lSetMaxWidth();
lSetMaxHeight();
}
function lSetMaxWidth() {
lSetWidth(parseInt(parent.document.body.clientWidth)-10);
}
function lSetMaxHeight() {
lSetHeight(parseInt(parent.document.body.clientHeight)-10);
}
function lSetSize(width, height) {
lSetWidth(width);
lSetHeight(height);
}
function lSetWidth(width) {
if (!parent || !parent._lDiv) return;
if (width) parent._lDiv.style.width=width;
parent.lResize();
}
function lSetHeight(height) {
if (!parent || !parent._lDiv) return;
if (height) parent._lDiv.style.height=height;
parent.lResize();
}
function lGetWin() {
if (!_lDiv) return;
var ifm=oFindChildByTagName(_lDiv, 'IFRAME');
return ifm.contentWindow;
}
var _lResizeCallback=null;
function lResizeBlend(width, height, dialogId, callback) {
var toWidth=width;
var toHeight=height;
if (callback) _lResizeCallback=callback;
var div;
if (dialogId) div=parent._lDialog[dialogId].div;
else div=parent._lDiv;
if (!div) return;
if (document.body.style.display != 'none') document.body.style.display='none';
var speed=4;
if (div.offsetWidth != width) {
if (div.offsetWidth > width) toWidth=div.offsetWidth-(Math.abs(Math.round((div.offsetWidth-width)/speed)))-1;
else if (div.offsetWidth < width) toWidth=div.offsetWidth+(Math.abs(Math.round((div.offsetWidth-width)/speed)))+1;
}
if (div.offsetHeight != height) {
if (div.offsetHeight > height) toHeight=div.offsetHeight-(Math.abs(Math.round((div.offsetHeight-height)/speed)))-1;
else if (div.offsetHeight < height) toHeight=div.offsetHeight+(Math.abs(Math.round((div.offsetHeight-height)/speed)))+1;
}
if (toHeight != height || toWidth != width) {
var moveTop=Math.round((div.offsetHeight-toHeight)/2);
var moveLeft=Math.round((div.offsetWidth-toWidth)/2);
div.style.width=toWidth;
div.style.height=toHeight;
div.style.top=div.offsetTop+moveTop;
div.style.left=div.offsetLeft+moveLeft;
setTimeout('lResizeBlend('+width+', '+height+', "'+(dialogId?dialogId:'')+'");', 0);
}else{
document.body.style.display='';
if (_lResizeCallback) {
if (typeof _lResizeCallback == 'function')
_lResizeCallback();
else
eval(_lResizeCallback);
_lResizeCallback=null;
}
if (dialogId)
parent.lDialogCenter(dialogId);
else
parent.lCenter();
}
}
function lHide() {
if (_lDiv) {
_lDiv.style.visibility='hidden';
_lDiv.style.display='none';
_lDiv.style.top='0px';
_lDiv.style.left='0px';
}
if (_lCurtain) {
_lCurtain.style.visibility='hidden';
_lCurtain.style.display='none';
_lCurtain.style.top='0px';
_lCurtain.style.left='0px';
}
eventListnerDelete('scroll','lCenter()');
eventListnerDelete('resize','lResize()');
//lShowControl(_lDiv);
if (_lHideCallback) {
try{
_lHideCallback();
}catch(e) {}
if (!_lHideCallbackPersistent)
_lHideCallback=null;
}
_lShow=false;
}
function lHideControl(tagName, popupObj) {
if (_isIE) {
var x=lX(popupObj);
var y=lY(popupObj);
var w=popupObj.offsetWidth;
var h=popupObj.offsetHeight;
var i;
var objs=document.getElementsByTagName(tagName);
if (!tagName || !objs) return;
for (i = 0; i < objs.length; ++i) {
var obj = objs[i];
if (!obj || !obj.offsetParent) continue;
var ox = lX (obj);
var oy = lY (obj);
var ow = obj.offsetWidth;
var oh = obj.offsetHeight;
if (ox > (x + w) || (ox + ow) < x) continue;
if (oy > (y + h) || (oy + oh) < y) continue;
if(obj.style.visibility == "hidden") continue;
if(!popupObj.overFlag)
popupObj.overFlag = new Array ();
popupObj.overFlag[popupObj.overFlag.length] = obj;
obj.style.visibility = "hidden";
}
}
}
function lShowControl(popupObj) {
if (_isIE && popupObj) {
if (popupObj.overFlag) {
var i;
for (i = 0; i < popupObj.overFlag.length; ++i)
popupObj.overFlag[i].style.visibility = "visible";
}
popupObj.overFlag = null;
}
}
function lX(obj, top, absolute) {
var x = 0;
if (!obj) return 0;
if (_isIE) {
do {
if (absolute && obj && obj.style && obj.style.position == 'absolute') break;
x += obj.offsetLeft+obj.clientLeft-obj.scrollLeft;
obj = obj.offsetParent;
}
while (obj && obj != top);
}else{
do {
if (absolute && obj && obj.style && obj.style.position == 'absolute') break;
x += obj.offsetLeft-obj.scrollLeft;
obj = obj.offsetParent;
}
while (obj && obj != top);
}
if (obj == document.body || !top) x-=document.body.offsetLeft;
return x;
}
function lEndX(obj, top, absolute) {
return lX(obj, top, absolute)+obj.offsetWidth;
}
function lY(obj, top, absolute) {
var y = 0;
if (!obj) return 0;
if (_isIE) {
do {
if (absolute && obj && obj.style && obj.style.position == 'absolute') break;
y += obj.offsetTop+obj.clientTop-obj.scrollTop;
obj = obj.offsetParent;
}while (obj && obj != top);
}else{
do {
if (absolute && obj && obj.style && obj.style.position == 'absolute') break;
y += obj.offsetTop-obj.scrollTop;
obj = obj.offsetParent;
}while (obj && obj != top);
}
if (obj == document.body || !top) y-=document.body.offsetTop;
return y;
}
function lEndY(obj, top, absolute) {
return lY(obj, top, absolute)+obj.offsetHeight;
}
function lElementPosIn(element, y, x) {
if (!element) return false;
var lx=lX(element);
var ly=lY(element);
return (lx <= x && (lx+element.offsetWidth) >= x && ly <= y && (ly+element.offsetHeight) >= y);
}
/* element */
function appendNew(parent, tag, doc) {
if (!doc) doc=document;
if (!parent) return null;
var el=doc.createElement(tag);
parent.appendChild(el);
return el;
}
function appendClone(parent, original) {
if (!parent) return null;
var el=original.cloneNode(true);
parent.appendChild(el);
return el;
}
/* div control */
function divHide(e) {
if (_isIE && !e) e=window.event;
if (e) {
if (e.button == 2)
return;
}
for (var i=_divs.length; i--;) {
if (_divs[i]) _divs[i].style.display='none';
}
}
function divHideAdd(div) {
if (arraySearch(div, _divs) < 0)
_divs.push(div);
}
function divHideDel(div) {
var idx=arraySearch(div, _divs);
if (idx > -1) _divs.splice(idx, 1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -