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

📄 script_editor.js

📁 IBM RSA下的JSF开发示例
💻 JS
📖 第 1 页 / 共 5 页
字号:
// This global variable serves as a flag for RTE acessibility support.// This var is set in options_ie.jsp when the accessible toolbar is invoked.var isAccessible = false;// This global variable is used to transfer the editor content from the main // editor window to the child print window. // This var is added in 5.1 release. See IBM_RTE_doPrint() for details. var cnt;var mode = 0;function IBM_RTE_getEditorMode(editorName){	if(IBM_RTE_getDocument(editorName).mode == null)		IBM_RTE_getDocument(editorName).mode = 0;	return IBM_RTE_getDocument(editorName).mode;}function IBM_RTE_isMozilla() {    return navigator.product == 'Gecko';}function IBM_RTE_isNetscape() {    return /netscape/i.test(navigator.userAgent);}function IBM_RTE_getFrame(editorName) {    if (!isAccessible)       return document.getElementById(editorName );    else       return this.opener.document.getElementById(editorName );      }function IBM_RTE_getWindow(editorName) {    return IBM_RTE_getFrame(editorName).contentWindow;}function IBM_RTE_getDocument(editorName) {    return IBM_RTE_getWindow(editorName).document;}function IBM_RTE_setDesignMode1(editorName) {    IBM_RTE_getDocument(editorName).designMode = "on";  }//In IE, use body.contentEditable to set the document to be editable.//This allows elements to be hidden or shown as needed using style.display attribute.//The change is mainly for 5.1 annotation feature (available in the popup editor version only).//No existing features are affected by this change.function IBM_RTE_setDesignMode(editorName) {    if (IBM_RTE_isMozilla()) {        IBM_RTE_getDocument(editorName).designMode = "on";      }else {		if ((IBM_RTE_getDocument(editorName).body)==null){			setTimeout("IBM_RTE_setDesignMode('" + editorName + "')", 1500);		}else{			IBM_RTE_getDocument(editorName).body.contentEditable = true;		}    }	editorNameSaved = editorName;	if(!IBM_RTE_isMozilla())		backup[0]=IBM_RTE_getDocument(editorName).body.innerHTML;}function IBM_RTE_getToolbarColor(editorName) {    return IBM_RTE_isMozilla() ? document.defaultView.getComputedStyle(document.getElementById(editorName), '').getPropertyValue("background-color") : document.getElementById(editorName).currentStyle.backgroundColor;}function IBM_RTE_loadEditorWithEmptyDocument(editorName, docDir) {    IBM_RTE_getDocument(editorName).body.innerHTML = "<html><head><title></title></head><body dir='" + docDir + "'></body></html>";}function IBM_RTE_doTheCommand(editorName, commandname) {        /** *  undo/redo breaks for RAD RTE plugin in IE. *  manual undo/redo implementation used. */    IBM_RTE_getWindow(editorName).focus();	if(!IBM_RTE_isMozilla() && (commandname == 'undo' || commandname == 'redo')){		if(commandname == 'undo'){			if(isAccessible) 				this.opener.IBM_RTE_undo(editorName);			else				IBM_RTE_undo(editorName);		}    else{		if(isAccessible) 			this.opener.IBM_RTE_redo(editorName);		else			IBM_RTE_redo(editorName);		}    }   else{		if(!IBM_RTE_isMozilla()){			if(isAccessible) 				this.opener.IBM_RTE_backup(editorName);			else				IBM_RTE_backup(editorName);		}    IBM_RTE_getDocument(editorName).execCommand(commandname, false, null);    }}function IBM_RTE_doLink(editorName, prompttext) {    	if(!IBM_RTE_isMozilla()){		if(isAccessible) 			this.opener.IBM_RTE_backup(editorName);		else			IBM_RTE_backup(editorName);	}    if (IBM_RTE_isMozilla()) {		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");		var xxx=0;		while(a[xxx] != null){			if(a[xxx].getAttribute("odc") != null)				a[xxx].setAttribute("href", a[xxx].getAttribute("odc"));				xxx++;		}        var theurl = prompt(prompttext[0], "http://");        IBM_RTE_getDocument(editorName).execCommand('createlink', false, theurl);		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");	    var xxx=0;		while(a[xxx] != null){			 a[xxx].setAttribute("odc", a[xxx].getAttribute("href"));			 xxx++;		}    }    else {		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");		var xxx=0;		while(a[xxx] != null){			if(a[xxx].odc != null)				a[xxx].href = a[xxx].odc;				xxx++;		}        IBM_RTE_getWindow(editorName).focus();        IBM_RTE_getDocument(editorName).execCommand('createlink', true, null);		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");	    var xxx=0;		while(a[xxx] != null){			 a[xxx].setAttribute("odc", a[xxx].href);			 xxx++;		}	   }}	function IBM_RTE_doFontStyle(editorName, ctrl, commandname) {    if (ctrl) {        var hType = ctrl.options[ctrl.selectedIndex].value;        if (hType != '') {            IBM_RTE_getWindow(editorName).focus();		if(!IBM_RTE_isMozilla()){			if(isAccessible) 				this.opener.IBM_RTE_backup(editorName);			else				IBM_RTE_backup(editorName);		}            IBM_RTE_getDocument(editorName).execCommand(commandname, false, hType);    }}}function IBM_RTE_getOffsetTop(ctrl) {    var offsetTop = ctrl.offsetTop;    var offsetParent = ctrl.offsetParent;    while (offsetParent) {                    offsetTop += offsetParent.offsetTop;        offsetParent = offsetParent.offsetParent;    }    return offsetTop;}function IBM_RTE_getOffsetLeft(ctrl) {    var offsetLeft = ctrl.offsetLeft;    var offsetParent = ctrl.offsetParent;    while (offsetParent) {        offsetLeft += offsetParent.offsetLeft;        offsetParent = offsetParent.offsetParent;    }    return offsetLeft;}function IBM_RTE_doColor(editorName, clrType, buttonElement, locale, images, directory, isBidi) {	if(!IBM_RTE_isMozilla()){		if(isAccessible) 			this.opener.IBM_RTE_backup(editorName);		else			IBM_RTE_backup(editorName);	}    if (IBM_RTE_isMozilla()) {        if (clrType.localeCompare("backcolor") == 0)              clrType = "hilitecolor";     }	IBM_RTE_getWindow(editorName).focus();    var jrl = "colorPicker_accessible.jsp";    jrl = directory + jrl;    var wcp_colorWin = window.open(jrl + '?locale=' + locale + '&images=' + images + '&editorName=' + editorName + '&isBidi=' + isBidi  + '&clrType=' + clrType, 'colors', 'scrollbars=0, toolbar=0, statusbar=0, width=320, height=450, left=' + ((screen.width - 260) / 2) + ', top=' + ((screen.height - 150) / 2));    wcp_colorWin.focus();}// Used to insert elements in Mozilla editor.function IBM_RTE_insertNodeAtSelection(win, insertNode) {    var sel = win.getSelection();    var range = sel.getRangeAt(0);    var container = range.endContainer;    var pos = range.endOffset;    // make a new range for the new selection    range = document.createRange();    if (container.nodeType == 3 && insertNode.nodeType == 3) {        // if we insert text in a textnode, do optimized insertion        container.insertData(pos, insertNode.nodeValue);        // put cursor after inserted text        range.setEnd(container, pos + insertNode.length);        range.setStart(container, pos + insertNode.length);            }else {        var afterNode;        if (container.nodeType == 3) {            // when inserting into a textnode we create 2 new textnodes and put the insertNode in between            var textNode = container;            container = textNode.parentNode;            var text = textNode.nodeValue;            // text before the split            var textBefore = text.substr(0,pos);            // text after the split            var textAfter = text.substr(pos);                        var beforeNode = document.createTextNode(textBefore);            var afterNode = document.createTextNode(textAfter);                        // insert the 3 new nodes before the old one            container.insertBefore(afterNode, textNode);            container.insertBefore(insertNode, afterNode);            container.insertBefore(beforeNode, insertNode);                        // remove the old node            container.removeChild(textNode);        }        else {            // else simply insert the node            afterNode = container.childNodes[pos];            container.insertBefore(insertNode, afterNode);        }        range.setEnd(afterNode, 0);        range.setStart(afterNode, 0);    }    sel.addRange(range);}function IBM_RTE_doTableInsert(editorName, buttonElement, locale, images, directory, tab_array, isBidi) {	var numrows = tab_array[0];	var numcols = tab_array[1];    IBM_RTE_getWindow(editorName).focus();	if(!IBM_RTE_isMozilla()){		if(isAccessible) 			this.opener.IBM_RTE_backup(editorName);		else			IBM_RTE_backup(editorName);	}    var wcp_tableWin = window.open(directory + 'table_ie.jsp?locale=' + locale + '&images=' + images + '&editorName=' + editorName + '&isBidi=' + isBidi, 'table', 'scrollbars=0, toolbar=0, statusbar=0,resizable=yes, width=200, height=190, left=' + ((screen.width - 200) / 2) + ', top=' + ((screen.height - 170) / 2));    wcp_tableWin.focus();}function IBM_RTE_getEditorHTML(editorName) {    var bodyDir =  IBM_RTE_getDocument(editorName).body.dir;    var lnks = IBM_RTE_getDocument(editorName).getElementsByTagName("link");    var iHead = '<html>\n<head>\n<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />\n';    var ttls = IBM_RTE_getDocument(editorName).getElementsByTagName("title");	if ((ttls) && ttls.length > 0) {        iHead += "<title>" + ttls[0].text + "</title>\n";    }        for (i = 0; (lnks) && (i < lnks.length); i++) {        iHead += "<link rel='" + lnks[0].rel + "' href='" + lnks[i].href + "' />\n";    }    iHead += "</head>\n";    if (bodyDir.localeCompare('ltr') == 0)        iHead += "<body dir='ltr'>\n";    else if (bodyDir.localeCompare('rtl') == 0)         iHead += "<body dir='rtl'>\n";    else        iHead += "<body>\n";    iHTML = IBM_RTE_getDocument(editorName).body.innerHTML;    iFoot = "</body>\n</html>";    iAll = iHead + iHTML + iFoot;    return iAll;}function IBM_RTE_getEditorContent(editorName, mode,encoding) {    var bodyDir =  IBM_RTE_getDocument(editorName).body.dir;    var lnks = IBM_RTE_getDocument(editorName).getElementsByTagName("link");    var iHead = '<html>\n<head>\n<meta http-equiv="content-type" content="text/html; charset="';	iHead += encoding;	iHead += "\" />\n";    var ttls = IBM_RTE_getDocument(editorName).getElementsByTagName("title");    if ((ttls) && ttls.length > 0) {        iHead += "<title>" + ttls[0].text + "</title>\n";    }        for (i = 0; (lnks) && (i < lnks.length); i++) {        iHead += "<link rel='" + lnks[0].rel + "' href='" + lnks[i].href + "' />\n";    }    iHead += "</head>\n";    if (bodyDir.localeCompare('ltr') == 0)        iHead += "<body dir='ltr'>\n";    else if (bodyDir.localeCompare('rtl') == 0)         iHead += "<body dir='rtl'>\n";    else        iHead += "<body>\n";    if (IBM_RTE_getEditorMode(editorName) == 0){                 iHTML = IBM_RTE_getDocument(editorName).body.innerHTML;		 IBM_RTE_getDocument(editorName).body.innerText = iHTML;		 iText = IBM_RTE_getDocument(editorName).body.innerText;		 IBM_RTE_getDocument(editorName).body.innerHTML = iText;       iHTML = IBM_RTE_getDocument(editorName).body.innerHTML;    }    else if (IBM_RTE_getEditorMode(editorName) == 1) {         if (IBM_RTE_isMozilla()) {            var html = IBM_RTE_getDocument(editorName).body.ownerDocument.createRange();            html.selectNodeContents(IBM_RTE_getDocument(editorName).body);            iHTML = html.toString();         }         else {            iHTML = IBM_RTE_getDocument(editorName).body.innerText;         }    }          iFoot = "</body>\n</html>";	iHTML= iHTML.replace(/\<TD\>\<\/TD\>/g, "<TD>&nbsp;</TD>");    iAll = iHead + iHTML + iFoot;	return iAll;}function IBM_RTE_getEditorHTML2(editorName, metaCnt) {    var bodyDir =  IBM_RTE_getDocument(editorName).body.dir;    var lnks = IBM_RTE_getDocument(editorName).getElementsByTagName("link");    var iHead = '<html>\n<head>\n';    iHead += '<meta http-equiv="content-type" content="' + metaCnt + '" />\n';    var ttls = IBM_RTE_getDocument(editorName).getElementsByTagName("title");    if ((ttls) && ttls.length > 0) {        iHead += "<title>" + ttls[0].text + "</title>\n";    }    for (i = 0; (lnks) && (i < lnks.length); i++) {        iHead += "<link rel='" + lnks[0].rel + "' href='" + lnks[i].href + "' />\n";    }    iHead += "</head>\n";    if (bodyDir.localeCompare('ltr') == 0)        iHead += "<body dir='ltr'>\n";    else if (bodyDir.localeCompare('rtl') == 0)         iHead += "<body dir='rtl'>\n";    else        iHead += "<body>\n";    iHTML = IBM_RTE_getDocument(editorName).body.innerHTML;    iFoot = "</body>\n</html>";    iAll = iHead + iHTML + iFoot;    return iAll;}function IBM_RTE_getEditorHTMLFragment(editorName) {	if(IBM_RTE_getEditorMode(editorName) == 0){		if (IBM_RTE_isMozilla()){			var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");			var xxx=0;			while(a[xxx] != null)			{				if(a[xxx].getAttribute("odc")!=null&&a[xxx].getAttribute("odc") != ""){					a[xxx].setAttribute("href", a[xxx].getAttribute("odc"));					a[xxx].removeAttribute("odc", 0);					}				else					a[xxx].removeAttribute("odc", 0); 				xxx++;			}			/*			var img = IBM_RTE_getDocument(editorName).body.getElementsByTagName("img");			xxx=0;						while(img[xxx] != null){				if(img[xxx].getAttribute("odc")!=null&&img[xxx].getAttribute("odc")!= ""){					img[xxx].setAttribute("src",img[xxx].getAttribute("odc"));					img[xxx].removeAttribute("odc", 0);				}				else					img[xxx].removeAttribute("odc", 0);				xxx++;			}			*/	   }		else{			var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");			var xxx=0;			while(a[xxx] != null){				if(a[xxx].getAttribute("odc") != "" && a[xxx].getAttribute("odc") != null) {					a[xxx].setAttribute("href", a[xxx].getAttribute("odc"));					a[xxx].removeAttribute("odc");								}

⌨️ 快捷键说明

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