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

📄 menu.js

📁 wince 电池电源管理文件集 wince 电池电源管理文件集
💻 JS
字号:
/*
	DMForum.NET MenuClass
*/

var MenuListenHandler = null; //菜单监视句柄
var MenuViewedID = null; //当前显示的菜单唯一名称
var LastMenuViewedID = null; //最后一次显示的菜单唯一名称

function class_menu()
{
	this.caption = "";
	this.inputs = "";
	this.items = "";
	this.marginOfTop = 0;
	this.sizeOfTop = 0;
	this.sizeOfLeft = 0;
	this.sizeOfWidth = 0;
	this.getXY = null;
	this.setToTop = false;
		
	this.MenuViewed = function()
	{
		var obj = document.getElementById("MenuLayer");
		if ( obj == null ) return false;
		return( obj.style.display == "block" && LastMenuViewedID == this.caption );
	}
	
	this.Create = function ( menuCaption )
	{
		var obj = document.getElementById("MenuLayer");
		if ( obj == null ) return;
		
		this.caption = menuCaption;

		clearInterval(MenuListenHandler);
		if ( this.MenuViewed() ) return;

		this.sizeOfTop = 0;
		this.items = "";
		this.inputs = "<div class='menucaption' onmouseover='DMFMenux.Keep(3)'><strong>" + this.caption + "</strong></div>";
	}
	
	this.Draw = function( reObj )
	{
		var obj = document.getElementById("MenuLayer");
		var itemobj = document.getElementById("MenuItemsLayer");
		if ( obj == null || itemobj == null ) return;

		
		if ( this.MenuViewed() ) return;

		itemobj.innerHTML = this.inputs + this.items;

		this.items = "";

		var p = this.getXY(reObj);
		var objheight = 20;
		if ( this.marginOfTop == 0 )
		{
			if ( reObj.height != null ) objheight = reObj.height;
			objheight = objheight / 2 - 2;
		}else
		{
			objheight = this.marginOfTop;
		}
		var nowtop = p.y + objheight;
		var nowleft = p.x;
		obj.style.top = nowtop + "px";
		if ( this.setToTop ) obj.style.top = "0px";
		if ( nowleft + this.sizeOfWidth > document.body.scrollWidth ) nowleft = document.body.scrollWidth - this.sizeOfWidth - 5;
		obj.style.left = nowleft + "px";
		obj.style.width = this.sizeOfWidth + "px";
		obj.style.paddingTop = this.sizeOfTop + "px";
		obj.style.paddingLeft = this.sizeOfLeft + "px";
		obj.style.display = "block";
		this.setToTop = false;
	}
	
	this.Dispose = function()
	{
		MenuListenHandler = setInterval("DMFMenux.Clear()",10);
	}
	
	this.Keep = function(number,obj)
	{
		//alert('keep:' + number);
		if ( obj != null ) obj.className = "menulinkitemselected";
		MenuViewedID = this.caption;
	}
	
	this.Out = function ( obj )
	{
		if ( obj != null ) obj.className = "menulinkitem";		
	}
	
	this.Finally = function(number,obj)
	{
		//alert('finally:' + number);
		LastMenuViewedID = MenuViewedID;
		MenuViewedID = null;
	}	
	
	this.AppendItem = function( linkURL,text,icon )
	{
		this.items += "<div class='menulinkitem' onmouseover='DMFMenux.Keep(2,this)' onmouseout='DMFMenux.Out(this)' onclick='javascript:location.href=\"" + linkURL + "\";'>";
		if ( icon != null ) this.items += "<img src='" + icon + "' alt='' class='inlineimg'/> ";
		this.items += text + "</div>";
	}
	
	this.AppendSelectItem = function( linkDes,text,style )
	{
		this.items += "<div class='menulinkitem' onmouseover='DMFMenux.Keep(2,this)' onmouseout='DMFMenux.Out(this)' onclick='javascript:" + linkDes + ";' style='" + style + "'>";
		this.items += text + "</div>";
	}

	this.AppendTextItem = function( text )
	{
		this.items += "<div class='menuitem' onmouseover='DMFMenux.Keep(2)'>" + text + "</div>";
	}
	
	this.Clear = function( )
	{
		var obj = document.getElementById("MenuLayer");
		if ( obj == null ) return;
		if (obj.style.display == "none")
		{
			clearInterval(MenuListenHandler);
			MenuViewedID = null;
			return;
		}
		
		if ( MenuViewedID == this.caption ) return;
		clearInterval(MenuListenHandler);
		obj.style.display = "none";
	}
}

var DMFMenux = new class_menu;

DMFMenux.getXY = DMFx.getXY;

⌨️ 快捷键说明

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