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

📄 getmenu.js

📁 购物网设计的购物系统是基于WEB开发的大型购物系统。  它以构建电子商务网站为目标
💻 JS
字号:
// 定义常量
var style = "<style>td {font-size:12px; cursor: default;}.disabled {color: #666666;filter: DropShadow(Color=#ffffff, OffX=1, OffY=1, Positive=1);}</style>";
var sMenuHr = "<tr><td align=center colspan=2 valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width=96% height=2><tr><td height=1 bgcolor=#999999><\/td><\/tr><tr><td height=1 bgcolor=#ffffff><\/td><\/tr><\/TABLE><\/td><\/tr>";

// 创建弹出菜单
var oPopupMenu = null;
if (BrowserInfo.IsIE55OrMore){
	oPopupMenu = window.createPopup();
}

//取得命令菜单
function GetMenuCommand (what, caption, image) {
	var s_Disabled = "";
	if (!EditorID.document.queryCommandEnabled(what)){
		s_Disabled = "disabled";
	}
	var s_Event = "format('" + what + "')";
	if (s_Disabled == "") {
		var doclick = "onClick=\"parent.oPopupMenu.hide();parent." + s_Event + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

//取得编辑命令菜单
function GetTextCommand (what, caption, image) {
	var s_Disabled = "";
	selectRange()
	if (RangeType != "Text" || form.modeedit.value != "design"){
		s_Disabled = "disabled";
	}
	var s_Event = "format('" + what + "')";
	if (s_Disabled == "") {
		var doclick = "onClick=\"parent.oPopupMenu.hide();parent." + s_Event + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

//取得修改图片命令
function GetModifyImgCommand (what, caption, image) {
	var doevent = what;
	var s_Disabled = "";
	if (!isImageSelected() || form.modeedit.value != "design"){
		s_Disabled = "disabled";
	}
	if (s_Disabled == "") {
		var doclick = " onClick=\"parent.oPopupMenu.hide();parent." + doevent + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

//取得修改Flash命令
function GetModifyFlashCommand (what, caption, image) {
	var doevent = what;
	var s_Disabled = "";
	if (!isFlashSelected() || form.modeedit.value != "design"){
		s_Disabled = "disabled";
	}
	if (s_Disabled == "") {
		var doclick = " onClick=\"parent.oPopupMenu.hide();parent." + doevent + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

//取得修改表格命令
function GetModifyTableCommand (what, caption, image) {
	var doevent = what;
	var s_Disabled = "";
	if (!isTableSelected() || form.modeedit.value != "design"){
		s_Disabled = "disabled";
	}
	if (s_Disabled == "") {
		var doclick = " onClick=\"parent.oPopupMenu.hide();parent." + doevent + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

//取得修改表格单元格命令
function GetModifyTableTdCommand (what, caption, image) {
	var doevent = what;
	var s_Disabled = "";
	if (!isCursorInTableCell() || form.modeedit.value != "design"){
		s_Disabled = "disabled";
	}
	if (s_Disabled == "") {
		var doclick = " onClick=\"parent.oPopupMenu.hide();parent." + doevent + "\"";
	}
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}


//取得一般命令
function GetCommonCommand (what, caption, image) {
	var doevent = what;
	var s_Disabled = "";
	var doclick = " onClick=\"parent.oPopupMenu.hide();parent." + doevent + "\"";
	if (image != "") {
		image = "<img src=edithtml/images/" + image + ">";
	}
	var menu_str = "<tr height=20 " + doclick + " onmouseover=\"parent.MouseOverColor(this, '#000066')\" onmouseout=\"parent.MouseOutColor(this, '')\"><td width=25 align=right>"+ image +"</td><td class=\"" + s_Disabled + "\">&nbsp;" + caption + "</td><tr>";
	return menu_str;
}

function getmenu (type) {
	var width = 128;
	var topper = -27;
	var oPopDocument = oPopupMenu.document;
	var oPopBody = oPopupMenu.document.body;

	var menu = "<body scroll=no style=\"background: #c0c0c0;border:none\" leftmargin=\"0\" topmargin=\"0\"oncontextmenu=return(false)> ";
	menu += "<table width=100% height=100% cellspacing=\"0\" cellpadding=\"0\" style=\"border-left:1 solid #ffffff;border-top:1 solid #ffffff;border-right:1 solid #999999;border-bottom:1 solid #999999\">";
	switch (type) {

		case "edit" :
			var height = 130;
			var lefter = 1;
			//menu += GetMenuCommand ("Undo", "撤消 Ctrl + Z", "undo.gif");
			//menu += GetMenuCommand ("Redo", "重做 Ctrl + Y", "redo.gif");
			//menu += sMenuHr;
			menu += GetMenuCommand ("Cut", "剪切 Ctrl + X", "cut.gif");
			menu += GetMenuCommand ("Copy", "复制 Ctrl + C", "copy.gif");
			menu += GetMenuCommand ("Paste", "粘贴 Ctrl + V", "paste.gif");
			menu += GetMenuCommand ("delete", "删除 Delete", "delete.gif");
			menu += sMenuHr;
			menu += GetMenuCommand ("selectall", "全选  Ctrl + A", "selectall.gif");
			menu += GetCommonCommand ("FindReplace()", "查找替换...", "findreplace.gif");
		break;
		case "view" :
			var height = 84;
			var lefter = 55;
			menu += GetCommonCommand ("ViewFormat('design')", "设计 " + GetMode ('design'), "modeeditbtn.gif");
			menu += GetCommonCommand ("ViewFormat('code')", "源代码 " + GetMode ('code'), "modecodebtn.gif");
			menu += GetCommonCommand ("ViewFormat('view')", "预览 " + GetMode ('view'), "site.gif");
			menu += GetCommonCommand ("ShowBorder()", "辅助线 " + GetShowBorder (), "guide.gif");
		break;
		case "input" :
			var width = 150;
			var height = 174;
			var lefter = 110;
			menu += GetCommonCommand ("InsertImg()", "图片...", "image.gif");
			menu += GetCommonCommand ("InsertFlash()", "Flash...", "flash.gif");
			menu += GetCommonCommand ("InsertRelPlayer()", "RelPlayer...", "rel.gif");
			menu += GetCommonCommand ("InsertMediaPlayer()", "MediaPlayer...", "mid.gif");
			menu += sMenuHr;
			menu += GetCommonCommand ("InsertTable()", "表格...", "tablemenu.gif");
			menu += sMenuHr;
			menu += GetCommonCommand ("InsertMarquee()", "移动字幕...", "marquee.gif");
			menu += GetMenuCommand ("InsertHorizontalRule", "水平线", "hr.gif");
			menu += sMenuHr;
			menu += GetMenuCommand ("CreateLink", "URL链接... Ctrl + K", "link.gif");
		break;
		case "modify" :
			var width = 150;
			var height = 256;
			var lefter = 165;
			menu += GetModifyImgCommand ("ModifyImage()", "图片属性...", "image.gif");
			menu += GetModifyFlashCommand ("ModifyFlash()", "Flash属性...", "flash.gif");
			menu += sMenuHr;
			menu += GetModifyTableCommand ("ModifyTable()", "表格属性...", "tablemenu.gif");
			menu += GetModifyTableTdCommand ("ModifyCell()", "单元格属性...", "cellpro.gif");
			menu += GetModifyTableTdCommand ("InsRowAbove()", "插入行(在上方)", "rowabove.gif");
			menu += GetModifyTableTdCommand ("InsRowBelow()", "插入行(在下方)", "rowbellow.gif");
			menu += GetModifyTableTdCommand ("InsColLeft()", "插入列(在左边)", "colafter.gif");
			menu += GetModifyTableTdCommand ("InsColRight()", "插入列(在右边)", "colbefore.gif");
			menu += GetModifyTableTdCommand ("DeleteRow()", "删除行", "delrow.gif");
			menu += GetModifyTableTdCommand ("DeleteCol()", "删除列", "delcol.gif");
			menu += sMenuHr;
			menu += GetMenuCommand ("CreateLink", "修改链接... Ctrl + K", "link.gif");
			menu += GetMenuCommand ("Unlink", "删除链接", "dellink.gif");
		break;
		case "text" :
			var height = 150;
			var lefter = 220;
			menu += GetTextCommand ("Bold", "粗体 Ctrl + B", "bold.gif");
			menu += GetTextCommand ("Italic", "斜体 Ctrl + I", "italic.gif");
			menu += GetTextCommand ("Underline", "下划线 Ctrl + U", "underline.gif");
			menu += GetTextCommand ("StrikeThrough", "删去线", "del.gif");
			menu += GetTextCommand ("Superscript", "上标", "superscript.gif");
			menu += GetTextCommand ("Subscript", "下标", "subscript.gif");
			menu += sMenuHr;
			menu += GetCommonCommand ("Font()", "文字...", "font.gif");
			
	}
	menu += "</table>";
	oPopDocument.open();
	oPopDocument.write(style + menu);
	oPopDocument.close();

	height+=2;
	if(lefter+width > EditorID.document.body.clientWidth) lefter=lefter-width;
	//if(topper+height > EditorID.document.body.clientHeight) topper=topper-height;

	oPopupMenu.show(lefter, topper, width, height, EditorID.document.body);
	return false;
}

// 右键菜单
function showContextMenu(event){
	var width = 150;
	var height = 128;
	var lefter = event.clientX;
	var topper = event.clientY;

	var oPopDocument = oPopupMenu.document;
	var oPopBody = oPopupMenu.document.body;
	var menu = "<body scroll=no style=\"background: buttonface;border:none\" leftmargin=\"0\" topmargin=\"0\"oncontextmenu=return(false)> ";
	menu += "<table width=100% height=100% cellspacing=\"0\" cellpadding=\"0\" style=\"border-left:1 solid #dddddd;border-top:1 solid:1 solid #dddddd;border-right:2 solid #999999;border-bottom:2 solid #999999\">";
	menu += GetMenuCommand ("Cut", "剪切 Ctrl + X", "cut.gif");
	menu += GetMenuCommand ("Copy", "复制 Ctrl + C", "copy.gif");
	menu += GetMenuCommand ("Paste", "粘贴 Ctrl + V", "paste.gif");
	menu += GetMenuCommand ("delete", "删除 Delete", "delete.gif");
	menu += GetMenuCommand ("SelectAll", "全选  Ctrl + A", "selectall.gif");
	menu += sMenuHr;
	menu += GetCommonCommand ("FindReplace()", "查找替换. . .", "findreplace.gif");
	menu += "</table>";
	oPopDocument.open();
	oPopDocument.write(style + menu);
	oPopDocument.close();

	height+=2;
	if(lefter+width > EditorID.document.body.clientWidth) lefter=lefter-width;
	if(topper+height > EditorID.document.body.clientHeight) topper=topper-height;

	oPopupMenu.show(lefter, topper, width, height, EditorID.document.body);
	return false;

}

⌨️ 快捷键说明

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