📄 etsooeditor.js
字号:
}
//点击
ETSOOEditor.MouseClick=function(objE,_Add,objEvent){
if(objE.className=="Disabled"||(this.ReadyState==0&&_Add==null))return;
var objActive=this.ActiveField;
if(objActive==null)return;
var numBrowser=this.Browser;
var strId=objE.id;
if(objActive.Mode=="Preview"&&strId!="ToolDiv")return;
var objDoc=objActive.FrameWindow.document;
var strPath=this.Path;
switch(strId){
case "ToolDiv":
var strName=objE.getAttribute("name");
var strTarget=objE.getAttribute("Target");
var objFrame=document.getElementById("ETSOOEditorFrame_"+strTarget);
var objFrameWin=objActive.FrameWindow;
var objTextArea=objFrame.previousSibling;
var numHeight=parseInt(objTextArea.style.height);
switch(strName){
case "Design":
case "Code":
case "Preview":
var objField=this.Fields[strTarget];
var strBaseMode=objField.Mode;
if(_Add==null||_Add==true){
if(strBaseMode==strName)return;
this._FrameOnBlur();
if(strName=="Code"){
var numWidth=objFrame.clientWidth;
objFrame.style.display="none";
with(objTextArea.style){
display="block";
width=numWidth;
}
}else{
objTextArea.style.display="none";
objFrame.style.display="block";
if(strName=="Design"){
this._SetStyle(objFrameWin,false);
this._SetMode(objField.FrameWindow.document,"on");
}
else{
this._SetMode(objField.FrameWindow.document,"off");
this._SetStyle(objFrameWin,true);
}
}
var arrToolDivs=objField.Div.getElementsByTagName("div");
var numLen=arrToolDivs.length;
for(var numI=0;numI<numLen;numI++){
var objOne=arrToolDivs[numI];
if(objOne.getAttribute("Active")==1&&objOne.getAttribute("name")!=strName){
objOne.className="";this.MouseOut(objOne);break;
}
}
objField.Mode=strName;
this.ActiveField=objField;
}else this.MouseDown(objE);
break;
case "Increase":
case "Decrease":
if(strName=="Increase")numHeight+=100;
else if(numHeight>=200)numHeight-=100;
objTextArea.style.height=numHeight+"px";
objFrame.style.height=numHeight+"px";
break;
}
break;
case "EEMore":
var numLeft,numTop;
if(this.Browser<100){
var arrPos=ETSOOGetPos(objE);
numLeft=arrPos[0]-22;
numTop=arrPos[1]+objE.clientHeight+2;
}else{
numLeft=objEvent.clientX-objEvent.offsetX+document.body.scrollLeft-23;
numTop=objEvent.clientY+objE.clientHeight-objEvent.offsetY+document.body.scrollTop+1;
}
var strTarget=objE.getAttribute("target");
var numHeight=0,strContent='';
if(strTarget!="EEForeColor"&&strTarget!="EEBgColor"){
var strSubMenuTarget=objE.getAttribute("menutarget");
var objTarget=this.GetObj(strTarget);
var arrSubMenu=this.SubMenu[strSubMenuTarget];
if(strTarget==strSubMenuTarget)arrSubMenu=new Array(strTarget.substr(2),objTarget.title).concat(arrSubMenu);
else arrSubMenu=new Array(strSubMenuTarget.substr(2),objTarget.getAttribute("basetitle")).concat(arrSubMenu);
var arrMenus=this.GetSubMenu(arrSubMenu,strTarget);
strContent=arrMenus[0];
numHeight=arrMenus[1]*24+arrMenus[2]*6+4;
}
var objPopup=new ETSOOPopup(null,null,numHeight,numLeft,numTop,31,22);
objPopup.BgColor=objActive.BgColor;
objPopup.Skin=strPath+"Skins/"+objActive.Skin+"/Popup.css";
objPopup.Content=strContent;
objPopup.SourceObject=objE;
if(strContent==''){
var objNext=objE.previousSibling;
objPopup.Path=strPath;
objPopup.DefaultColor=objNext.style.backgroundColor;
objPopup.DoFunction="ETSOOEditor.SetColor";
objPopup.SourceId=strTarget;
objPopup.ShowColorPallette(this.OtherLangs[1],this.OtherLangs[2]);
}
else objPopup.Show();
break;
case "EENew":
if(confirm(this.OtherLangs[0])){
this.ActiveField.Reset();
}
break;
case "EEOpen":
break;
case "EEFind":
this.InsertObj("FIND");
break;
case "EESave":
break;
case "EEPasteText":
if(window.clipboardData){
strText=window.clipboardData.getData("Text");
if(strText==null)strText="";
this.InsertHTML(strText);
}else objDoc.execCommand(CMD_PASTE,UI_DEFAULT, null);
break;
case "EEPasteWord":
var strHtml=this._GetSavedHTML();
if(strHtml==null)objDoc.execCommand(CMD_PASTE,UI_DEFAULT, null);
else this._ClearAndInsertWordHtml(strHtml);
break;
case "EEEmotion":
this.InsertObj("FACE");
break;
case "EEFlash":
var objFlash=this.GetActive("OBJECT|EMBED",objE);
this.InsertObj("OBJECT",objFlash,"Flash");
break;
case "EEImage":
var objImage=this.GetActive("IMG",objE);
this.InsertObj("IMG",objImage);
break;
case "EEMedia":
var objMedia=this.GetActive("OBJECT|EMBED",objE);
this.InsertObj("OBJECT",objMedia,"Media");
break;
case "EEMarquee":
var objMarquee=this.GetActive("MARQUEE",objE);
this.InsertObj("MARQUEE",objMarquee);
break;
case "EESpecial":
this.InsertObj("SPECIAL");
break;
case "EETable":
case "EETableProperty":
var objTable=this.GetActive("TABLE",objE);
this.InsertObj("TABLE",objTable);
break;
case "EECellProperty":
var objTD=this.GetActive("TD",objE);
this.InsertObj("TD",objTD);
break;
case "EESplitCell":
var objTD=this.GetActive("TD",objE);
this.InsertObj("SPLITCELL",objTD);
break;
case "EEMergeCell":
EditorTableMergeCell();
break;
case "EEInsertRow":
EditorTableInsertRow();
break;
case "EEDeleteRow":
EditorTableInsertRow(1);
break;
case "EEInsertCol":
EditorTableInsertCol();
break;
case "EEDeleteCol":
EditorTableInsertCol(1);
break;
case "EEForm":
case "EEFormProperty":
var objForm=this.GetActive("FORM",objE);
this.InsertObj("FORM",objForm);
break;
case "EEFormFieldset":
this.InsertHTML('<fieldset style="padding: 2"><legend>'+this.Langs["FormFieldset"]+'</legend> </fieldset>');
break;
case "EEFormImage":
case "EEFormText":
case "EEFormFile":
case "EEFormCheckBox":
case "EEFormRadio":
case "EEFormButton":
var objFImage=this.GetActive("INPUT",objE);
this.InsertObj("INPUT",objFImage,strId);
break;
case "EEFormTextArea":
var objTextArea=this.GetActive("TEXTAREA",objE);
this.InsertObj("TEXTAREA",objTextArea);
break;
case "EEFormSelect":
var objSelect=this.GetActive("SELECT",objE);
this.InsertObj("SELECT",objSelect);
break;
case "EEFormLabel":
var objLabel=this.GetActive("LABEL",objE);
this.InsertObj("LABEL",objLabel);
break;
case "EEInsertFile":
var objIFrame=this.GetActive("IFRAME",objE);
this.InsertObj("IFRAME",objIFrame);
break;
case "EELayer":
this.InsertHTML('<div style="border:1px dotted #666666;padding:4px;background-color:#f3f3f3;width:98%;">'+this.OtherLangs[3]+'<br></div>');
break;
case "EETab":
this.InsertHTML(" ");
break;
case "EEAnchor":
this.InsertObj("ANCHOR");
break;
case "EELink":
case "EEAnchorLink":
case "EEEmailLink":
var objA=this.GetActive("A",objE);
this.InsertObj("A",objA,strId);
break;
case "EEImageLink":
this.InsertObj("IMAGELINK");
break;
case "EEUnlink":
objActive.FrameWindow.document.execCommand(CMD_UNLINK,UI_DEFAULT,null);
break;
case "EECalendar":
var dat1=new Date();
var strDate=(numBrowser<=105.5)?dat1.toLocaleString().split(" ")[0]:dat1.toLocaleDateString();
this.InsertHTML(strDate);
break;
case "EETime":
var dat1=new Date();
var strTime=(numBrowser<=105.5)?dat1.toLocaleString().split(" ")[1]:dat1.toLocaleTimeString();
this.InsertHTML(strTime);
break;
case "EEUpLevel":
objDoc.execCommand(CMD_BRING_FORWARD,UI_DEFAULT, null);
break;
case "EEDownLevel":
objDoc.execCommand(CMD_SEND_BACKWARD,UI_DEFAULT, null);
break;
case "EEFirstLevel":
objDoc.execCommand(CMD_BRING_TO_FRONT,UI_DEFAULT, null);
break;
case "EELastLevel":
objDoc.execCommand(CMD_SEND_TO_BACK,UI_DEFAULT, null);
break;
case "EEControlProperty":
this.InsertObj("CONTROL");
break;
case "EEArt":
this.InsertObj("ART");
break;
case "EEClearArt":
var objArt=this.GetWordArt();
this.ClearArt(objActive,objArt);
break;
case "EECssProperty":
this.InsertObj("CSS");
break;
case "EEAbout":
this.InsertObj("ABOUT");
break;
case "EEHelp":
this.InsertObj("HELP");
break;
default:
this.Command(objActive,objE,objEvent);
}
this._DocOnSelectionChange(objEvent);
}
//清除艺术字
ETSOOEditor.ClearArt=function(objField,objE){
if(objE)objE.removeNode(true);
var objDocument=objField.FrameWindow.document;
var objShapeTypes=objDocument.getElementsByTagName("shapetype");
var numLen=objShapeTypes.length;
for(var numI=0;numI<numLen;numI++){
var objShapeType=objShapeTypes[numI];
var strId=objShapeType.id;
if(!this.testShapeType(objDocument,strId,"shape")&&!this.testShapeType(objDocument,strId,"group")){
var objSpan=objShapeType.parentNode;
if(objSpan.nodeName=="SPAN")objShapeType=objSpan;
objShapeType.removeNode(true);
}
}
}
//是否启用ShapeType
ETSOOEditor.testShapeType=function(objDocument,strId,strTagName){
var objE=objDocument.getElementsByTagName(strTagName);
var blnHave=false;
var numLen=objE.length;
for(var numI=0;numI<numLen;numI++){
var objOne=objE[numI];
if(objOne.type=="#"+strId){
blnHave=true;
}
}
return blnHave;
}
//获得当前活动对象
ETSOOEditor.GetActive=function(strTagName,objSource){
var objE=null;
var objTarget=this.ActiveTarget;
if(objTarget){
if(strTagName=="TD"||strTagName=="TABLE"||strTagName=="FORM"||strTagName=="MARQUEE"||strTagName=="A")objTarget=this.GetTarget(objTarget,strTagName);
if(objTarget&&strTagName.indexOf(objTarget.nodeName)!=-1){
var objFirst=objSource.firstChild;
if(strTagName=="FORM"||(objFirst&&objFirst.id=="SubMenu"))objE=objTarget;
}
}
return objE;
}
//生成子菜单
ETSOOEditor.GetSubMenu=function(arrSubMenu,strTarget){
if(strTarget==null)strTarget="";
var strContent='';
var numLine=0;
var numSub=0
var numLen=arrSubMenu.length;
if(strTarget=="EEForm"||strTarget=="EETable"||strTarget=="EELink"){
var objActive=this.ActiveTarget;
if(objActive){
if(strTarget=="EELink"){
if(objActive.tagName!="IMG"&&numLen>6)numLen-=2;
}else{
var strTag=strTarget.substr(2).toUpperCase();
var objTemp=this.GetTarget(objActive,strTag);
if(objTemp==null)numLen=2;
}
}
}
for(var numI=0;numI<numLen;numI+=2){
var strName=arrSubMenu[numI];
if(strName=="NewLine"){
numLine++;
strContent+='<tr><td style="padding-top:2px;padding-bottom:2px"><table cellspacing="0" cellpadding="0" style="border-collapse: collapse" width="100%"><tr><td id="BreakLine"></td></tr></table></td></tr>';
}else{
var strInco=this.GetImgSrc(strName.toUpperCase());
var strLang=arrSubMenu[numI+1];
if(strLang==null)continue;
numSub++;
strContent+='<tr><td style="padding:2px" id="EE'+strName+'" target="'+strTarget+'" onmouseover="this.className=\'Hover\'" onmouseout="this.className=\'\'" onclick="parent.ETSOOEditor.MenuClick(this,null,event);" onselectstart="return false" title="'+strLang+'"><span id="SubMenu">';
strContent+='<img src="'+strInco+'" width="20" height="20" align="absmiddle"> '+strLang+'</span></td></tr>';
}
}
return [strContent,numSub,numLine];
}
//处理菜单事件
ETSOOEditor.MenuClick=function(objE,_Add,objEvent){
var strTarget=objE.getAttribute("target");
if(strTarget!=""&&strTarget!=null){
var strId=objE.id;
var objTarget=this.GetObj(strTarget);
objTarget.id=strId;
objTarget.title=objE.title;
objTarget.src=objE.getElementsByTagName("img")[0].src;
ETSOOPopup.ActiveOne.SourceObject.setAttribute("target",strId);
}
ETSOOPopup.HideFrame(1);
this.MouseClick(objE,_Add,objEvent);
}
//是否为艺术字
ETSOOEditor.GetWordArt=function(){
var objE=this.ActiveTarget;
var objArt=this.GetTarget(objE,"SHAPE");
if(objArt==null)objArt=this.GetTarget(objE,"GROUP");
if(objArt)if(objArt.textpath.string=="")objArt=null;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -