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

📄 simpleetsooeditor.js

📁 TurboCWCShop v1.6.7 is make in the Utility-LAYer Framework.
💻 JS
📖 第 1 页 / 共 5 页
字号:
				if(numNodeType==1||numNodeType==3){
					if(objTarget.nodeName=="BODY"||objTarget.nodeName=="BR")numCut=-1;
					if(objTarget.nodeName=="BODY"&&strText!="")numCut=0;
					if(numNodeType==3||numBrowser>100)numCut=(strText=="")?-1:0;
				}else{
					numCut=-1;
				}
			}
		}else{
			objTarget=objRange(0);
		}
		if(objTarget&&objTarget.style&&objTarget.style.position=="absolute")numAbsPos=1;
	}
	ETSOOEditor.ActiveTarget=objTarget;
	ETSOOEditor._SetButton("AbsolutePos",numAbsPos);
	ETSOOEditor._SetButton("Cut",numCut);
	ETSOOEditor._SetButton("Copy",numCut);
	ETSOOEditor._SetButton("Delete",numCut);
	ETSOOEditor._SetButton("Link",numCut);
	var strFont=ETSOOEditor._GetValue(objTarget,"FONT;","face",null,0);
	if(numBrowser<100&&!strFont)strFont=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontFamily",null,1);
	ETSOOEditor._SetButton("FontSet",strFont);
	var strSize=strSize=ETSOOEditor._GetValue(objTarget,"FONT;","size",null,0);
	if(numBrowser<100&&!strSize)strSize=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontSize",null,1);
	ETSOOEditor._SetButton("FontSize",strSize);
	if(ETSOOEditor.GetTarget(objTarget,"B")!=null||ETSOOEditor.GetTarget(objTarget,"STRONG")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontWeight","bold",1))numType=1;
	ETSOOEditor._SetButton("Bold",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"I")!=null||ETSOOEditor.GetTarget(objTarget,"EM")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontStyle","italic",1))numType=1;
	ETSOOEditor._SetButton("Italic",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"U")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","underline",1))numType=1;
	ETSOOEditor._SetButton("Underline",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"STRIKE")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","line-through",1))numType=1;
	ETSOOEditor._SetButton("StrikeThrough",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","left",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","left",1))numType=1;
	ETSOOEditor._SetButton("Left",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","center",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","center",1))numType=1;
	ETSOOEditor._SetButton("Center",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","right",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","right",1))numType=1;
	ETSOOEditor._SetButton("Right",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","justify",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","jusfity",1))numType=1;
	ETSOOEditor._SetButton("Full",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"OL")!=null)numType=1;
	ETSOOEditor._SetButton("OrderList",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"UL")!=null)numType=1;
	ETSOOEditor._SetButton("UnorderList",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"SUP")!=null)numType=1;
	ETSOOEditor._SetButton("SuperScript",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"SUB")!=null)numType=1;
	ETSOOEditor._SetButton("SubScript",numType);numType=0;
}

ETSOOEditor._GetValue=function(objTarget,strTagName,strProperty,strValue,numType){
	blnFind=false;
	var strOK='';
	while(objTarget){
		var strNodeName=objTarget.nodeName.toUpperCase();
		if(strNodeName=="BODY")break;
		if(strTagName.indexOf(strNodeName+";")!=-1){
			var strBaseValue;
			strOK+=strValue;
			if(numType==0)strBaseValue=objTarget.getAttribute(strProperty);
			else if(objTarget.style)strBaseValue=eval("objTarget.style."+strProperty);
			if(strBaseValue==null)strBaseValue="";
			strBaseValue=strBaseValue.toLowerCase();
			if(strValue==null){
				if(strBaseValue!=""){
					return strBaseValue;break;
				}
			}else if(strBaseValue.indexOf(strValue)!=-1){
				blnFind=true;break;
			}
		}
		objTarget=objTarget.parentNode;
	}
	return blnFind;
}

ETSOOEditor._SetButton=function(strId,numType){
	var objE=this.GetObj("EE"+strId);
	if(objE){
		if(strId=="FontSet"||strId=="FontSize"){
			var numLen=objE.length,blnSet=false;
			for(var numI=0;numI<numLen;numI++){
				var objOne=objE.options[numI];
				if(objOne.value==numType){
					objOne.selected=true;
					blnSet=true;
					break;
				}
			}
			if(!blnSet)objE.options[0].selected=true;
		}else{
			strId=strId.toUpperCase();
			this._SetButtonAdd(objE,strId,numType);
			var objNext=objE.nextSibling;
			if(objNext!=null&&objNext.id!="EEMore")objNext=null;
			if(objNext)this._SetButtonAdd(objNext,"MORE",numType);
		}
	}
}

ETSOOEditor._SetButtonAdd=function(objE,strId,numType){
	var strSrc=objE.src;
	objE.className="";
	if(numType>=0){
		if(strSrc.indexOf("disabled.gif")!=-1)objE.src=this.GetImgSrc(strId);
		if(numType==0)this.MouseOut(objE);
		else{
			this.MouseDown(objE);
			objE.className="Keep";
		}
	}else if(numType==-1){
		if(strSrc.indexOf("disabled.gif")==-1)objE.src=this.GetImgSrc(strId+"DISABLED");
		this.MouseOut(objE);
		objE.className="Disabled";
	}
}

ETSOOEditor.GetTarget=function(objE,strTagName){
	while(objE&&(objE.nodeName.toUpperCase()!=strTagName))objE=objE.parentNode;
	return objE;
}

ETSOOEditor._SetMode=function(objDocument,strValue){
	var blnIE5=(objDocument.body.contentEditable==null);
	var blnValue=(strValue=="on")?true:false;
	if(blnIE5)objDocument.designMode=strValue;
	else objDocument.body.contentEditable=blnValue;
	return blnIE5;
}

ETSOOEditor._GetCharset=function(){
	return (this.Browser>100)?document.defaultCharset:document.characterSet;
}

ETSOOEditor._SetShow=function(strId){
	var objShow=this.GetObj(strId+"_Show");
	if(objShow==null)return false;
	var objImg=this.GetObj(strId);
	var arrPos=ETSOOGetPos(objImg);
	var numLeft=arrPos[0]+4;
	var numTop=arrPos[1]+16;
	if(window.Node){
		numLeft-=1;
		numTop-=1;
	}
	var strBgColor=(strId=="EEForeColor")?"#000000":"#FFFFFF";
	with(objShow.style){
		backgroundColor=strBgColor;
		left=numLeft+"px";
		top=numTop+"px";
		display="block";
	}
}

ETSOOEditor._SetFieldContent=function(){
	var blnIE=(this.Browser>100);
	var blnIE5=(this.Browser==105);
	var blnHave=false;
	var blnActiveStatus=this.ActiveStatus;
	for(strField in this.Fields){
		if(!blnHave)blnHave=true;
		var objField=this.Fields[strField];
		if(this.ActiveField==null)this.ActiveField=objField;
		var strBaseContent=objField.Content;
		var objTextArea=objField.TextArea;
		if(objTextArea.value!="")strBaseContent=objTextArea.value;
		else objTextArea.value=strBaseContent;
		var objDiv=objField.Div;
		var numShowMode=objDiv.getAttribute("ShowMode");
		var objDocument=objField.FrameWindow.document;
		var numShowMargin=objField.Div.getAttribute("ShowMargin");
		var strPath=this.Path;
		if(blnIE)
		{
			objField.History=new this.History(objField);
			objField.History.Data[0]=strBaseContent;
			window.attachEvent("onbeforeunload",this._FrameOnBlur);
			objField.FrameDocument.attachEvent("onfocus",this._FrameOnFocus);
			var strCharset=this._GetCharset();
			var strBody='<html><head>';
			strBody+='<meta http-equiv="Content-Type" content="text/html; charset='+strCharset+'">';
			strBody+='<style>TD,OBJECT,EMBED,FORM{border:1px dotted #111111}';
			strBody+='A{padding-left:12px;background-image:url('+strPath+'Images/anchor_show.gif);background-repeat:no-repeat}</style>\n';
			if(!blnIE5){
				objField.FrameDocument.attachEvent("onblur",this._FrameOnBlur);
			}
			else{
				document.attachEvent("onmousedown",this._FrameOnBlur);
				window.attachEvent("onblur",this._FrameOnBlur);
			}
			strBody+='<style>\n';
			strBody+='v\\:* {behavior: url(#default#VML);}\n';
			strBody+='o\\:* {behavior: url(#default#VML);}\n';
			strBody+='.shape{behavior: url(#default#VML);}\n';
			strBody+='body,td{font-size:9pt}\n';
			strBody+='</style>\n';
			strBody+='<XML:NAMESPACE NS="urn:schemas-microsoft-com:vml" PREFIX="v"/>\n';
			strBody+='<base target="_blank"></head>\n';
			strBody+='<body onmousedown="return parent.ETSOOEditor._DocOnClick(event)" onkeydown="return parent.ETSOOEditor._DocOnKeyPress(event)"';
			strBody+=' onpaste="return parent.ETSOOEditor._DocOnPaste(event);" style="margin:'+(numShowMargin==0?0:12)+'px"';
			strBody+=' oncontextmenu="return parent.ETSOOEditor._DocOnContextMenu(event)" ondblclick="return parent.ETSOOEditor._DocOnDblClick(event)"';
			strBody+=' onmouseup="return parent.ETSOOEditor._DocMouseUp(event)"';
			if(blnActiveStatus)strBody+=' onkeyup="return parent.ETSOOEditor._DocOnSelectionChange(event)" onselectionchange="return parent.ETSOOEditor._DocOnSelectionChange(event)"';
			strBody+='>'+strBaseContent+'</body></html>';
			objDocument.open();
			objDocument.write(strBody);
			objDocument.close();
			objDocument.execCommand("LiveResize",false,true);
			objDocument.execCommand("2D-Position",false,true);
			objDocument.execCommand("MultipleSelection",false,true);
			this._SetMode(objDocument,"on");
		}else{
			window.addEventListener('unload',this._FrameOnBlur,true);
			objDocument.addEventListener('blur',this._FrameOnBlur,true);
			objDocument.addEventListener('focus',this._FrameOnFocus,true);
			objDocument.addEventListener('mousedown',this._DocOnClick,true);
			objDocument.addEventListener('keydown',this._DocOnKeyPress,true);
			objDocument.addEventListener('contextmenu',this._DocOnContextMenu ,true);
			objDocument.addEventListener('dblclick',this._DocOnDblClick,true);
			objDocument.addEventListener('mouseup',this._DocMouseUp,true);
			if(blnActiveStatus)objDocument.addEventListener('keyup',this._DocOnSelectionChange,true);
			var objBody=objDocument.body;
			var objHead=objDocument.createElement("head");
			objHead=objDocument.documentElement.insertBefore(objHead,objBody);
			var objStyle=objDocument.createElement("style");
			objStyle.innerHTML='TD,OBJECT,EMBED,FORM{border:1px dotted #111111};A{padding-left:12px;background-image:url('+strPath+'Images/anchor_show.gif);background-repeat:no-repeat}';
			objHead.appendChild(objStyle);
			objBody.bgColor="#FFFFFF";
			with(objBody.style)
			{
				margin=(numShowMargin==0?0:12)+"px";
				fontSize="9pt";
			}
			objBody.innerHTML=strBaseContent;
			objDocument.id=objField.FrameDocument.id;
			objDocument.designMode="on";
		}
		if(numShowMode==1||numShowMode==2){
			var objOneDiv=objDiv.getElementsByTagName("div")[0];
			ETSOOEditor.MouseDown(objOneDiv);
			this.MouseClick(objOneDiv,true);
		}
		objDiv.style.visibility="visible";
	}
	this._SetShow("EEForeColor");
	this._SetShow("EEBgColor");
	ETSOOPopup._SetAddEvent(window);
	if(blnIE&&!blnIE5){
		var objDiv=document.createElement("div");
		objDiv.id="ETSOOEditorTempleData";
		with(objDiv.style){
			visibility="hidden";
		}
		objDiv.setAttribute("contentEditable",true);
		document.body.insertAdjacentElement("beforeEnd",objDiv);
	}
	if(blnHave){
		this.ReadyState=1;
		if(blnIE){
			if(blnActiveStatus){
				this._SetButton("Redo",-1);
				this._SetButton("Undo",-1);
			}
			var numLen=document.forms.length;
			for(var numI=0;numI<numLen;numI++){
				var objForm=document.forms[numI];
				if(blnIE)objForm.attachEvent("onsubmit",this._FormOnSubmit);
				else objForm.addEventListener('submit',this._FormOnSubmit, true);
			}
		}
		if(!blnIE5&&blnActiveStatus)this._DocOnSelectionChange();
	}
}
if(ETSOOEditor.Browser>100)window.attachEvent("onload",function(){ETSOOEditor._SetFieldContent()});
else window.addEventListener("load",function(){ETSOOEditor._SetFieldContent()},false);

