?? editor.js
字號:
catch(e){this.Document.body.appendChild(c);this.SelectOneEidtor();}
while(c&&c.firstChild){var node=c.removeChild(c.firstChild);c.parentNode.insertBefore(node,c);}
c.parentNode.removeChild(c);}
if(this.FullScreenPrompt){this.FullScreenPrompt=false;var sw=Global.GetClientWidth(this.Document);var nodes=this.Document.getElementsByTagName('*');for(var i=0,len=nodes.length;i<len;i++){if(nodes[i].offsetWidth>sw){this.EditorObj.SwitchToFullScreen();break;}}}},InsertContentIE:function(content){try{if(this.SelectRange.type=='None'){if(this.TextRange.parentElement().ownerDocument.body.className!='maxcode-userenters')
throw new Error('parent document');}
if((this.SelectRange.type=='Control'||this.TextRange.text!='')&&this.SelectRange.clear)
this.SelectRange.clear();this.TextRange.pasteHTML(content);this.TextRange.select();this.TextRange.collapse(false);}
catch(e){var c=this.Document.createElement('span');this.Document.body.appendChild(c);c.innerHTML=content;while(c.firstChild){var node=c.removeChild(c.firstChild);c.parentNode.insertBefore(node,c);}
c.parentNode.removeChild(c);this.SelectOneEidtor();}
this.GetRange();},InsertContentGecko:function(insertNode){var sel=this.SelectRange;var range=sel.getRangeAt(0);sel.removeAllRanges();range.deleteContents();var container=range.startContainer;var pos=range.startOffset;range=this.Document.createRange();if(container.nodeType==3&&insertNode.nodeType==3){container.insertData(pos,insertNode.nodeValue);range.setEnd(container,pos+insertNode.length);range.setStart(container,pos+insertNode.length);}
else{var afterNode;if(container.nodeType==3){var textNode=container;container=textNode.parentNode;var text=textNode.nodeValue;var textBefore=text.substr(0,pos);var textAfter=text.substr(pos);var beforeNode=this.Document.createTextNode(textBefore);afterNode=this.Document.createTextNode(textAfter);container.insertBefore(afterNode,textNode);container.insertBefore(insertNode,afterNode);container.insertBefore(beforeNode,insertNode);container.removeChild(textNode);}
else{afterNode=container.childNodes[pos];container.insertBefore(insertNode,afterNode);}
try{range.setEnd(afterNode,0);}catch(e){}
try{range.setStart(afterNode,0);}catch(e){}}
try{sel.addRange(range);range.collapse(false);this.Focus();}
catch(e){}},Menu:function(targetWindow,width,height,content,callback){var targetDocument=targetWindow.document;var menu=document.createElement('div');menu.style.position='absolute';width&&(menu.style.width=width+'px');height&&(menu.style.height=height+'px');CSS.AddClass(menu,'menu');if(typeof content=='string'){var link=targetDocument.createElement('a');link.href='#';link.onclick=function(){cEditor.setStyle('Bold')};link.appendChild(targetDocument.createTextNode(content));content=link;}
content&&menu.appendChild(content);targetDocument.body.appendChild(menu);var tempMouseDown=targetDocument.onmousedown||new Function();targetDocument.onmousedown=function(e){e=(e||targetWindow.event);var p=e.srcElement||e.target;if(p!=menu){while(p){if(p==menu){return;}
p=p.offsetParent;}}
menu.style.display='none';callback&&callback();};try{var tempMouseDownEditor=this.Document.onmousedown||new Function();this.Document.onmousedown=function(){tempMouseDownEditor();menu.style.display='none';callback&&callback();mouse_down();};}
catch(e){}
try{this.Document.addEventListener('mousedown',function(){menu.style.display='none';callback&&callback();},false);}
catch(e){}
var _parent=targetWindow.parent;function mouse_down(){menu.style.display='none';callback&&callback();_parent.Events.RemoveEvent(_parent.document,'mousedown',mouse_down);}
_parent.Events.AttachEvent(_parent.document,'mousedown',mouse_down);return menu;}};(function(){var Document=window.parent.document;cEditor.TextField=Document.getElementsByName(cEditor.Name)[0];cEditor._TextField=Document.getElementsByName('_'+cEditor.Name)[0];cEditor.EditorType=Document.getElementsByName(cEditor.Name+'Type')[0];cEditor.EditorObj.EditorWindow=window;cEditor.EditorObj.FrameEditor=cEditor;Events.AttachEvent(window,'focus',function(){cEditor.Focus();});})();var Toolbar={FullScreen:Url.QS()['FullScreen']=='1'?true:false,Resizable:Url.QS()['Resizable']=='1'?true:false,buttons:{},iconLoaded:false,iconsRoot:'images/',iconSrc:'editorSkin.png',iconWidth:20,iconHeight:20,yOffset:20,icons:{fontName:[1,0,100,'字體','字體'],fontSize:[1,110,60,'字號','字號'],bold:[1,240,0,'粗體',''],italic:[1,280,0,'斜體',''],underline:[1,320,0,'下劃線',''],foreColor:[1,360,0,'前景色',''],backColor:[1,400,0,'背景色',''],justifyLeft:[1,440,0,'左對齊',''],justifyCenter:[1,480,0,'居中對齊',''],justifyRight:[1,520,0,'右對齊',''],orderedList:[1,560,0,'有序列表',''],unorderedList:[1,600,0,'無序列表',''],indent:[1,680,0,'增加縮進',''],outdent:[1,640,0,'減少縮進',''],link:[1,720,0,'創(chuàng)建鏈接',''],unlink:[1,760,'取消鏈接',''],face:[1,'face.png',50,'表情','表情'],table:[1,800,0,'表格',''],code:[1,880,0,'代碼',''],hide:[1,920,0,'如果這是一個主題,點擊此按鈕可將選定內(nèi)容標(biāo)識為需要回復(fù)才可瀏覽',''],free:[1,1240,0,'如果是出售主題,使用本按鈕可以將選定內(nèi)容標(biāo)記為免費內(nèi)容,即無需購買就能查看',''],quote:[1,1200,0,'引用',''],fullScreen:[1,1120,50,'全屏','全屏']},regIcons:[],config:{enableHtmlEdit:true},fontNamePanel:null,fontSizePanel:null,colorPanel:null,colorNode:null,colorType:'',justifyPanel:null,listPanel:null,indentPanel:null,facePanel:null,faceNode:null,faceAbout:{faceList:{},width:24,height:24,defaultImg:'',path:'',lowpath:'',group:{}},tablePanel:null,fontNameList:['宋體','黑體','楷體_GB2312','隸書','幼圓','Arial','Arial Narrow','Arial Black','Comic Sans MS','Courier','System','Times New Roman'],fontSizeList:[{label:'極小',data:'1'},{label:'特小',data:'2'},{label:'小',data:'3'},{label:'中',data:'4'},{label:'大',data:'5'},{label:'特大',data:'6'},{label:'極大',data:'7'}],init:function(tb,sb){var self=this;if(Browser.IsIE56){var img=new Image();img.onload=function(){self.createHead(tb);self.displayRegIcon(tb);self.iconLoaded=true;cEditor.Resize();}
img.src=this.iconsRoot+this.iconSrc;}
else{this.createHead(tb);this.displayRegIcon(tb);}
this.createFoot(sb);},createHead:function(tb){this.createFontName(this,tb);this.createFontSize(this,tb);this.createBold(this,tb);this.createItalic(this,tb);this.createUnderline(this,tb);this.createForeColor(this,tb);this.createBackColor(this,tb);this.createJustifyLeft(this,tb);this.createJustifyCenter(this,tb);this.createJustifyRight(this,tb);this.createOrderedList(this,tb);this.createUnorderedList(this,tb);this.createOutdent(this,tb);this.createIndent(this,tb);this.createLink(this,tb);this.createUnlink(this,tb);var clear=CSS.AddClear(tb,CSS.LEFT);clear.style.height='5px';this.createTable(this,tb);this.createCode(this,tb);this.createFree(this,tb);this.createHide(this,tb);this.createQuote(this,tb);this.createFace(this,tb);this.createFullScreen(this,tb);},createFoot:function(sb){var wysiwyg=oNode.CreateNode('div');var curButton=wysiwyg;oNode.AddNode(wysiwyg,sb);CSS.AddClass(wysiwyg,'one focus');wysiwyg.innerHTML=Config.ButWysiwyg;this.wysiwygClick=wysiwyg.onclick=function(){if(curButton==wysiwyg)return;if(cEditor.ChangeState(Config.WYSIWYG)){CSS.RemoveClass(curButton,'focus');CSS.AddClass(wysiwyg,'focus');curButton=wysiwyg;}};var xhtml=oNode.CreateNode('div');oNode.AddNode(xhtml,sb);CSS.AddClass(xhtml,'two');xhtml.innerHTML=Config.ButXhtml;this.xhtmlClick=xhtml.onclick=function(){if(curButton==xhtml)return;if(cEditor.ChangeState(Config.XHTML)){CSS.RemoveClass(curButton,'focus');CSS.AddClass(xhtml,'focus');curButton=xhtml;}};var ubb=oNode.CreateNode('div');oNode.AddNode(ubb,sb);CSS.AddClass(ubb,'three');ubb.innerHTML=Config.ButUbb;this.ubbClick=ubb.onclick=function(){if(curButton==ubb)return;if(cEditor.ChangeState(Config.UBB)){CSS.RemoveClass(curButton,'focus');CSS.AddClass(ubb,'focus');curButton=ubb;}};this.wysiwygMode=function(){cEditor.Mode=Config.WYSIWYG;xhtml.style.display=ubb.style.display='none';};this.xhtmlMode=function(){cEditor.Mode=Config.XHTML;ubb.style.display='none';};this.ubbMode=function(){cEditor.Mode=Config.UBB;xhtml.style.display='none';CSS.ReplaceClass(ubb,'three','two');};if(this.Resizable){var add=oNode.CreateNode('a');oNode.AddNode(add,sb);CSS.AddClass(add,'add');add.href='javascript:;';add.onclick=function(){cEditor.AddHeight();};var minus=oNode.CreateNode('a');oNode.AddNode(minus,sb);CSS.AddClass(minus,'minus');minus.href='javascript:;';minus.onclick=function(){cEditor.MinusHeight();};this.setResizable=function(resizable){add.style.display=minus.style.display=resizable?'':'none';'';};}},createFontName:function(toolbar,div){if(!this.icons.fontName[0])return;var fontName=this.buttons.fontName=this.createIcon(div,'fontName');CSS.AddClass(fontName,'fontname');fontName.onclick=function(){if(cEditor.isXHTML())return;if(toolbar.fontNamePanel){document.body.removeChild(toolbar.fontNamePanel);}
var oDiv=oNode.CreateNode('div');oDiv.style.overflow='hidden';for(var i=0,len=toolbar.fontNameList.length;i<len;i++){var oA=oNode.CreateNode('a');oA.style.display='block';oA.style.width='100%';oA.style.color='#000';oA.style.padding='2px';oA.style.fontSize='12px';oA.style.textDecoration='none';oA.style.fontFamily=toolbar.fontNameList[i];oA.href='javascript:void(0)';oA.onclick=function(){if(cEditor.isWYSIWYG()){cEditor.SetStyle('FontName',this.innerHTML);toolbar.fontNamePanel.style.display='none';toolbar.response();}
else{cEditor.SetUBBStyle('[font='+this.innerHTML+']\x01[/font]');toolbar.fontNamePanel.style.display='none';}};oA.onmouseover=function(){CSS.ReplaceClass(this,'menu-item-out','menu-item-over');};oA.onmouseout=function(){CSS.ReplaceClass(this,'menu-item-over','menu-item-out');};oA.appendChild(document.createTextNode(toolbar.fontNameList[i]));oDiv.appendChild(oA);}
var newLine=oNode.CreateNode('div');newLine.style.clear='both';oDiv.appendChild(newLine);toolbar.fontNamePanel=cEditor.Menu(window,125,0,oDiv);toolbar.fontNamePanel.style.top=Global.GetOffsetTop(this)+this.offsetHeight+'px';toolbar.fontNamePanel.style.left=Global.GetOffsetLeft(this)+'px';};},createFontSize:function(toolbar,div){if(!this.icons.fontSize[0])return;var fontSize=this.buttons.fontSize=this.createIcon(div,'fontSize');CSS.AddClass(fontSize,'fontsize');fontSize.onclick=function(){if(cEditor.isXHTML())return;if(toolbar.fontSizePanel){document.body.removeChild(toolbar.fontSizePanel);}
var oDiv=oNode.CreateNode('div');oDiv.style.overflow='hidden';for(var i=0;i<toolbar.fontSizeList.length;i++){var oA=oNode.CreateNode('a');oA.style.display='block';oA.style.width='100%';oA.style.color='#000';oA.style.padding='2px';oA.style.textDecoration='none';oA.href='javascript:void(0);';oA.FontSize=toolbar.fontSizeList[i].data;oA.onclick=function(){if(cEditor.isWYSIWYG()){cEditor.SetStyle('FontSize',this.FontSize);toolbar.fontSizePanel.style.display='none';toolbar.response();}
else{cEditor.SetUBBStyle('[size='+this.FontSize+']\x01[/size]');toolbar.fontSizePanel.style.display='none';}};oA.onmouseover=function(){CSS.ReplaceClass(this,'menu-item-out','menu-item-over');};oA.onmouseout=function(){CSS.ReplaceClass(this,'menu-item-over','menu-item-out');};var oFont=oNode.CreateNode('font');oFont.size=toolbar.fontSizeList[i].data;oFont.appendChild(document.createTextNode(toolbar.fontSizeList[i].label));oA.appendChild(oFont);oDiv.appendChild(oA);}
toolbar.fontSizePanel=cEditor.Menu(window,120,0,oDiv);toolbar.fontSizePanel.style.top=Global.GetOffsetTop(this)+this.offsetHeight+'px';toolbar.fontSizePanel.style.left=Global.GetOffsetLeft(this)+'px';};},createBold:function(toolbar,div){if(!this.icons.bold[0])return;var bold=this.buttons.bold=this.createIcon(div,'bold');bold.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('Bold',false);toolbar.refreshState(this,'Bold');}
else{cEditor.SetUBBStyle('[b]\x01[/b]');}};},createItalic:function(toolbar,div){if(!this.icons.italic[0])return;var italic=this.buttons.italic=this.createIcon(div,'italic');italic.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('Italic',false);toolbar.refreshState(this,'Italic');}
else{cEditor.SetUBBStyle('[i]\x01[/i]');}};},createUnderline:function(toolbar,div){var underline=this.buttons.underline=this.createIcon(div,'underline');underline.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('Underline',false);toolbar.refreshState(this,'Underline');}
else{cEditor.SetUBBStyle('[u]\x01[/u]');}};},createForeColor:function(toolbar,div){var foreColor=this.buttons.foreColor=this.createIcon(div,'foreColor');foreColor.onclick=function(){if(cEditor.isXHTML())return;var type='ForeColor';if(toolbar.colorPanel){toolbar.colorPanel.parentNode.removeChild(toolbar.colorPanel);}
var oDiv=oNode.CreateNode('div');oDiv.appendChild(toolbar.colorList(type));toolbar.colorPanel=cEditor.Menu(window,0,0,oDiv);toolbar.colorPanel.style.top=Global.GetOffsetTop(this)+this.offsetHeight+'px';toolbar.colorPanel.style.left=Global.GetOffsetLeft(this)+'px';};},createBackColor:function(toolbar,div){var backColor=this.buttons.backColor=this.createIcon(div,'backColor');backColor.onclick=function(){if(cEditor.isXHTML())return;var type;if(Browser.IsIE){type='BackColor';}
else{type='HiliteColor';}
if(toolbar.colorPanel){toolbar.colorPanel.parentNode.removeChild(toolbar.colorPanel);}
var oDiv=oNode.CreateNode('div');oDiv.appendChild(toolbar.colorList(type));toolbar.colorPanel=cEditor.Menu(window,0,0,oDiv);toolbar.colorPanel.style.top=Global.GetOffsetTop(this)+this.offsetHeight+'px';toolbar.colorPanel.style.left=Global.GetOffsetLeft(this)+'px';};},createJustifyLeft:function(toolbar,div){if(!this.icons.justifyLeft[0])return;var justifyLeft=this.buttons.justifyLeft=this.createIcon(div,'justifyLeft');justifyLeft.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('JustifyLeft',false);if(!this.overState){toolbar.refreshState(this,'JustifyLeft');toolbar.changeState(toolbar.buttons.justifyCenter,false);toolbar.changeState(toolbar.buttons.justifyRight,false);}}
else{cEditor.SetUBBStyle('[align=left]\x01[/align]');}};},createJustifyCenter:function(toolbar,div){if(!this.icons.justifyCenter[0])return;var justifyCenter=this.buttons.justifyCenter=this.createIcon(div,'justifyCenter');justifyCenter.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('JustifyCenter',false);if(!this.overState){toolbar.refreshState(this,'JustifyCenter');toolbar.changeState(toolbar.buttons.justifyLeft,false);toolbar.changeState(toolbar.buttons.justifyRight,false);}}
else{cEditor.SetUBBStyle('[align=center]\x01[/align]');}};},createJustifyRight:function(toolbar,div){if(!this.icons.justifyRight[0])return;var justifyRight=this.buttons.justifyRight=this.createIcon(div,'justifyRight');justifyRight.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('JustifyRight',false);if(!this.overState){toolbar.refreshState(this,'JustifyRight');toolbar.changeState(toolbar.buttons.justifyLeft,false);toolbar.changeState(toolbar.buttons.justifyCenter,false);}}
else{cEditor.SetUBBStyle('[align=right]\x01[/align]');}};},createOrderedList:function(toolbar,div){if(!this.icons.orderedList[0])return;var orderedList=this.buttons.orderedList=this.createIcon(div,'orderedList');orderedList.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('InsertOrderedList',false);toolbar.refreshState(this,'InsertOrderedList');toolbar.changeState(toolbar.buttons.unorderedList,false);}
else{cEditor.SetUBBStyle('[list=1][*]\x01[/list]');}};},createUnorderedList:function(toolbar,div){if(!this.icons.unorderedList[0])return;var unorderedList=this.buttons.unorderedList=this.createIcon(div,'unorderedList');unorderedList.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('InsertUnorderedList',false);toolbar.refreshState(this,'InsertUnorderedList');toolbar.changeState(toolbar.buttons.orderedList,false);}
else{cEditor.SetUBBStyle('[list][*]\x01[/list]');}};},createIndent:function(toolbar,div){if(!this.icons.indent[0])return;var indent=this.buttons.indent=this.createIcon(div,'indent');indent.onclick=function(){if(cEditor.isXHTML())return;if(cEditor.isWYSIWYG()){cEditor.SetStyle('Indent',false);}
else{cEditor.SetUBBStyle('[indent]\x01[/indent]');}};},createOutdent:function(toolbar,div){if(!this.icons.outdent[0])return;var outdent=this.buttons.outdent=this.createIcon(div,'outdent');outdent.onclick=function(){if(!cEditor.isWYSIWYG())return;cEditor.SetStyle('Outdent',false);};},createLink:function(toolbar,div){if(!this.icons.link[0])return;var link=this.buttons.link=this.createIcon(div,'link');link.onclick=function(){if(cEditor.isXHTML())return;var id=Global.Random();var panel=PopUp.Panel(['<div class="editwin-head">',' <h3>插入鏈接</h3>','</div>','<div class="clearfix editwin-body editwin-hide">',' <p style="margin-top: 5px;">',' 鏈接地址:<input type="text" name="url_'+id+'" id="url_'+id+'" class="text" style="width:270px;" />',' </p>',' <p>',' 顯示文本:<input type="text" name="text_'+id+'" id="text_'+id+'" class="text" style="width:270px;" />',' </p>',' <p style="float:right">',' <span class="xbtn"><input type="button" value="確認" id="confirm_'+id+'" /></span>',' <span class="xbtn"><input type="button" value="取消" id="cancel_'+id+'" /></span>',' </p>','</div>'].join(''),200,100);CSS.AddClass(panel,'editwin');PopUp.AddPopUp(panel,true);panel.style.zIndex=10;panel.style.left=Global.GetOffsetLeft(this)-(Global.GetOffsetLeft(this)>panel.offsetWidth?panel.offsetWidth-this.offsetWidth:0)+'px';panel.style.top=Global.GetOffsetTop(this)+this.offsetHeight+'px';PopUp.HideModal(panel);$('confirm_'+id).onclick=function(){var url=$('url_'+id).value;var urlPatrn=/^[a-zA-Z]{1,10}:\/\/(.*?|\s*?)$/;if(!urlPatrn.exec(url)){url='http://'+url;} var text=$('text_'+id).value;PopUp.RemovePopUp(panel);if(cEditor.isWYSIWYG()){if(url){if(oNode.IsNode(node)&&node.tagName.toLowerCase()=='a'){node.href=url;node.innerHTML=(text==clearTag(_text)?_text:htmlentities(text));}
else{if(Browser.IsIE){cEditor.SelectRange.clear();cEditor.InsertContent('<a href="'+url+'">'+(text==clearTag(_text)?_text:htmlentities(text))+'</a>');}
else{var n=cEditor.Document.createElement('a');n.href=url;n.appendChild(text==clearTag(_text)?node:cEditor.Document.createTextNode(text));cEditor.InsertContentGecko(n);}}}}
else{url&&cEditor.SetUBBStyle('[url=\x02]\x01[/url]',url);}};$('cancel_'+id).onclick=function(){PopUp.RemovePopUp(panel);};if(cEditor.isWYSIWYG()){var _text=text=Browser.IsIE?cEditor.TextRange.htmlText:cEditor.SelectRange;var url='';var node=null;if(cEditor.TextRange&&cEditor.TextRange.parentElement){node=cEditor.TextRange.parentElement();if(node.tagName.toLowerCase()=='a'){url=node.getAttribute('href',2);_text=text=node.innerHTML;}
else{node=null;}}
else{var range=cEditor.SelectRange.getRangeAt(0);var snode=range.startContainer;var soff=range.startOffset;var enode=range.endContainer;var eoff=range.endOffset;var geta=function(node){while(node){if(oNode.IsNode(node)&&node.tagName.toLowerCase()=='a'){break;}
node=node.parentNode;}
return node;};var sa=geta(snode);var ea=geta(enode);if(sa==ea&&oNode.IsNode(sa)&&sa.tagName.toLowerCase()=='a'){node=sa;url=sa.getAttribute('href',2);_text=text=sa.innerHTML;}
else if(snode==enode&&soff+1==eoff&&snode.childNodes[soff].tagName.toLowerCase()=='a'){node=sa=snode.childNodes[soff];url=sa.getAttribute('href',2);_text=text=sa.innerHTML;}
else{node=range.cloneContents();}}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -