⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fw_menu.js

📁 JSP工程应用与实践
💻 JS
📖 第 1 页 / 共 3 页
字号:
				menuLayer.Menu = container.menus[x];
				menuLayer.Menu.container = "menuLayer" + x;
				menuLayer.style.zIndex = 101;
				s = menuLayer.style;
				s.top = s.pixelTop = -300;
				s.left = s.pixelLeft = -300;
				menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
				menuLayer.style.backgroundColor = menu.menuBorderBgColor;
			}
			var top = 0;
			for (var i=0; i<container.menus[x].items.length; i++) {
				if( !menu.hasBeenWritten )
				{
					var l = FIND("menuItem" + menuCount);
					l.Menu = container.menus[x];
					if (l.addEventListener) { // ns6
						l.style.width = menu.menuItemWidth;	
						l.style.height = menu.menuItemHeight;
						l.style.top = top;
						l.addEventListener("mouseover", onMenuItemOver, false);
						l.addEventListener("click", onMenuItemAction, false);
						l.addEventListener("mouseout", mouseoutMenu, false);
					} else { //ie
						l.style.pixelWidth = menu.menuItemWidth;	
						l.style.pixelHeight = menu.menuItemHeight;
						l.style.pixelTop = top;
					}
					top = top + menu.menuItemHeight+menu.menuItemBorder;
					l.style.fontSize = menu.fontSize;
					l.style.backgroundColor = menu.menuItemBgColor;
					l.style.visibility = "inherit";
					l.saveColor = menu.menuItemBgColor;
					l.menuHiliteBgColor = menu.menuHiliteBgColor;
					l.action = container.menus[x].actions[i];
					l.hilite = FIND("menuItemHilite" + menuCount);
					l.focusItem = FIND("focusItem" + x);
					l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
					var childItem = FIND("childMenu" + menuCount);
					if (childItem) {
						l.childMenu = container.menus[x].items[i].menuLayer;
						childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth -11;
						childItem.style.pixelTop = childItem.style.top =(menu.menuItemHeight /2) -4;
						//childItem.style.pixelWidth = 30 || 7;
						//childItem.style.clip = "rect(0 7 7 3)";
						l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
					}
					var sep = FIND("menuSeparator" + menuCount);
					if (sep) {
						sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
						sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;	
						sep.style.backgroundColor = menu.bgColor;
						sep = FIND("menuSeparatorLite" + menuCount);
						sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
						sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;	
						sep.style.backgroundColor = menu.menuLiteBgColor;
						l.style.height = l.style.pixelHeight = menu.menuItemHeight/2;
						l.isSeparator = true
						top -= (menu.menuItemHeight - l.style.pixelHeight)
					} else {
						if( document.all )
						{
							l.style.cursor = "hand";
						}
						else
						{
							l.style.cursor = "pointer";
						}
					}
				}
				menuCount++;
			}
			
			if( !menu.hasBeenWritten )
			{
				menu.menuHeight = top-1;
				var lite = FIND("menuLite" + x);
				var s = lite.style;
				s.height = s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
				s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 2);
				s.backgroundColor = menu.menuLiteBgColor;
	
				var body = FIND("menuFg" + x);
				s = body.style;
				s.height = s.pixelHeight = menu.menuHeight + menu.menuBorder;
				s.width = s.pixelWidth = menu.menuItemWidth + menu.menuBorder;
				s.backgroundColor = menu.bgColor;
	
				s = menuLayer.style;
				s.width = s.pixelWidth  = menu.menuItemWidth + (menu.menuBorder * 4);
				s.height = s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
			
				menu.hasBeenWritten = true;
			}
		}
	}
	if (document.captureEvents) {	
		document.captureEvents(Event.MOUSEUP);
	}
	if (document.addEventListener) {	
		document.addEventListener("mouseup", onMenuItemOver, false);
	}
	if (document.layers && window.innerWidth) {
		window.onresize = NS4resize;
		window.NS4sIW = window.innerWidth;
		window.NS4sIH = window.innerHeight;
	}
	document.onmouseup = mouseupMenu;
	window.fwWroteMenu = true;
	status = "";
}

