?? popupmenu-script.js
字號(hào):
aHtml.push ( "<td align=center unselectable='on' width=30 nowrap> " );
if( aItemData.icon ) {
aHtml.push ( "<img border=0 src=\"" + aItemData.icon + "\">" );
} else {
aHtml.push ( " " );
}
aHtml.push ( "</td>" );
//文本列
aHtml.push ( "<td nowrap unselectable='on'>" );
aHtml.push ( aItemData.text );
aHtml.push ( "</td>" );
//右邊(如果有子菜單應(yīng)顯示箭頭)
aHtml.push ( "<td nowrap width=10 unselectable='on'>" );
if( blnHasChildren ) {
aHtml.push ( "<font style='font-family:Webdings;font-size:7pt;height:10;padding-right:5px;padding-left:3px;'>4</font>" );
} else {
aHtml.push ( " " );
}
aHtml.push ( "</td>" );
aHtml.push ( "</tr>" );
return aHtml.join("");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// ------------------------------ end 將菜單數(shù)據(jù)轉(zhuǎn)換為html代碼的函數(shù) -------------------------------------//
// ------------------------------------- 顯示子菜單的處理 ---------------------------------------//
//////////////////////////////////////////////////////////////////////////////////////////////////
//顯示主菜單下的一級(jí)子菜單
function showItemsOfMain ( id ) {
var hasSub = hasChildren( id );
//判斷事件
var eventType = window.event.type.toLowerCase();
if( eventType == "mouseover" && !getPopup(0).isOpen ) {
return;
}
if( eventType == "click" ) {
execute( id );
}
//alert("OK");
///////////////////////////////////////////////////
//如果沒(méi)有子菜單,則隱藏第一級(jí)popup窗口即可,因?yàn)槠渌哟翱跁?huì)一并隱藏
if( !hasSub ) {
//getPopup(0).hide();
return;
}
var objMain = document.getElementById( id );
var pop = getPopup(0);
pop.document.body.innerHTML = getSubItemsHtml(id);
//設(shè)置id屬性,以便辨別打開(kāi)的窗口屬于該菜單項(xiàng)
pop.document.body.setAttribute("id", id);
pop.show(0,0,1,1,objMain);
var intWidth = pop.document.body.scrollWidth;
var intHeight = pop.document.body.scrollHeight;
pop.hide();
pop.show(10,objMain.offsetHeight-2,intWidth,intHeight,objMain);
}
//顯示菜單項(xiàng)下屬的子菜單
//@param objItem 菜單項(xiàng)對(duì)象
//@param id 菜單項(xiàng)id(添加數(shù)據(jù)時(shí)的id)
function showItems( objItem, id ) {
//如果沒(méi)有子菜單,則隱藏窗口打開(kāi)的子窗口
if( !hasChildren(id) ) {
hideAllParentPopup( id );
return;
}
//得到顯示的Popup窗口
var degree = getMenuDegree(id);
var pop = getPopup( degree );
pop.document.body.innerHTML = getSubItemsHtml(id);
//設(shè)置id屬性,以便辨別打開(kāi)的窗口屬于該菜單項(xiàng)
pop.document.body.setAttribute("id", id);
pop.show(0,0,1,1,objItem);
var intWidth = pop.document.body.scrollWidth;
var intHeight = pop.document.body.scrollHeight;
var intLeft = objItem.offsetWidth - 2;
/*
var screenWidth = screen.width;
document.all.txtWidth.value = (intLeft + intWidth + 5) + " left=" + objItem.scrollLeft;
if( (intLeft + intWidth + 5) > screenWidth ) {
intLeft = intLeft - 2 * intWidth;
}*/
pop.hide();
pop.show(intLeft, -2, intWidth,intHeight, objItem);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// ------------------------------------- end 顯示子菜單的處理 ---------------------------------------//
//判斷一個(gè)菜單項(xiàng)下屬的子菜單是否打開(kāi)
function isSubItemsOpen( id ) {
if( !hasChildren( id ) ) {
return false;
}
var degree = getMenuDegree(id);
if( !aPopupWindows[degree] || !aPopupWindows[degree].isOpen ) {
return false;
}
if( aPopupWindows[degree].document.body.getAttribute("id") != id ) {
return false;
}
return true;
}
var prevMainMenuItemObj = null;
// --------------- 重置菜單得時(shí)間器處理 ------------------//
//這種方式對(duì)于子菜單不適應(yīng)
var menuPopTimer = null;
function menuPopOut() {
//clearMenuPopTimer();
menuPopTimer = window.setTimeout("resetMenu()",700);
}
function clearMenuPopTimer() {
if( menuPopTimer != null ) {
window.clearTimeout(menuPopTimer);
}
}
////////////////////////////////////////////////////////////
document.onclick = clickEvent
top.document.onclick = clickEvent
// ------------------------------ 改變菜單樣式得相關(guān)處理 -----------------------------------//
/////////////////////////////////////////////////////////////////////////////////////////////
//將菜單置為初始狀態(tài)
function resetMenu() {
//clickEvent()
if( prevMainMenuItemObj != null ) {
chgMainMenuStyle(prevMainMenuItemObj, false);
prevMainMenuItemObj = null;
}
getPopup(0).hide();
}
//鼠標(biāo)單擊時(shí)響應(yīng)的事件
function clickEvent() {
if( prevMainMenuItemObj != null && !getPopup(0).isOpen ) {
chgMainMenuStyle(prevMainMenuItemObj, false);
prevMainMenuItemObj = null;
}
}
//鼠標(biāo)移上主菜單時(shí)樣式的改變
function mainMenuOverStyle(id, obj) {
//clearMenuPopTimer();//清除重置菜單得時(shí)間器
chgMainMenuStyle(obj, true);
mapIdVSItemInfos[id].obj = obj;
if( prevMainMenuItemObj == obj ) {
return;
}
if( prevMainMenuItemObj != null ) {
chgMainMenuStyle(prevMainMenuItemObj, false);
}
prevMainMenuItemObj = obj;
}
//鼠標(biāo)移上主菜單上樣式的改變
//@param id 菜單項(xiàng)對(duì)應(yīng)的id
//@param obj 被恢復(fù)樣式的菜單對(duì)象
function mainMenuOutStyle(id, obj) {
//menuPopOut();//打開(kāi)重置菜單得時(shí)間器
//如果有子菜單打開(kāi),則不恢復(fù)
if( isSubItemsOpen(id) ) {
return;
}
chgMainMenuStyle(obj, false);
}
//鼠標(biāo)移上子菜單項(xiàng)上時(shí)樣式的改變
//除了改變當(dāng)前菜單項(xiàng)的樣式之外,
//還要恢復(fù)同窗口中上次被改變的菜單樣式
function subMenuOverStyle(id, obj) {
//clearMenuPopTimer();//清除重置菜單得時(shí)間器
mapIdVSItemInfos[id].obj = obj;
var parentId = mapIdVSItemInfos[id].parentId;
var preObj = mapIdVSItemInfos[parentId].preObj;
chgSubMenuStyle(obj, true);
if( preObj == obj ) {
return;
}
if( preObj ) {
chgSubMenuStyle(preObj, false);
}
mapIdVSItemInfos[parentId].preObj = obj;
}
//鼠標(biāo)移開(kāi)子菜單上樣式的改變
//@param id 菜單項(xiàng)對(duì)應(yīng)的id
//@param obj 被恢復(fù)樣式的菜單對(duì)象
function subMenuOutStyle(id, obj) {
//menuPopOut();//打開(kāi)重置菜單得時(shí)間器
//如果有子菜單打開(kāi),則不恢復(fù)
if( isSubItemsOpen(id) ) {
return;
}
chgSubMenuStyle(obj, false);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// ------------------------------ end 改變菜單樣式得相關(guān)處理 -----------------------------------//
//顯示主窗口需彈出的popup窗口
function showMainPopup( pop, objMain ) {
var objLink = pop.document.getElementsByTagName("LINK")[0];
if( objLink.readyState == "complete" ) {
}
}
//判斷一個(gè)菜單項(xiàng)是否有子菜單
function hasChildren( id ) {
if( !menuItemVSSubItems[id] ) {
return false;
}
if( menuItemVSSubItems[id].length == 0 ) {
return false;
}
return true;
}
/// ------------------------------------ 執(zhí)行菜單相應(yīng)事件的操作 ------------------------------------------------//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//執(zhí)行菜單的響應(yīng)事件
function execute( id ) {
var action = mapIdVSItemInfos[id].action;
var target = mapIdVSItemInfos[id].target;
var aFromIds = getMenuFromIds(id);//進(jìn)入該菜單所經(jīng)歷的菜單項(xiàng)
//獲取位置信息
var position = "";
for( var i = aFromIds.length - 1;i >=0;i -- ) {
position += mapIdVSItemInfos[aFromIds[i]].text + " ";
}
position += mapIdVSItemInfos[id].text;
//end 獲取位置信息
//alert(position);
if( action == "" || action == "#" ) {
return;
}
resetMenu();//重置菜單
if( target.toLowerCase() == "js" || target.toLowerCase() == "javascript" ) {
eval( action );
return;
}
if( shouldAddContextPathBefore( action ) ) {
action = contextPath + action;
}
//alert( action );
window.open(action, target);
}
//判斷是否應(yīng)在某個(gè)鏈接前加上contextPath
function shouldAddContextPathBefore( action ) {
if( !contextPath || contextPath == "" ) {
return false;
}
if( action.toLowerCase().substring(0,4) == "http" ) {
return false;
}
//如果url指定的不是決定路徑,則不用加
if( action.substring(0,1) != "/" ) {
return false;
}
//如果已經(jīng)是contextptah開(kāi)頭,則不用加
var len = contextPath.length;
if( action.length > len && action.substring(0,len) == contextPath ) {
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ------------------------------------ end 執(zhí)行菜單相應(yīng)事件的操作 ------------------------------------------------//
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -