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

📄 editor.js

📁 学院公告发布系统 前台功能: 1.公告列表 2.浏览公告内容 后台基本功能: 1.添加公告 2.修改公告 3.删除公告(可批量删除) 4.密码修改(可修
💻 JS
📖 第 1 页 / 共 3 页
字号:
			  <area shape='rect' coords='3,30,29,54' onClick='EDiaryEditor.insertFace(\"011\");'>\
			  <area shape='rect' coords='246,4,272,28' onClick='EDiaryEditor.insertFace(\"010\");'>\
			  <area shape='rect' coords='219,4,245,28' onClick='EDiaryEditor.insertFace(\"009\");'>\
			  <area shape='rect' coords='192,4,218,28' onClick='EDiaryEditor.insertFace(\"008\");'>\
			  <area shape='rect' coords='165,4,191,28' onClick='EDiaryEditor.insertFace(\"007\");'>\
			  <area shape='rect' coords='138,4,164,28' onClick='EDiaryEditor.insertFace(\"006\");'>\
			  <area shape='rect' coords='111,4,137,28' onClick='EDiaryEditor.insertFace(\"005\");'>\
			  <area shape='rect' coords='84,4,110,28' onClick='EDiaryEditor.insertFace(\"004\");'>\
			  <area shape='rect' coords='57,4,83,28' onClick='EDiaryEditor.insertFace(\"003\");'>\
			  <area shape='rect' coords='30,4,56,28' onClick='EDiaryEditor.insertFace(\"002\");'>\
			  <area shape='rect' coords='3,4,29,28' onClick='EDiaryEditor.insertFace(\"001\");'>\
			</map>\
		</div>\
		";
		this.addHTML($("EDiaryEditorToolBar"), _toolbarStr8);

		var _toolbarStr9 = "<div style='position: absolute; left: 0px; top: 0px; width: 621px; background: url(editor/images/blank.gif); height: 69px; display: none;' id='EDiaryEditorToolBarMask'></div>";

		this.addHTML($("EDiaryEditorToolBar"), _toolbarStr9);	

		var _toolbarStr9 = "<div style='position: absolute; left: 483px; top: 41px; display: none;' id='EDiaryEditorRsave' title='恢复上一次未成功发表内容'><img src='images/editor/rsave.gif' csrc='/images/rsave.gif' bsrc='/images/rsave_over.gif' onmouseover='this.src=this.bsrc' onmouseout='this.src=this.csrc'></div>";
		this.addHTML($("EDiaryEditorToolBar"), _toolbarStr9);
		
		
		var _toolbarStr4 = "\
			<div style='position: absolute; width: 198px; height: 95px; top: 66px; left: 421px; display: none; background-image: url(images/editor/justifyformat_bg.gif);' id='EDiaryEditorJustifyFormatItem'>\
				<div style='float: left; margin-left: 12px; margin-top: 29px; width: 42px; height: 50px; cursor: pointer;' id='EDiaryEditorIMGLeft' unselectable='on'></div>\
				<div style='float: left; margin-left: 11px; margin-top: 29px; width: 42px; height: 50px; cursor: pointer;' id='EDiaryEditorIMGCenter' unselectable='on'></div>\
				<div style='float: left; margin-left: 24px; margin-top: 29px; width: 43px; height: 50px; cursor: pointer;' id='EDiaryEditorIMGRight' unselectable='on'></div>\
			</div>\
		";
		this.addHTML($("EDiaryEditorToolBar"), _toolbarStr4);

		var _toolBarHash = this.config.node;
		for(var key in _toolBarInfo) {
			_toolBarHash[_toolBarInfo[key]["n"]] = $("EDiaryEditor" + _toolBarInfo[key]["n"]);
		}
		this.iframe = $("editor_body_area");
		if(window._isIE) {
			this.iframe.addBehavior("#default#userData");
			// 恢复文章内容功能模块 
			function EDiaryEditorRsave() {
				try{
					if(readCookie("EDiaryEditor_RSave") == "false")return;
					var oPersist = _this.iframe;
					oPersist.load("EDiaryEditorRsave");
					var oData = oPersist.getAttribute("Edit");
					if(oData != null && oData != "" && Request("ReadCookie")==1) {
						if(confirm("您有一篇未完成的内容,是否确认恢复?")) {
							if(_this.iframe.style.display != "none") {// 设计模式
								_this.iframe.contentWindow.document.body.innerHTML = oData;
							}
							else {
								$("EDiaryEditorArea").value = oData;
							}
						}
						else{
							_this.delEditorRsave();
						}
							
					}
				}catch(e) {};
			}
			this.EDiaryEditorRsave = EDiaryEditorRsave;
			// 成功,删除保存的内容
			this.delEditorRsave = function () {
				writeCookie("EDiaryEditor_RSave", "false", 1);
				var oPersist = _this.iframe;
				oPersist.setAttribute("Edit", "");
				oPersist.save("EDiaryEditorRsave");
			}
			var delEditorRsave = this.delEditorRsave;
			if(readCookie("EDiaryEditor_RUser") == null || readCookie("EDiaryEditor_RUser") == "" || readCookie("EDiaryEditor_RUser") == "null") {
				writeCookie("EDiaryEditor_RUser", guid, 1000);
			}
			else if (readCookie("EDiaryEditor_RUser") != guid) {
				writeCookie("EDiaryEditor_RUser", "null", 1000);
				delEditorRsave();
			}
			// 定时保存文章正文内容
			this.iframe.addBehavior("#default#userData");
			setInterval(function () {
				if(readCookie("EDiaryEditor_RSave") == "false")return;
				if(_this.iframe.contentWindow.document.body.innerHTML.length > 5000) return;
				if(sState != "iframe")return;
				if(_this.iframe.style.display != "none") {// 设计模式
					if(_this.iframe.contentWindow.document.body.innerHTML.toLowerCase() == "<div>&nbsp;</div>") return;
					if(_this.iframe.contentWindow.document.body.innerHTML.toLowerCase() == "<div></div>") return;
					if(_this.iframe.contentWindow.document.body.innerHTML.toLowerCase() == "<p>&nbsp;</p>") return;
					if(_this.iframe.contentWindow.document.body.innerHTML.toLowerCase() == "<p></p>") return;
					var oPersist = _this.iframe;
					oPersist.setAttribute("Edit",_this.iframe.contentWindow.document.body.innerHTML);
					oPersist.save("EDiaryEditorRsave");
				}
				else {// 代码模式
					if($("editor_body_textarea").value.toLowerCase() == "<div>&nbsp;</div>") return;
					if($("editor_body_textarea").value.toLowerCase() == "<div></div>") return;
					if($("editor_body_textarea").value.toLowerCase() == "<p>&nbsp;</p>") return;
					if($("editor_body_textarea").value.toLowerCase() == "<p></p>") return;
					
					var oPersist = _this.iframe;
					oPersist.setAttribute("Edit",$("editor_body_textarea").value);
					oPersist.save("EDiaryEditorRsave");
				}
			}, 2000);
		}else{
			this.delEditorRsave = this.EDiaryEditorRsave = function(){}
			}
	},
	initControl: function (bWordMode, sContent) {
		var _this = this;
		
		var FontMenuFuncHash = {
			menulist: {
				Family: {obj: $("EDiaryEditorFontFamilyItem")},
				Size: {obj: $("EDiaryEditorFontSizeItem")},
				Style: {obj: $("EDiaryEditorFontStyleItem")},
				Justify: {obj: $("EDiaryEditorJustifyFormatItem")},
				FColor: {obj: $("EDiaryEditorforecolorItem")},
				HColor: {obj: $("EDiaryEditorhilitecolorItem")},
				FaceBG: {obj: $("EDiaryEditorfaceItem")}
			},
			click: function (el, _tthis) {
				var node;
				var event = window.event || el;
				var esrc = event.srcElement || event.target;
				for(var key in _tthis.menulist) {
					node = _tthis.menulist[key];
					if(esrc.getAttribute("action") == key) {
						if(key == "Justify") {
							if(!window._isIE) {
								var oSelection = _this.iframe.contentWindow.getSelection();
							}
							else {
								var oSelection = _this.iframe.contentWindow.document.selection.createRange();
							}
							var sRangeType = _this.getElement();
							if (sRangeType.tagName.toLowerCase() != "img"){
								alert('请选中图片后操作!')
							return;
							}
						}
						if(node["obj"].style.display == "") {
							node["obj"].style.display = "none";
						}
						else {
							node["obj"].style.display = "";
						}
					}
					else {
						node["obj"].style.display = "none";
					}
				}
			},
			hide: function (event, _this) {
				var node;
				for(var key in _this.menulist) {
					node = _this.menulist[key];
					node["obj"].style.display = "none";
				};
			}
		};
		/////////////////////////////////////////////////////////////////////////

		function hiddenDialog(event, Act) {
			if(Act == "img") {
				//$("EDiaryEditorIMGDialog").style.display = "none";
				//$("EDiaryEditorDialog").style.display = "none";
			}
		}
		function viewDialog(el, Act) {
			var event = window.event || el;
			var win;
			if(window._isIE) {			
				window.showModalDialog("editor/"+Act+".htm", window, "dialogWidth: 400px; dialogHeight: 200px; help: no; scroll: no; status: no");
			}else {
				win = window.open("editor/"+Act+".htm", null, "Width=400,Height=200,left="+(window.screen.availWidth-400)/2+",top="+(window.screen.availHeight-200)/2+"");
				win.dialogArguments = window;
			}

		}
		function addIMG(event, Act) {
				var html = "<img src='" + $("EDiaryEditorIMGInput").value + "'>";
				if (_this.iframe.contentWindow.document.selection.type.toLowerCase() != "none"){
					_this.iframe.contentWindow.document.selection.clear() ;
				}
				_this.iframe.contentWindow.focus();
				var oRng = _this.iframe.contentWindow.document.selection.createRange();
				oRng.pasteHTML(html);
				oRng.collapse(false);
				oRng.select();
				hiddenDialog(event, Act);
		}

		////////////////////////////////////////////////////////////
		// 需要优化
        function eventObserver(){
            var es =_this.iframe.contentWindow.document.body.keyupEvents;
				/* 字体预设
                if(es.fontsize){
                    reaplceFontName("fontsize",es.fontsize)
                }
				*/
                if(es.fontname){
                    reaplceFontName("fontname",es.fontname)
                }
        }
        function formatFont(what, v){
            var idocument= _this.iframe.contentWindow.document;

            if(window._isIE) {
				if(v == "楷体" && !window._isVista) {
					v = "楷体_GB2312";
				}
                idocument.execCommand("fontname", "", "EDiaryEditor_Temp_FontName");
                 if(!idocument.body.keyupEvents)
                    idocument.body.keyupEvents=new Array();
                 if( idocument.selection.type!="Text"){
                     idocument.body.keyupEvents[what]=v;
                     idocument.body.onkeyup=eventObserver;
                 }else{
                     reaplceFontName(what,v);
                 }
            }
			else {
				switch(what){
					case "fontname":
						_this.iframe.contentWindow.document.execCommand("fontname", "", v);
						break;
					case "fontsize":
						v = parseInt(v) / 6;
						_this.iframe.contentWindow.document.execCommand("fontsize", "", v);
						break;
					default:
						break;
				}
			}
		}
        function reaplceFontName(what,v){
            var idocument=_this.iframe.contentWindow.document;
            var es=idocument.body.keyupEvents;
            var a_Font = idocument.body.getElementsByTagName("font");
                  for (var i = 0; i < a_Font.length; i++){
                        var o_Font = a_Font[i];
                        if (o_Font.getAttribute("face") == "EDiaryEditor_Temp_FontName"){
                             delInFont(o_Font, what);
                             setStyleValue(o_Font, what, v);
                            es[what]=null;
                            if(!es.fontsize && !es.fontname)
                                 o_Font.removeAttribute("face");
                       }
                 }
         }
        function delInFont(obj, what){
			var o_Children = obj.children;
			for (var j = 0; j < o_Children.length; j++){
				setStyleValue(o_Children[j], what, "");
				delInFont(o_Children[j], what);

				if (o_Children[j].style.cssText == ""){
					if ((o_Children[j].tagName == "FONT") || (o_Children[j].tagName == "SPAN")){
						o_Children[j].outerHTML = o_Children[j].innerHTML;
					}
				}
			}
		}
		function setStyleValue(obj, what, v){
			switch(what){
				case "fontname":
					obj.style.fontFamily = v;
					break;
				case "fontsize":
					obj.style.fontSize = v;
					break;
				default:
					break;
			}
		}
		////////////////////////////////////////////////////////
		function setMenuFunc(node) {
			node.onclick = function () {
				if(this.getAttribute("action") == "family") {
					formatFont("fontname", this.getAttribute("value"));
				}
				if(this.getAttribute("action") == "size") {
					formatFont("fontsize", this.getAttribute("value"));
				}
				if(this.getAttribute("action") == "style") {
					_this.runCMD("formatblock", "<" + this.getAttribute("value") + ">");
						
				}
			}
			node.onmouseover = function () {
				this.style.border = "solid #f90 1px";
				this.style.background = "#fff";
			}
			node.onmouseout = function () {
				this.style.border = "solid #ccc 1px";
				this.style.background = "#f4f4f4";
			}
		}
		var nDiv = $("EDiaryEditorFontFamilyBox").getElementsByTagName("div");
		for(var i = 0; i < nDiv.length; i ++) {
			setMenuFunc(nDiv[i]);
		}
		
		var nDiv = $("EDiaryEditorFontSizeBox").getElementsByTagName("div");
		for(var i = 0; i < nDiv.length; i ++) {
			setMenuFunc(nDiv[i]);
		}
		
		var nDiv = $("EDiaryEditorFontStyleBox").getElementsByTagName("div");
		for(var i = 0; i < nDiv.length; i ++) {
			setMenuFunc(nDiv[i]);
		}
		function formatIMG(el, Act) {
			var event = window.event || el;
			if(window.Event) {

⌨️ 快捷键说明

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