function NS4resize() {
	if (NS4sIW < window.innerWidth || 
		NS4sIW > window.innerWidth || 
		NS4sIH > window.innerHeight || 
		NS4sIH < window.innerHeight ) 
	{
		window.location.reload();
	}
}

function onMenuItemOver(e, l) {
	FW_clearTimeout();
	l = l || this;
	a = window.ActiveMenuItem;
	if (document.layers) {
		if (a) {
			a.document.bgColor = a.saveColor;
			if (a.hilite) a.hilite.visibility = "hidden";
			if (a.Menu.bgImageOver) {
				a.background.src = a.Menu.bgImageUp;
			}
			a.focusItem.top = -100;
			a.clicked = false;
		}
		if (l.hilite) {
			l.document.bgColor = l.menuHiliteBgColor;
			l.zIndex = 101;
			l.hilite.visibility = "inherit";
			l.hilite.zIndex = 102;
			l.document.layers[1].zIndex = 101;
			l.focusItem.zIndex = this.zIndex +2;
		}
		if (l.Menu.bgImageOver) {
			l.background.src = l.Menu.bgImageOver;
		}
		l.focusItem.top = this.top;
		l.Menu.hideChildMenu(l);
	} else if (l.style && l.Menu) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.Menu.bgImageUp) {
				a.style.background = "url(" + a.Menu.bgImageUp +")";;
			}
		} 
		if (l.isSeparator) return;
		l.style.backgroundColor = l.menuHiliteBgColor;
		l.zIndex = 101;  // magic IE 4.5 mac happy doohicky.	jba
		if (l.Menu.bgImageOver) {
			l.style.background = "url(" + l.Menu.bgImageOver +")";
		}
		if (l.hilite) {
			l.style.backgroundColor = l.menuHiliteBgColor;
			l.hilite.style.visibility = "inherit";
		}
		l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
		l.focusItem.style.zIndex = l.zIndex +1;
		l.Menu.hideChildMenu(l);
	} else {
		return; // not a menu - magic IE 4.5 mac happy doohicky.  jba
	}
	window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
	l = window.ActiveMenuItem;
	if (!l) return;
	hideActiveMenus();
	if (l.action) {
		eval("" + l.action);
	}
	window.ActiveMenuItem = 0;
}

function FW_clearTimeout()
{
	if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
	fwHideMenuTimer = null;
	fwDHFlag = false;
}
function FW_startTimeout()
{
	fwStart = new Date();
	fwDHFlag = true;
	fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
}

function fwDoHide()
{
	if (!fwDHFlag) return;
	var elapsed = new Date() - fwStart;
	if (elapsed < 1000) {
		fwHideMenuTimer = setTimeout("fwDoHide()", 1100-elapsed);
		return;
	}
	fwDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}

function FW_showMenu(menu, x, y, child) {
	if (!window.fwWroteMenu) return;
	FW_clearTimeout();
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.left = 1;
			l.top = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) { 			   
			if (!l.layers[i].isHilite) 
				l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) 
				FW_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") 
				l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) 
				l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") 
				l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;	
		hideActiveMenus();
		if (typeof(l) == "string") {
			l = FIND(l);
		}
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") 
			s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
		if (y != "relative") 
			s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) {
		window.activeMenus[window.activeMenus.length] = l;
	}
}

function onMenuItemDown(e, l) {
	var a = window.ActiveMenuItem;
	if (document.layers) {
		if (a) {
			a.eX = e.pageX;
			a.eY = e.pageY;
			a.clicked = true;
		}
    }
}

function mouseupMenu(e)
{
	hideMenu(true, e);
	hideActiveMenus();
	return true;
}

function mouseoutMenu()
{
	hideMenu(false, false);
	return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -