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

📄 edithtml.js

📁 OpenCms 是一个J2EE的产品
💻 JS
📖 第 1 页 / 共 3 页
字号:
	GeneralContextMenu[1] = new ContextMenuItem(LANG_COPY, DECMD_COPY);
	GeneralContextMenu[2] = new ContextMenuItem(LANG_PASTE, DECMD_PASTE);
	TableContextMenu[0] = new ContextMenuItem(MENU_SEPARATOR, 0);
	TableContextMenu[1] = new ContextMenuItem(LANG_INSERTROW, DECMD_INSERTROW);
	TableContextMenu[2] = new ContextMenuItem(LANG_DELETEROW, DECMD_DELETEROWS);
	TableContextMenu[3] = new ContextMenuItem(MENU_SEPARATOR, 0);
	TableContextMenu[4] = new ContextMenuItem(LANG_INSERTCOL, DECMD_INSERTCOL);
	TableContextMenu[5] = new ContextMenuItem(LANG_DELETECOL, DECMD_DELETECOLS);
	TableContextMenu[6] = new ContextMenuItem(MENU_SEPARATOR, 0);
	TableContextMenu[7] = new ContextMenuItem(LANG_INSERTCELL, DECMD_INSERTCELL);
	TableContextMenu[8] = new ContextMenuItem(LANG_DELETECELL, DECMD_DELETECELLS);
	TableContextMenu[9] = new ContextMenuItem(LANG_MERGECELL, DECMD_MERGECELLS);
	TableContextMenu[10] = new ContextMenuItem(LANG_SPLITCELL, DECMD_SPLITCELL);
	EDITOR.EDIT_HTML.focus();
}

// Sets the foreground color with the data received by the "selcolor" dialog
function setFGColor(arr) {
	if (arr != -1) {
		if (document.all.EDIT_HTML.QueryStatus( DECMD_GETFORECOLOR ) != DECMDF_DISABLED) {
			document.all.EDIT_HTML.ExecCommand(DECMD_SETFORECOLOR, OLECMDEXECOPT_DODEFAULT, arr);
		}
		window.clearInterval(CheckFGCol);
		SelColor=-1;
	}
}

// Sets the background color with the data received by the "selcolor" dialog
function setBGColor(arr) {
	if (arr != -1) {
		if (document.all.EDIT_HTML.QueryStatus( DECMD_SETBACKCOLOR )  != DECMDF_DISABLED ) {
			document.all.EDIT_HTML.ExecCommand(DECMD_SETBACKCOLOR, OLECMDEXECOPT_DODEFAULT, arr);
		}
		window.clearInterval(CheckBGCol);
		SelColor=-1;
	}
}


// Checks if a table element is selected
function checkTableSelection() {
	var editor = document.all.EDIT_HTML;
	var sel = editor.DOM.selection;

	if(sel.type == "Control") {
		var range = sel.createRange()(0);

		// we have selected a table object
		if(range.tagName == "TABLE" || range.tagName == "table") {

			// get table properties
			var args1 = new Array();

			if (range.border != "" && range.border.length > 0) {
				args1["BorderLineWidth"] = range.border;
			}

			if (range.cellPadding != "" && range.cellPadding.length > 0) {
				args1["CellPadding"] = range.cellPadding;
			}

			if (range.cellSpacing != "" && range.cellSpacing.length > 0) {
				args1["CellSpacing"] = range.cellSpacing;
			}

			if (range.bgColor != "" && range.bgColor.length > 0) {
				args1["TableColor"] = range.bgColor;
			}

			//get new attributes
			var args2 = new Array();
			args2 = showModalDialog("dialogs/table_new.jsp?titleType=edit", args1, "dialogWidth:600px; resizable: yes; help: no; status: no; scroll: no;");

			// set the new attributes
			if (args2 != null) {
				for ( elem in args2 ) {
					if ("BorderLineWidth" == elem && args2["BorderLineWidth"] != null) {
						range.border = args2["BorderLineWidth"];
					} else if ("CellPadding" == elem && args2["CellPadding"] != null) {
						range.cellPadding = args2["CellPadding"];
					} else if ("CellSpacing" == elem && args2["CellSpacing"] != null) {
						range.cellSpacing = args2["CellSpacing"];
					} else if ("TableColor" == elem && args2["TableColor"] != null) {
						range.bgColor = args2["TableColor"];
					}
				}
			}
		}
	} else {
		InsertTable();
	}
}