ETSOOEditor.Command=function(objActive,objE,objEvent){
	var strId=objE.id;
	var objDoc=objActive.FrameWindow.document;
	var blnCode=(objActive.Mode=="Code");
	if(strId.indexOf("EE")==0)strId=strId.substr(2);
	if(objE.className=="Keep"&&(strId=="Center"||strId=="Right"||strId=="Full"))strId="Left";
	var strPath=this.Path;
	var strWord="";
	var blnActiveStatus=this.ActiveStatus;
	switch(strId){
		case "Redo":
			if(this.Browser>100&&blnActiveStatus)objActive.History.Go(1);
			else objDoc.execCommand(CMD_REDO,UI_DEFAULT, null);
			break;
		case "Undo":
			if(this.Browser>100&&blnActiveStatus)objActive.History.Go(-1);
			else objDoc.execCommand(CMD_UNDO,UI_DEFAULT, null);
			break;
		case "FontSet":
			if(blnCode)strWord='<FONT FACE="'+objE.value+'">*</FONT>';
			else{
				var strFont=objE.value;
				if(strFont=="")strFont=null;
				objDoc.execCommand(CMD_FONTSET,UI_DEFAULT, strFont);
			}
			break;
		case "FontSize":
			if(blnCode)strWord='<FONT SIZE="'+objE.value+'">*</FONT>';
			else{
				var numSize=objE.value;
				if(numSize=="")numSize=null;
				objDoc.execCommand(CMD_FONTSIZE,UI_DEFAULT,numSize);
			}
			break;
		case "BgColor":
			var strColor=objE.nextSibling.style.backgroundColor;
			objDoc.execCommand(CMD_BGCOLOR,UI_DEFAULT,strColor);
			break;
		case "ForeColor":
			var strColor=objE.nextSibling.style.backgroundColor;
			objDoc.execCommand(CMD_FORECOLOR,UI_DEFAULT,strColor);
			break;
		default:
			strWord=null;

⌨️ 快捷键说明

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