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

📄 menu.js

📁 ajax php wiki source code
💻 JS
字号:
function Menu(strObjName, strEID, strCallback) {
	this.itemNum = 0;
	this.items = Array();
	this.curSel = 0;
	this.objName = strObjName;
	this.elementID = strEID;
	this.callback = strCallback;

	this.selClassName = "son";		// Default class name
	this.unselClassName = "soff";		// Default class name
	
	if (arguments.length >= 5) {
		this.selClassName = arguments[3];
		this.unselClassName = arguments[4];

		if (arguments.length == 5) {
			this.maxSelection = arguments[5];
		}
	}
}

Menu.prototype.clear = function() {
	$(this.elementID).innerHTML = "";
	this.itemNum = 0;
	this.items.clear();
	this.curSel = 0;
}

Menu.prototype.add_item = function($content) {
	$(this.elementID).innerHTML += '<div style="cursor:pointer" class="' + this.unselClassName + '" onmouseover="' + this.objName + '.highlight(\'' + this.itemNum + '\')" onmouseout="' + this.objName +'.highlight(\'' + this.itemNum + '\')" onclick="' + this.callback + '(\'' + this.itemNum + '\')" id="MENU_ITEM_' + this.itemNum + '">' + $content + '</div>';
	this.items.push ($content);
	this.itemNum ++;
}

Menu.prototype.highlight = function (id) {
	for (var i = 0; i < this.itemNum; i++) {
		var d = $('MENU_ITEM_' + i);
		if (id == i) {
			d.className = this.selClassName;
			this.curSel = i;
		} else {
			d.className = this.unselClassName;
		}
	}
}

Menu.prototype.sel_next = function () {
	if (this.itemNum == 0)
		return;
	if (this.curSel < this.itemNum - 1) {
		this.highlight (this.curSel + 1);
	}
}

Menu.prototype.sel_prev = function () {
	if (this.itemNum == 0)
		return;
	if (this.curSel > 0) {
		this.highlight (this.curSel - 1);
	}
}

Menu.prototype.get_content = function (id) {
	if (id >= 0 && id < this.itemNum) {
		return $('MENU_ITEM_' + id).innerHTML;
	} else {
		return false;
	}
}

Menu.prototype.get_current_content = function () {
	return this.get_content(this.curSel);
}

⌨️ 快捷键说明

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