// Checks if a table row or cell element is selected
function checkTableElSelection(type) {

	var editor = document.all.EDIT_HTML;
	var sel = editor.DOM.selection;
	var sel2 = null;
	var args1 = new Array();

	cursorPos=sel.createRange();

	// there should be no selection !
	if (sel.type == 'None') {
		var elt = cursorPos.parentElement();
		// find next TD or TR
		while (elt) {
			if (elt.tagName == type) {
				break;
			}
			elt = elt.parentElement;
		}

		if (elt) {
			// don't select document area
			if (elt.id != editor.id) {
				// get all attributes
				var eltheight = elt.getAttribute("height", 0);
				var eltwidth = elt.getAttribute("width", 0);
				var eltalign = elt.getAttribute("align", 0);
				var eltvAlign = elt.getAttribute("vAlign", 0);
				var eltbgColor = elt.getAttribute("bgColor", 0);
				var eltborderColor = elt.getAttribute("borderColor", 0);
				// set arguments for dialog
				if(eltbgColor != null && eltbgColor != "undefined" && eltbgColor.length > 0) {
					args1["bgColor"] = eltbgColor;
				} else {
					args1["bgColor"] = "";
				}
				if(eltborderColor != null && eltborderColor != "undefined" && eltborderColor.length > 0) {
					args1["borderColor"] = eltborderColor;
				} else {
					args1["borderColor"] = "";
				}
				if(eltheight != null && eltheight.length > 0) {
					args1["height"] = eltheight;
				} else {
					args1["height"] = "";
				}
				if(eltwidth != null && eltwidth.length > 0) {
					args1["width"] = eltwidth;
				} else {
					args1["width"] = "";
				}
				if(eltalign != null && eltalign.length > 0) {
					args1["align"] = eltalign;
				} else {
					args1["align"] = "";
				}
				if(eltvAlign != null && eltvAlign.length > 0) {
					args1["vAlign"] = eltvAlign;
				} else {
					args1["vAlign"] = "";
				}
				args1["title"] = type;

				// call dialog
				args2 = showModalDialog("dialogs/table_element.jsp?titleType=" + type, args1, "resizable: yes; help: no; status: no; scroll: no;");

				// args == null if cancel button was pressed
				if (args2 != null) {
					// clear all attributes
					elt.removeAttribute("bgColor", 0);
					elt.removeAttribute("borderColor", 0);
					elt.removeAttribute("height", 0);
					elt.removeAttribute("width", 0);
					elt.removeAttribute("align", 0);
					elt.removeAttribute("vAlign", 0);
					// get values from dialog and set attributes of table element
					for ( elem in args2 ) {
						if ("bgColor" == elem && args2["bgColor"] != null) {
							elt.setAttribute("bgColor", args2["bgColor"]);
						} else if ("borderColor" == elem && args2["borderColor"] != null) {
							elt.borderColor = args2["borderColor"];
						} else if ("height" == elem && args2["height"] != null) {
							elt.height = args2["height"];
						} else if ("width" == elem && args2["width"] != null) {
							elt.width = args2["width"];
						} else if ("align" == elem && args2["align"] != null) {
							elt.align = args2["align"];
						} else if ("vAlign" == elem && args2["vAlign"] != null) {
							elt.vAlign = args2["vAlign"];
						}
					}
				}
			} else {
				// id of found element == id of Editor, so cursor is not inside table
				args1["error_notable"] = "true";
				showModalDialog( workplacePath + "action/edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
			}
		} else {
			// no parent found with tag.name == TR or TD
			args1["error_notable"] = "true";
			showModalDialog( workplacePath + "action/edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50px; dialogHeight:32px");
		}
	} else {
		// text or picture or control selected
		args1["error_selection"] = "true";
		showModalDialog( workplacePath + "action/edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
	}
}

//  Inserts a new table
function InsertTable() {
	var pVar = document.all.ObjTableInfo;
	var args = new Array();
	var arr = null;

	document.all.ObjTableInfo.TableAttrs =" ";
	document.all.ObjTableInfo.CellAttrs =" ";

	// Preset values for the table dialog.
	// Data is stored in an array that is submitted to the dialog.
	args["NumRows"] = document.all.ObjTableInfo.NumRows;
	args["NumCols"] = document.all.ObjTableInfo.NumCols;
	args["TableAttrs"] =document.all.ObjTableInfo.TableAttrs;
	args["CellAttrs"] = document.all.ObjTableInfo.CellAttrs;
	args["Caption"] = document.all.ObjTableInfo.Caption;
	args["BorderLineWidth"] = 1;
	args["CellSpacing"] = 1;
	args["CellPadding"] = 1;
	args["TableAlignment"] = "";
	args["TableWidth"] = 100;
	args["TableHeight"] = 100;
	args["TableWidthMode"] = "";
	args["TableHeightMode"] = "";

	arr = null;

	// Call the "addtable" dialog and receive its results in the arr array
	arr = showModalDialog("dialogs/table_new.jsp", args, "dialogWidth:600px; resizable: yes; help: no; status: no; scroll: no;");
	if (arr != null) {

	// Initialize table object. Values from the arr array are processed for creating the Control call

	for ( elem in arr ) {
		if ("NumRows" == elem && arr["NumRows"] != null) {
			document.all.ObjTableInfo.NumRows = arr["NumRows"];
		} else if ("NumCols" == elem && arr["NumCols"] != null) {
			document.all.ObjTableInfo.NumCols = arr["NumCols"];
		} else if ("BorderLineWidth" == elem) {
			document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "border="+arr["BorderLineWidth"]+" ";
		} else if ("CellSpacing" == elem) {
			document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellspacing="+arr["CellSpacing"]+" ";
		} else if ("CellPadding" == elem) {
			document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellpadding="+arr["CellPadding"]+" ";
		} else if ("TableWidth" == elem) {
			if(arr["TableWidth"] != "") {
				document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "width="+arr["TableWidth"];
				if(arr["TableWidthMode"] == "%") {
					document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
				} else {
					document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
				}
			}
		} else if ("TableHeight" == elem) {
			if(arr["TableHeight"] == "") {
				document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "height="+arr["TableHeight"];
				if(arr["TableHeightMode"] == "%") {
					document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
				} else {
					document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
				}
			}
		} else if ("TableAlignment" == elem) {
			document.all.ObjTableInfo.CellAttrs = document.all.ObjTableInfo.CellAttrs + "align="+arr["TableAlignment"]+" ";
		} else if ("TableColor" == elem) {
			if(arr["TableColor"] != "") {
				document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "bgcolor="+arr["TableColor"];
			}
		} else if ("Caption" == elem) {
			document.all.ObjTableInfo.Caption = arr["Caption"];
		}
	}

	document.all.EDIT_HTML.ExecCommand(DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT, pVar);
	}
}


// sends URL string from seperate browser window to a hidden field within the opener document
function sendURLString(destFormName,destFieldName,strURL) {
	var obj1='top.window.opener.self.document.'+ destFormName;
	var obj2='top.window.opener.self.document.'+ destFormName +'.'+ destFieldName;
	if (eval(obj1) && eval(obj2)) {
		Eval(obj2 +'.value="'+strURL+'"');
		top.window.opener.doEditHTML(45);
	}
}


var foundstyles = new Array();

function setStyles(i, name) {
	foundstyles[i] = name;
}

function resetStyles() {
	var sel = document.all.BLOCK;
	for (i=0; i<foundstyles.length; i++) {
		sel.options[i] = new Option(foundstyles[i], foundstyles[i]);
	}
}

function initStyles() {
	getStyles();
	resetStyles();
}

// Delete all empty <a>-Tags
function deleteEmptyATags() {
	var allLinks = EDITOR.EDIT_HTML.DOM.all.tags("A");
	var allImgLinks;

	for(var i = 0; i < allLinks.length; i++) {
		if (allLinks[i].innerText == "") {
			allImgLinks = allLinks[i].all.tags("IMG");
			if (allImgLinks.length == 0) {
				allLinks[i].removeNode();
			}
		}
	}
}

// Remove server name from image path
// Example: http://10.0.0.0:8080/system/test -> /system/test
function makeImageLinks() {
	var systemPath = getSystemPath();
	var col = document.EDIT_HTML.DOM.all.tags("img");
	var i;
	for (i=0; i<col.length; i++) {
		var el = col[i];
		var href = el.getAttribute("src");
		href = href.replace(systemPath, "");
		el.setAttribute("src", href);
		// el.removeAttribute("style");
	}
}

// Get the server name of the page
function getSystemPath() {
	var systemPath="";
	var localURL=document.URL;
	var n;

	n = localURL.indexOf("://", 0);
	if (n<0) return systemPath;

	n = localURL.indexOf("/", n+3);
	if (n<0) n = localURL.length;

	systemPath = localURL.substring(0, n);
	return systemPath;
}

⌨️ 快捷键说明

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