?? divdindow.js
字號:
var currentMoveObj = null; //當(dāng)前拖動對象
var relLeft; //鼠標(biāo)按下位置相對對象位置
var relTop;
//最后一個顯示的窗口ID
var lastShowDivWinID = null;
//最后一個顯示的窗口是否要徹底關(guān)閉(下次重新加載)
var lastShowDivWinIsReload = "false";
function divBoxDown(obj){
/**
先不讓拖動
currentMoveObj = obj; //當(dāng)對象被按下時,記錄該對象
currentMoveObj.style.position = "absolute";
relLeft = event.x - currentMoveObj.style.pixelLeft;
relTop = event.y - currentMoveObj.style.pixelTop;
currentMoveObj.style.filter = "Alpha(opacity=60)"; //按下時對象透明
currentMoveObj.style.opacity = "0.6"; //firfox有效
**/
}
function divBoxUp(obj){
/**
先不讓拖動
currentMoveObj = obj; //當(dāng)鼠標(biāo)被釋放時,記錄該對象
currentMoveObj.style.filter = "Alpha(opacity=100)"; //恢復(fù)
currentMoveObj = null; //當(dāng)鼠標(biāo)釋放時同時釋放拖動對象
**/
}
function divBoxMove(obj){
/**
先不讓拖動
if(currentMoveObj != null){
currentMoveObj.style.pixelLeft=event.x-relLeft;
currentMoveObj.style.pixelTop=event.y-relTop;
}
**/
}
//關(guān)閉窗口
function closeDivWindow(){
//顯示select控件
DispalySelect(1);
//隱藏遮罩
hideMask();
//隱藏窗口
hideDivWindow(lastShowDivWinID,lastShowDivWinIsReload);
}
//頁面遮罩對象
var MaskObj = null;
//顯示遮罩
function showMask(){
var Maskw,Maskh,Openw,Openh;
Maskw = document.body.offsetWidth;
Maskh = window.screen.height; //document.body.scrollHeight;
Maskh = document.body.scrollHeight;
//設(shè)置遮罩層
//只有第一次才創(chuàng)建這個遮罩層
if(null == MaskObj){
MaskObj = document.createElement("windowMask");
}
MaskObj.id = "windowMask";
MaskObj.className = "div_window_mask";
MaskObj.style.width = Maskw + "px";
MaskObj.style.height = Maskh + "px";
document.body.appendChild(MaskObj);
}
//隱藏遮罩
function hideMask(){
var maskObj = document.getElementById("windowMask");
if(null != maskObj){
maskObj.style.width = "0px";
maskObj.style.height = "0px";
}
}
//隱藏窗口
function hideDivWindow(winID,isReload){
var winObj = document.getElementById(winID);
if(null != winObj){
//如果是需要下載重新加載,則在關(guān)閉窗口時,徹底刪除窗口對象
if(isReload == "true"){
winObj.removeNode(true); //移除窗口,以及所有子節(jié)點(diǎn)
}else{
winObj.style.display = "none";
}
}
}
//顯示窗口,使用AJAX方法動態(tài)讀取某URL中的輸出內(nèi)容做為窗口的內(nèi)容
function showDivWindowForURL(winID,width,height,isReload,title,url){
lastShowDivWinID = winID;
lastShowDivWinIsReload = isReload;
var contentObj = showDivWindow(winID,width,height,isReload,title,"窗口加載中..");
var ajax=new AJAXRequest;
//使用這種方法,可以直接將輸出innerhtml某對象
//ajax.get('../../getmodule?ajax=true&module=' + url,contentObj);
//由于要支持在innerHTML中,支持JS,所以用了一個 setInnerHTML 方法
ajax.get('../../getmodule?ajax=true&module=' + url,function(obj){setInnerHTML(contentObj, obj.responseText);});
}
/**
* 顯示窗口
**/
function showDivWindow(winID,width,height,isReload,title,content){
//隱藏select控件
DispalySelect(0);
//顯示遮罩
showMask();
var PopObj = null;
if(!document.getElementById(winID)){ //如果沒有winID,則創(chuàng)建
PopObj = document.createElement(winID);
PopObj.id = winID;
PopObj.className = "div_window_box";
PopObj.onselectstart = function(){return false;};
PopObj.style.left = (window.screen.width - width) / 2 + "px";
PopObj.style.top = (-160 + window.screen.height - height) / 2 +"px";
PopObj.style.width = width+10 + "px";
PopObj.style.height = height+20 + "px";
document.body.appendChild(PopObj);
//開始
var popObjHTML = "<div class='div_window_box_border' onMouseDown='divBoxDown(this.parentNode)' onMouseUp='divBoxUp(this.parentNode)' onMouseMove='divBoxMove(this.parentNode)'>";
//標(biāo)題行
popObjHTML = popObjHTML + "<div class='div_window_box_oper_bar'><div class='div_window_box_oper_bar_title'>"+title+"</div><div class='div_window_box_oper_bar_button'><div class='div_window_box_oper_bar_button_close' onclick='closeDivWindow();'> </div></div></div>";
//內(nèi)容
popObjHTML = popObjHTML + "<div class='div_window_box_content' id='div_window_box_content'>"+content+"</div>";
//結(jié)束
popObjHTML = popObjHTML + "</div>";
PopObj.innerHTML = popObjHTML;
//設(shè)置內(nèi)容區(qū)的高度
//document.getElementById("div_window_box_content").style.height = (height) + "px";
}else{ //如果有,則直接獲得
PopObj = document.getElementById(winID);
//關(guān)閉時,設(shè)置為了隱藏,這時,又要顯示,所以再設(shè)置為顯示
PopObj.style.display="block";
}
//返回內(nèi)容容器對象
return document.getElementById("div_window_box_content");
}
//顯示和隱藏select控件
function DispalySelect(val){
var dispalyType;
var arrdispalyType=["hidden","visible"];
var arrObjSelect=document.getElementsByTagName("select");
for (i=0;i<arrObjSelect.length;i++){
arrObjSelect[i].style.visibility=arrdispalyType[val];
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -