xheditor.js
上传用户:jiajie98
上传日期:2020-04-24
资源大小:1206k
文件大小:47k
源码类别:

网格计算

开发平台:

PHP

  1. /*
  2.  * xhEditor - WYSIWYG XHTML Editor
  3.  * @requires jQuery v1.4.1
  4.  * 
  5.  * @author Yanis.Wang<yanis.wang@gmail.com>
  6.  * @site http://xheditor.com/
  7.  * @licence LGPL(http://www.opensource.org/licenses/lgpl-license.php)
  8.  * 
  9.  * @Version: 1.0.0 beta2 build 100207
  10.  */
  11. (function(i){i.fn.xheditor=function(E,F){return this.each(function(){if(this.tagName.toLowerCase()!="textarea"){return}if(E){if(!this.objxhe){var G=i(this).attr("xheditor");if(G){try{G=eval("("+G+")")}catch(H){}F=i.extend({},G,F)}var I=new i.xheditor(this,F);if(I.init()){this.objxhe=I}else{I=null}}}else{if(this.objxhe){this.objxhe.remove();this.objxhe=null}}})};var k=0,l=i.browser.version,s=i.browser.msie,n=i.browser.mozilla,C=i.browser.safari,t=false,m=true;var e,A,q,j;var c;i("script[src*=xheditor]").each(function(){var E=this.src;if(E.match(/xheditor[^/]*.js/i)){c=E.replace(/[?#].*$/,"").replace(/(^|[/\])[^/]*$/,"$1");return false}});var B={27:"esc",9:"tab",32:"space",13:"enter",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"};var o=["#FFFFFF","#CCCCCC","#C0C0C0","#999999","#666666","#333333","#000000","#FFCCCC","#FF6666","#FF0000","#CC0000","#990000","#660000","#330000","#FFCC99","#FF9966","#FF9900","#FF6600","#CC6600","#993300","#663300","#FFFF99","#FFFF66","#FFCC66","#FFCC33","#CC9933","#996633","#663333","#FFFFCC","#FFFF33","#FFFF00","#FFCC00","#999900","#666600","#333300","#99FF99","#66FF99","#33FF33","#33CC00","#009900","#006600","#003300","#99FFFF","#33FFFF","#66CCCC","#00CCCC","#339999","#336666","#003333","#CCFFFF","#66FFFF","#33CCFF","#3366FF","#3333FF","#000099","#000066","#CCCCFF","#9999FF","#6666CC","#6633FF","#6600CC","#333399","#330099","#FFCCFF","#FF99FF","#CC66CC","#CC33CC","#993399","#663366","#330033"];var z=[{n:"p",t:"普通段落"},{n:"h1",t:"标题1"},{n:"h2",t:"标题2"},{n:"h3",t:"标题3"},{n:"h4",t:"标题4"},{n:"h5",t:"标题5"},{n:"h6",t:"标题6"},{n:"pre",t:"已编排格式"},{n:"address",t:"地址"}];var d=[{n:"宋体",c:"SimSun"},{n:"仿宋体",c:"FangSong_GB2312"},{n:"黑体",c:"SimHei"},{n:"楷体",c:"KaiTi_GB2312"},{n:"微软雅黑",c:"Microsoft YaHei"},{n:"Arial"},{n:"Arial Narrow"},{n:"Arial Black"},{n:"Comic Sans MS"},{n:"Courier New"},{n:"System"},{n:"Times New Roman"},{n:"Tahoma"},{n:"Verdana"}];var w=[{n:"xx-small",wkn:"x-small",s:"8pt",t:"极小"},{n:"x-small",wkn:"small",s:"10pt",t:"特小"},{n:"small",wkn:"medium",s:"12pt",t:"小"},{n:"medium",wkn:"large",s:"14pt",t:"中"},{n:"large",wkn:"x-large",s:"18pt",t:"大"},{n:"x-large",wkn:"xx-large",s:"24pt",t:"特大"},{n:"xx-large",wkn:"-webkit-xxx-large",s:"36pt",t:"极大"}];var f=[{s:"左对齐",v:"justifyleft",t:"左对齐"},{s:"居中",v:"justifycenter",t:"居中"},{s:"右对齐",v:"justifyright",t:"右对齐"},{s:"两端对齐",v:"justifyfull",t:"两端对齐"}],g=[{s:"数字列表",v:"insertOrderedList",t:"数字列表"},{s:"符号列表",v:"insertUnorderedList",t:"符号列表"}];var a='<div>使用键盘快捷键(Ctrl+V)把内容粘贴到方框里,按 确定</div><div><textarea id="xhePastetextValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var b='<div>链接地址: <input type="text" id="xheLinkHref" value="http://" class="xheText" /></div><div>打开方式: <select id="xheLinkTarget"><option selected="selected" value="">默认</option><option value="_blank">新窗口</option><option value="_self">当前窗口</option><option value="_parent">父窗口</option></select></div><div style="display:none">链接文字: <input type="text" id="xheLinkText" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var y='<div>图片文件: <input type="text" id="xheImgSrc" value="http://" class="xheText" /></div><div>替换文本: <input type="text" id="xheImgAlt" /></div><div>对齐方式: <select id="xheImgAlign"><option selected="selected" value="">默认</option><option value="left">左对齐</option><option value="right">右对齐</option><option value="top">顶端</option><option value="middle">居中</option><option value="baseline">基线</option><option value="bottom">底边</option></select></div><div>宽度高度: <input type="text" id="xheImgWidth" style="width:40px;" /> x <input type="text" id="xheImgHeight" style="width:40px;" /></div><div>边框大小: <input type="text" id="xheImgBorder" style="width:40px;" /></div><div>水平间距: <input type="text" id="xheImgHspace" style="width:40px;" /> 垂直间距: <input type="text" id="xheImgVspace" style="width:40px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var D='<div>动画文件: <input type="text" id="xheFlashSrc" value="http://" class="xheText" /></div><div>宽度高度: <input type="text" id="xheFlashWidth" style="width:40px;" value="480" /> x <input type="text" id="xheFlashHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var x='<div>媒体文件: <input type="text" id="xheMediaSrc" value="http://" class="xheText" /></div><div>宽度高度: <input type="text" id="xheMediaWidth" style="width:40px;" value="480" /> x <input type="text" id="xheMediaHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var h='<div>行数列数: <input type="text" id="xheTableRows" style="width:40px;" value="3" /> x <input type="text" id="xheTableColumns" style="width:40px;" value="2" /></div><div>标题单元: <select id="xheTableHeaders"><option selected="selected" value="">无</option><option value="row">第一行</option><option value="col">第一列</option><option value="both">第一行和第一列</option></select></div><div>宽度高度: <input type="text" id="xheTableWidth" style="width:40px;" value="200" /> x <input type="text" id="xheTableHeight" style="width:40px;" value="" /></div><div>边框大小: <input type="text" id="xheTableBorder" style="width:40px;" value="1" /></div><div>表格间距: <input type="text" id="xheTableCellSpacing" style="width:40px;" value="1" /> 表格填充: <input type="text" id="xheTableCellPadding" style="width:40px;" value="1" /></div><div>对齐方式: <select id="xheTableAlign"><option selected="selected" value="">默认</option><option value="left">左对齐</option><option value="center">居中</option><option value="right">右对齐</option></select></div><div>表格标题: <input type="text" id="xheTableCaption" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';var r='<div style="width:200px;word-wrap:break-word;word-break:break-all;"><p><span style="font-size:20px;color:#1997DF;">xhEditor</span><br />v1.0.0 beta2 build 100207</p><p>xhEditor是一个基于jQuery开发的跨平台开源迷你XHTML编辑器组件。</p><p><a href="http://xheditor.com/" target="_blank">http://xheditor.com/</a></p></div>';var p={"default":{name:"默认",width:25,height:18,line:6,list:{biggrin:"Big grin",smile:"Smile",titter:"Titter",lol:"Lol",call:"Call",victory:"Victory",shy:"Shy",handshake:"Handshake",kiss:"Kiss",sad:"Sad",cry:"Cry",huffy:"Huffy",mad:"Mad",tongue:"Tongue",sweat:"Sweat",shocked:"Shocked",time:"Time",hug:"Hug"}}};var v={GStart:{},GEnd:{},Separator:{},Cut:{t:"剪切 (Ctrl+X)"},Copy:{t:"复制 (Ctrl+C)"},Paste:{t:"粘贴 (Ctrl+V)"},Pastetext:{t:"粘贴文本"},Blocktag:{t:"段落标签"},Fontface:{t:"字体"},FontSize:{t:"字号"},Bold:{t:"加粗 (Ctrl+B)",s:"Ctrl+B"},Italic:{t:"斜体 (Ctrl+I)",s:"Ctrl+I"},Underline:{t:"下划线 (Ctrl+U)",s:"Ctrl+U"},Strikethrough:{t:"中划线 (Ctrl+S)",s:"Ctrl+S"},FontColor:{t:"字体颜色"},BackColor:{t:"背景颜色"},Removeformat:{t:"删除文字格式"},Align:{t:"对齐"},List:{t:"列表"},Outdent:{t:"减少缩进 (Shift+Tab)",s:"Shift+Tab"},Indent:{t:"增加缩进 (Tab)",s:"Tab"},Link:{t:"超链接"},Unlink:{t:"取消超链接"},Img:{t:"图片"},Flash:{t:"Flash动画"},Media:{t:"多媒体文件"},Emot:{t:"表情"},Table:{t:"表格"},Source:{t:"源代码"},Preview:{t:"预览"},Fullscreen:{t:"全屏编辑 (Esc)",s:"Esc"},About:{t:"关于 xhEditor"}};var u={mini:"GStart,Bold,Italic,Underline,Strikethrough,GEnd,Separator,GStart,Align,List,GEnd,Separator,GStart,Link,Img,About,GEnd",simple:"GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Img,Emot,About,GEnd",full:"GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Removeformat,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Unlink,Img,Flash,Media,Table,GEnd,Separator,GStart,Source,Preview,Fullscreen,About,GEnd"};i.xheditor=function(M,Z){var ag={skin:"default",tools:"full",clickCancelDialog:true,linkTag:false,internalScript:false,inlineScript:false,internalStyle:true,inlineStyle:true,showBlocktag:false,forcePtag:true,upLinkExt:"zip,rar,txt",upImgExt:"jpg,jpeg,gif,png",upFlashExt:"swf",upMediaExt:"wmv,avi,wma,mp3,mid",modalWidth:350,modalHeight:220,modalTitle:true,defLinkText:"点击打开链接",layerShadow:3,emotMark:false,upBtnText:"上传",wordDeepClean:true};var F=this,ac=M,V=i(ac),ad=V.closest("form"),Q,ab,al,E,O,T,Y;var G;var am=false,N=false,K=false,H=false,W=false,an=false,R="",ak;var af=0;this.settings=i.extend({},ag,Z);if(F.settings.plugins){v=i.extend({},v,F.settings.plugins)}if(F.settings.tools.match(/^s*(mini|simple|full)s*$/i)){F.settings.tools=i.trim(F.settings.tools);F.settings.tools=u[F.settings.tools]}if(!F.settings.tools.match(/(^|,)s*Abouts*(,|$)/i)){F.settings.tools+=",About"}F.settings.tools=F.settings.tools.split(",");c=S(c,"abs");var ae="xheCSS_"+F.settings.skin,ah="xhe"+k+"_container",I="xhe"+k+"_Tool",J="xhe"+k+"_iframearea",L="xhe"+k+"_iframe";var P="",ao=c+"xheditor_skin/"+F.settings.skin+"/",ai=p,U=S(c,"rel")+"xheditor_emot/",aj="";ai=i.extend({},ai,F.settings.emots);an=F.settings.showBlocktag;if(an){P+=" showBlocktag"}var X=[];this.init=function(){if(i("#"+ae).length==0){i("head").append('<link id="'+ae+'" rel="stylesheet" type="text/css" href="'+ao+'ui.css" />')}var at=F.settings.width||ac.style.width||V.outerWidth();af=F.settings.height||V.outerHeight();if(/^[0-9.]+$/i.test(""+at)){at+="px"}var ar="",ax,az;i.each(F.settings.tools,function(aA,aB){ax=v[aB];if(aB=="GStart"){ar+='<span class="xheGStart"/>'}else{if(aB=="GEnd"){ar+='<span class="xheGEnd"/>'}else{if(aB=="Separator"){ar+='<span class="xheSeparator"/>'}else{if(aB=="BtnBr"){ar+="<br />"}else{if(ax.c){az=ax.c}else{az="xheIcon xheBtn"+aB}ar+='<span><a href="javascript:void(0);" title="'+ax.t+'" name="'+aB+'" class="xheButton xheEnabled"><span class="'+az+'" /></a></span>';if(ax.s){F.addShortcuts(ax.s,aB)}}}}}});ar+="<br />";V.after(i('<span id="'+ah+'" class="xhe_'+F.settings.skin+'" style="display:none"><table cellspacing="0" cellpadding="0" class="xheLayout" style="width:'+at+";height:"+af+'px;"><tbody><tr><td id="'+I+'" class="xheTool" style="height:1px;"></td></tr><tr><td id="'+J+'" class="xheIframeArea"><iframe frameborder="0" id="'+L+'" src="" style="width:100%;"></iframe></td></tr></tbody></table></span>'));Q=i("#"+I);ab=i("#"+J);var au='<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><link rel="stylesheet" href="'+ao+'iframe.css"/>';if(F.settings.loadCSS){var aq=F.settings.loadCSS;if(aa(aq,"array")){for(var av in aq){au+='<link rel="stylesheet" href="'+aq[av]+'"/>'}}else{au+='<link rel="stylesheet" href="'+aq+'"/>'}}au+='</head><body spellcheck="false" dir="ltr" class="editMode'+P+'"></body></html>';al=i("#"+L)[0].contentWindow;E=i(al);try{O=al.document;T=i(O);O.open();O.write(au);O.close();if(s){O.body.contentEditable="true"}else{O.designMode="On"}}catch(ay){}setTimeout(F.setOpts,300);F.setSource();al.setInterval=null;Q.append(ar);Q.find(".xheButton").click(function(aB){F.hidePanel();F.focus();ak=aB;var aA=i(this);if(aA.is(".xheEnabled")){F.exec(aA.attr("name"))}return false}).mousedown(function(){return false});e=i("#xhePanel");A=i("#xheShadow");q=i("#xheCntLine");if(e.length==0){e=i('<div id="xhePanel"></div>').mousedown(function(aA){aA.stopPropagation()});A=i('<div id="xheShadow"></div>');q=i('<div id="xheCntLine"><img src="'+ao+'img/spacer.gif" /></div>');i(document.body).append(e).append(A).append(q)}i(document).mousedown(F.clickCancelPanel);T.mousedown(F.clickCancelPanel);if(s){T.bind("beforedeactivate",function(){if(s&&!N){G=F.getRng()}});E.focus(function(){if(s&&!N&&G){G.select();G=null}})}Y=i('<iframe class="xheHideArea" />').appendTo("body");i("#"+ah).show();ab.css("height",af-Q.outerHeight());V.hide();V.focus(F.focus);ad.submit(F.getSource).bind("reset",F.setSource);var ap=i(window);ap.unload(F.saveUnload).bind("beforeunload",F.saveUnload);ap.resize(F.fixFullHeight);E.focus(function(){if(F.settings.focus){F.settings.focus()}}).blur(function(){if(F.settings.blur){F.settings.blur()}});if(C){E.click(F.fixAppleSel)}T.keydown(F.checkShortcuts).keydown(F.forcePtag);i("body",T).bind("paste",F.cleanPaste);var aw=F.settings.shortcuts;if(aw){i.each(aw,function(aA,aB){F.addShortcuts(aA,aB)})}k++;am=true;if(F.settings.fullscreen){F.toggleFullscreen()}if(F.settings.readonly){F.toggleReadonly(true)}else{if(F.settings.sourceMode){setTimeout(F.toggleSource,20)}}return true};this.remove=function(){V.unbind("focus",F.focus);ad.unbind("submit",F.getSource).unbind("reset",F.setSource);var ap=i(window);ap.unbind("unload",F.saveUnload).unbind("beforeunload",F.saveUnload);ap.unbind("resize",F.fixFullHeight);i("#"+ah).remove();V.show();am=false};this.saveUnload=function(){F.getSource()};this.cleanPaste=function(){if(s&&!N){var aq,ap=Y[0].contentWindow.document.body;ap.innerHTML="";ap.createTextRange().execCommand("Paste");aq=ap.innerHTML;if(aq.indexOf("&nbsp;")==0){aq=aq.substring(6)}aq=F.cleanWord(aq);aq=F.cleanHTML(aq);F.pasteHTML(aq);return false}};this.setCSS=function(ap){try{F._exec("styleWithCSS",ap)}catch(aq){try{F._exec("useCSS",!ap)}catch(aq){}}};this.setOpts=function(){if(am&&!K&&!N){F.setCSS(false);try{F._exec("enableObjectResizing",true)}catch(ap){}if(s){try{F._exec("BackgroundImageCache",true)}catch(ap){}}}};this.forcePtag=function(aq){if(N||K||aq.keyCode!=13||aq.shiftKey||aq.ctrlKey||aq.altKey){return true}var ap=F.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");if(F.settings.forcePtag){if(ap.length==0){F._exec("formatblock","<p>")}}else{F.pasteHTML("<br />");return false}};this.fixFullHeight=function(){if(!n&&!C){ab.height("100%");if(H){ab.css("height",ab.outerHeight()-Q.outerHeight())}if(s){Q.hide().show()}}};this.fixAppleSel=function(ar){ar=ar.target;if(ar.tagName.match(/(img|embed)/i)){var aq=F.getSel(),ap=F.getRng();ap.selectNode(ar);aq.removeAllRanges();aq.addRange(ap)}};this.focus=function(){if(!N){E.focus()}else{i("#sourceCode",O).focus()}return false};this.getSel=function(){return al.getSelection?al.getSelection():O.selection};this.getRng=function(){var ar=F.getSel(),ap;try{ap=ar.rangeCount>0?ar.getRangeAt(0):(ar.createRange?ar.createRange():O.createRange())}catch(aq){}if(!ap){ap=s?O.body.createTextRange():O.createRange()}return ap};this.getParent=function(ap){var aq=F.getRng(),ar;if(!s){ar=aq.commonAncestorContainer;if(!aq.collapsed){if(aq.startContainer==aq.endContainer&&aq.startOffset-aq.endOffset<2&&aq.startContainer.hasChildNodes()){ar=aq.startContainer.childNodes[aq.startOffset]}}}else{ar=aq.item?aq.item(0):aq.parentElement()}ap=ap?ap:"*";ar=i(ar);if(!ar.is(ap)){ar=i(ar).closest(ap)}return ar};this.getSelect=function(au){var at=F.getSel(),ap=F.getRng(),aq=true;if(!ap||ap.item){aq=false}else{aq=!at||ap.boundingWidth==0||ap.collapsed}if(au=="text"){return aq?"":(ap.text||(at.toString?at.toString():""))}var av;if(ap.cloneContents){var ar=i("<div></div>"),aw;aw=ap.cloneContents();if(aw){ar.append(aw)}av=ar.html()}else{if(aa(ap.item)){av=ap.item(0).outerHTML}else{if(aa(ap.htmlText)){av=ap.htmlText}else{av=ap.toString()}}}if(aq){av=""}av=F.processHTML(av,"read");av=F.formatXHTML(av);av=F.cleanHTML(av);return av};function aa(aq,ap){var ar=typeof(aq);if(!ap){return ar!="undefined"}if(ap=="array"&&(aq.hasOwnProperty&&aq instanceof Array)){return true}return ar==ap}this.pasteHTML=function(at){if(N||K){return false}F.focus();at=F.processHTML(at,"write");var ar=F.getSel(),ap=F.getRng();at+='<span id="_xhe_temp" />';if(ap.insertNode){ap.deleteContents();ap.insertNode(ap.createContextualFragment(at))}else{if(ap.item){F._exec("delete");ap=F.getRng()}ap.pasteHTML(at)}var aq=i("#_xhe_temp",O),au=aq[0];if(s){ap.moveToElementText(au);ap.select()}else{ap.selectNode(au);ar.removeAllRanges();ar.addRange(ap)}aq.remove()};this.pasteText=function(ap){if(!ap){ap=""}ap=F.domEncode(ap);ap=ap.replace(/r?n/g,"<br />");F.pasteHTML(ap)};this.appendHTML=function(ap){if(N||K){return false}F.focus();ap=F.processHTML(ap,"write");i(O.body).append(ap)};this.domEncode=function(ap){return ap.replace(/[<>]/g,function(aq){return{"<":"&lt;",">":"&gt;"}[aq]})};this.setSource=function(ap){setTimeout(function(){F._setSource(ap)},10)};this._setSource=function(ap){G=null;if(typeof ap!="string"&&ap!=""){ap=V.val()}if(N){i("#sourceCode",O).val(ap)}else{if(F.settings.beforeSetSource){ap=F.settings.beforeSetSource(ap)}ap=F.formatXHTML(ap);ap=F.cleanWord(ap);ap=F.cleanHTML(ap);i(O.body)[0].innerHTML=F.processHTML(ap,"write")}};this.processHTML=function(az,aw){var ay=' class="Apple-style-span"';if(aw=="write"){function ar(aC,aA,aD,aB){aB=aB.split(",");if(!aB[1]){aB[1]=aB[0];aB[0]=""}if(aB[0]=="default"){aB[0]=""}return aC.replace(/s+srcs*=s*(["']?).*?1(s|$|/|>)/i,"$2").replace(aA,' src="'+U+(aB[0]?aB[0]:"default")+"/"+aB[1]+'.gif"'+(F.settings.emotMark?' emot="'+(aB[0]?aB[0]+",":"")+aB[1]+'"':""))}az=az.replace(/<img(?:s+[^>]*?)?(s+emots*=s*(["']?)s*(.+?)s*2)(?:s+[^>]*?)?/?>/ig,ar);function aq(aD,aB,aA,aF,aE,aC){return aD.replace(aA,aA+" _xhe_"+aF+'="'+aC+'"')}az=az.replace(/<(w+(?::w+)?)(?:s+[^>]*?)?(s+(src|href)s*=s*(["']?)s*(.*?)s*4)(?:s+[^>]*?)?/?>/ig,aq);az=az.replace(/<(/?)del(s+[^>]*?)?>/ig,"<$1strike$2>");if(n){az=az.replace(/<(/?)strong(s+[^>]*?)?>/ig,"<$1b$2>");az=az.replace(/<(/?)em(s+[^>]*?)?>/ig,"<$1i$2>")}else{if(C){az=az.replace(/("|;)s*font-sizes*:s*([a-z-]+)(;?)/ig,function(aE,aG,aA,aF){var aC,aD;for(var aB=0;aB<w.length;aB++){aC=w[aB];if(aA==aC.n){aD=aC.wkn;break}}return aG+"font-size:"+aD+aF});az=az.replace(/<strong(s+[^>]*?)?>/ig,"<span"+ay+' style="font-weight: bold;"$1>');az=az.replace(/<em(s+[^>]*?)?>/ig,"<span"+ay+' style="font-style: italic;"$1>');az=az.replace(/<u(s+[^>]*?)?>/ig,"<span"+ay+' style="text-decoration: underline;"$1>');az=az.replace(/<strike(s+[^>]*?)?>/ig,"<span"+ay+' style="text-decoration: line-through;"$1>');az=az.replace(/</(strong|em|u|strike)>/ig,"</span>");az=az.replace(/<span((?:s+[^>]*?)?s+style="([^"]*;)*s*(font-family|font-size|color|background-color)s*:s*[^;"]+s*;?"[^>]*)>/ig,"<span"+ay+"$1>")}else{if(s){az=az.replace(/&apos;/ig,"&#39;");az=az.replace(/s+(disabled|checked|readonly|selected)s*=s*["']?(false|0)["']?/ig,"")}}}az=az.replace(/<a(s+[^>]*?)?/>/,"<a$1></a>");if(!C){function au(aH,aL,aA,aE){var aK="",aD,aJ,aI,aG;aD=aA.match(/font-familys*:s*([^;"]+)/i);if(aD){aK+=' face="'+aD[1]+'"'}aJ=aA.match(/font-sizes*:s*([^;"]+)/i);if(aJ){aJ=aJ[1].toLowerCase();for(var aB=0;aB<w.length;aB++){if(aJ==w[aB].n||aJ==w[aB].s){aI=aB+1;break}}if(aI){aK+=' size="'+aI+'"';aA=aA.replace(/(^|;)(s*font-sizes*:s*[^;"]+;?)+/ig,"$1")}}aG=aA.match(/(?:^|[s;])colors*:s*([^;"]+)/i);if(aG){var aF;if(aF=aG[1].match(/s*rgbs*(s*(d+)s*,s*(d+)s*,s*(d+)s*)/i)){aG[1]="#";for(var aC=1;aC<=3;aC++){aG[1]+=(aF[aC]-0).toString(16)}}aG[1]=aG[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i,"#$1$1$2$2$3$3");aK+=' color="'+aG[1]+'"'}aA=aA.replace(/(^|;)(s*(font-family|color)s*:s*[^;"]+;?)+/ig,"$1");if(aK!=""){if(aA){aK+=' style="'+aA+'"'}return"<font"+aK+">"+aE+"</font>"}else{return aH}}az=az.replace(/<(span)(?:s+[^>]*?)?s+styles*=s*"((?:[^"]*?;)*s*(?:font-family|font-size|color)s*:[^"]*)"(?: [^>]+)?>(((?!<1(s+[^>]*?)?>)[sS])*?)</1>/ig,au);az=az.replace(/<(span)(?:s+[^>]*?)?s+styles*=s*"((?:[^"]*?;)*s*(?:font-family|font-size|color)s*:[^"]*)"(?: [^>]+)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?)</1>/ig,au);az=az.replace(/<(span)(?:s+[^>]*?)?s+styles*=s*"((?:[^"]*?;)*s*(?:font-family|font-size|color)s*:[^"]*)"(?: [^>]+)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?</1>)*?)</1>/ig,au)}}else{var ax=F.settings.localUrl;function av(aB,aD,aC,aA){if(ax){aA=S(aA,ax)}return aB.replace(new RegExp("\s+"+aD+"\s*=\s*(["']?).*?\1([\s/>])","ig")," "+aD+'="'+aA.replace(/$/g,"$$$$")+'"$2')}az=az.replace(/<(?:w+(?::w+)?)(?:s+[^>]*?)?s+_xhe_(src|href)s*=s*(["']?)s*(.*?)s*2(?:s+[^>]*?)?/?>/ig,av);if(C){az=az.replace(/("|;)s*font-sizes*:s*([a-z-]+)(;?)/ig,function(aE,aG,aA,aF){var aC,aD;for(var aB=0;aB<w.length;aB++){aC=w[aB];if(aA==aC.wkn){aD=aC.n;break}}return aG+"font-size:"+aD+aF});var ap=[{r:/font-weight:sbold/ig,t:"strong"},{r:/font-style:sitalic/ig,t:"em"},{r:/text-decoration:sunderline/ig,t:"u"},{r:/text-decoration:sline-through/ig,t:"strike"}];function at(aG,aB,aD,aC,aH){var aA=aD+aC,aF="";for(var aE=0;aE<ap.length;aE++){if(aA.match(ap[aE].r)){aF=ap[aE].t;break}}if(aF){return"<"+aF+">"+aH+"</"+aF+">"}else{return aG}}az=az.replace(/<(span)(s+[^>]*?)?s+classs*=s*"Apple-style-span"(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS])*?)</1>/ig,at);az=az.replace(/<(span)(s+[^>]*?)?s+classs*=s*"Apple-style-span"(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?)</1>/ig,at);az=az.replace(/<(span)(s+[^>]*?)?s+classs*=s*"Apple-style-span"(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?</1>)*?)</1>/ig,at)}az=az.replace(/s+(?:_xhe_|_moz_|_webkit_)[^=]+?s*=s*(["']?).*?1([s/>])/ig,"$2");az=az.replace(/(<w+[^>]*?)s+classs*=s*(["']?)s*(?:apple|webkit)-.+?s*2([s/>])/ig,"$1$3")}return az};this.getSource=function(ap){var aq;if(N){aq=i("#sourceCode",O).val()}else{aq=F.processHTML(i(O.body).html(),"read");aq=F.formatXHTML(aq,ap);aq=F.cleanWord(aq);aq=F.cleanHTML(aq);if(F.settings.beforeGetSource){aq=F.settings.beforeGetSource(aq)}}V.val(aq);return aq};this.cleanWord=function(aq){if(aq.match(/mso-|MsoNormal/i)){var ap=F.settings.wordDeepClean;aq=aq.replace(/(<link(?:s+[^>]*?)?)s+hrefs*=s*(["']?)s*file://.+?s*2((?:s+[^>]*?)?s*/?>)/ig,"");aq=aq.replace(/<!--[sS]*?-->|<!(--)?[[sS]+?](--)?>|<style(s+[^>]*?)?>[sS]*?</style>/ig,"");aq=aq.replace(/</?w+:[^>]*>/ig,"");if(ap){aq=aq.replace(/</?(span|a|img)(s+[^>]*?)?>/ig,"")}aq=aq.replace(/(<w+(?:s+[^>]*?)?)s+classs*=s*(["']?)s*mso.+?s*2((?:s+[^>]*?)?s*/?>)/ig,"$1$3");aq=aq.replace(/(<w+(?:s+[^>]*?)?)s+langs*=s*(["']?)s*.+?s*2((?:s+[^>]*?)?s*/?>)/ig,"$1$3");aq=aq.replace(/(<w+(?:s+[^>]*?)?)s+aligns*=s*(["']?)s*lefts*2((?:s+[^>]*?)?s*/?>)/ig,"$1$3");aq=aq.replace(/<w+(?:s+[^>]*?)?(s+styles*=s*(["']?)s*(.*?)s*2)(?:s+[^>]*?)?s*/?>/ig,function(at,ar,av,au){au=i.trim(au.replace(/s*(mso-[^:]+:.+?|margins*:s*0cm 0cm 0pts*|(text-align|font-variant|line-height)s*:s*.+?)(;|$)s*/ig,""));return at.replace(ar,ap?"":au?' style="'+au+'"':"")})}return aq};this.cleanHTML=function(aq){aq=aq.replace(/<??xml(:w+)?(s+[^>]*?)?>([sS]*?</xml>)?/ig,"");aq=aq.replace(/</?(html|head|body|meta|title)(s+[^>]*?)?>/ig,"");if(!F.settings.linkTag){aq=aq.replace(/<link(s+[^>]*?)?>/ig,"")}if(!F.settings.internalScript){aq=aq.replace(/<script(s+[^>]*?)?>[sS]*?</script>/ig,"")}if(!F.settings.inlineScript){aq=aq.replace(/(<w+)(s+[^>]*?)?s+on(?:click|dblclick|mousedown|mouseup|mousemove|mouseover|mouseout|mouseenter|mouseleave|keydown|keypress|keyup|change|select|submit|reset|blur|focus|load|unload)s*=s*(["']?).*?3((?:s+[^>]*?)?/?>)/ig,"$1$2$4")}if(!F.settings.internalStyle){aq=aq.replace(/<style(s+[^>]*?)?>[sS]*?</style>/ig,"")}if(!F.settings.inlineStyle){aq=aq.replace(/(<w+)(s+[^>]*?)?s+styles*=s*(["']?).*?3((?:s+[^>]*?)?/?>)/ig,"$1$2$4")}for(var ap=0;ap<3;ap++){aq=aq.replace(/<(strong|b|u|del|strike|s|em|i)(?:s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)([ trn]|&nbsp;))*?)</1>/ig,function(at,ar,au){if(au.match(/&nbsp;/i)){return au.replace(/ +/g,"")}else{return""}})}aq=aq.replace(/</(strong|b|u|strike|em|i)>((?:s|<br/?>|&nbsp;)*?)<1(s+[^>]*?)?>/ig,"$2");aq=aq.replace(/<(p|div)(?:s+[^>]*?)?>(((?!<1(?: [^>]+)?>)[sS])+?)</1>/ig,function(au,ar,av){var at=av.replace(/</?(span|strong|b|u|strike|em|i)(s+[^>]*?)?>/ig,"");at=at.replace(/([ trn]|&nbsp;)+/ig,"");if(at!=""){return au}else{return"<"+ar+"></"+ar+">"}});return aq};this.formatXHTML=function(aE,ax){var aA=aC("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");var at=aC("address,applet,blockquote,button,center,dd,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul");var aq=aC("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,del,strong,sub,sup,textarea,tt,u,var");var aN=aC("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");var aB=aC("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");var aM=aC("script,style");var ar={b:"strong",i:"em",s:"del",strike:"del"};var aJ=/^<(w+(?::w+)?)((?:s+[w-:]*(?:s*=s*(?:(?:"[^"]*")|(?:'[^']*')|[^>s]+))?)*)s*(/?)>/;var aw=/^</(w+(?::w+)?)[^>]*>/;var aH=/([w-(?::w+)?]+)(?:s*=s*(?:(?:"((?:\.|[^"])*)")|(?:'((?:\.|[^'])*)')|([^>s]+)))?/g;var aG=0,au=[],az=aE.replace(/t*r?nt*/g,""),aF=Array(),aD=-1,ay;au.last=function(){return this[this.length-1]};while(az.length>0){if(!au.last()||!aM[au.last()]){aG=0;if(az.substring(0,4)=="<!--"){aG=az.indexOf("-->");if(aG!=-1){aG+=3;ap(az.substring(0,aG))}}else{if(az.substring(0,2)=="</"){match=az.match(aw);if(match){match[0].replace(aw,aK);aG=match[0].length}}else{if(az.charAt(0)=="<"){match=az.match(aJ);if(match){match[0].replace(aJ,aL);aG=match[0].length}}}}if(aG==0){aG=az.indexOf("<");if(aG==0){aG=1}else{if(aG<0){aG=az.length}}ap(F.domEncode(az.substring(0,aG)))}az=az.substring(aG)}else{az=az.replace(/^([sS]*?)</(style|script)>/i,function(aQ,aO,aP){ap(aO);return""});aK("",au.last())}}aK();aE=aF.join("");aF=null;function aC(aR){var aQ={},aO=aR.split(",");for(var aP=0;aP<aO.length;aP++){aQ[aO[aP]]=true}return aQ}function av(aP){if(aP){aP=aP.toLowerCase();var aO=ar[aP];if(aO){aP=aO}}else{aP=""}return aP}function aL(aR,aP,aQ,aO){aP=av(aP);if(at[aP]){while(au.last()&&aq[au.last()]){aK("",au.last())}}if(aN[aP]&&au.last()==aP){aK("",aP)}aO=aA[aP]||!!aO;if(!aO){au.push(aP)}aR=Array();aR.push("<"+aP);aQ.replace(aH,function(aT,aS){aS=aS.toLowerCase();var aU=arguments[2]?arguments[2]:arguments[3]?arguments[3]:arguments[4]?arguments[4]:aB[aS]?aS:"";if(aU){aR.push(" "+aS+'="'+aU.replace(/(^|[^\])"/g,'$1\"')+'"')}});aR.push((aO?" /":"")+">");ap(aR.join(""),aP,true)}function aK(aQ,aP){if(!aP){var aR=0}else{aP=av(aP);for(var aR=au.length-1;aR>=0;aR--){if(au[aR]==aP){break}}}if(aR>=0){for(var aO=au.length-1;aO>=aR;aO--){ap("</"+au[aO]+">",au[aO])}au.length=aR}}function ap(aQ,aP,aS){if(ax==true){if(aQ.match(/^[st]*$/)){return}var aR=at[aP],aO=0;if(aR){if(aS){aD++}if(aS||(!aS&&ay!="")){aF.push("rn");aO=aD;while(aO--){aF.push("t")}}ay="block"}else{ay=""}aF.push(aQ);if(aP=="br"){aF.push("rn");aO=aD;if(aO>0){while(aO--){aF.push("t")}}}if(aR&&!aS){aD--}}else{aF.push(aQ)}}function aI(aS,aW,aT,aQ){var aU="",aP,aV,aR,aO;aP=aT.match(/ faces*=s*"s*([^"]+)s*"/i);if(aP){aU+="font-family:"+aP[1]+";"}aV=aT.match(/ sizes*=s*"s*(d+)s*"/i);if(aV){aU+="font-size:"+w[aV[1]-1].n+";"}aR=aT.match(/ colors*=s*"s*([^"]+)s*"/i);if(aR){aU+="color:"+aR[1]+";"}aO=aT.match(/ styles*=s*"s*([^"]+)s*"/i);if(aO){aU+=aO[1]}if(aU){aQ='<span style="'+aU+'">'+aQ+"</span>"}return aQ}aE=aE.replace(/<(font)(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS])*?)</1>/ig,aI);aE=aE.replace(/<(font)(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?)</1>/ig,aI);aE=aE.replace(/<(font)(s+[^>]*?)?>(((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS]|<1(s+[^>]*?)?>((?!<1(s+[^>]*?)?>)[sS])*?</1>)*?</1>)*?)</1>/ig,aI);aE=aE.replace(/^(s*r?n)+|(s*r?n)+$/,"");return aE};this.toggleShowBlocktag=function(aq){if(an===aq){return}an=!an;var ap=i(O.body);if(an){P+=" showBlocktag";ap.addClass("showBlocktag")}else{P=P.replace(" showBlocktag","");ap.removeClass("showBlocktag")}};this.toggleReadonly=function(ap){if(W===ap){return}if(N){F.toggleSource(true)}W=!W;if(W){if(!K){F.togglePreview(true)}Q.find("[name=Preview]").toggleClass("xheEnabled").toggleClass("xheActive")}else{Q.find("[name=Preview]").toggleClass("xheEnabled").toggleClass("xheActive");if(K){F.togglePreview()}}};this.toggleSource=function(aq){if(K||N===aq){return}Q.find("[name=Source]").toggleClass("xheEnabled").toggleClass("xheActive");if(t){F.hidePanel()}var ap=i(O.body),ar;if(!N){ar=F.getSource(true);if(s){O.body.contentEditable="false"}else{O.designMode="Off"}ap.attr("scroll","no").attr("class","sourceMode").html('<textarea id="sourceCode" wrap="soft" spellcheck="false" height="100%" />');ap.find("#sourceCode").blur(F.getSource)}else{ar=F.getSource();ap.find("#sourceCode").remove();if(s){O.body.contentEditable="true"}else{O.designMode="On";if(n){F._exec("inserthtml","-")}}ap.removeAttr("scroll").attr("class","editMode"+P);setTimeout(function(){al.scrollTo(0,0)},10)}N=!N;F._setSource(ar);Q.find("[name=Source]").toggleClass("xheEnabled");Q.find(".xheButton").not("[name=Source],[name=Fullscreen],[name=About]").toggleClass("xheEnabled");setTimeout(F.setOpts,300)};this.togglePreview=function(aq){if(N||K===aq){return}Q.find("[name=Preview]").toggleClass("xheActive").toggleClass("xheEnabled");var ap=i(O.body);if(!K){if(s){O.body.contentEditable="false"}else{O.designMode="Off"}ap.attr("class","previewMode");ap[0].innerHTML=ap.html();i("head base",O).attr("target","_blank")}else{if(s){O.body.contentEditable="true"}else{O.designMode="On"}ap.attr("class","editMode"+P);ap[0].innerHTML=ap.html();i("head base",O).removeAttr("target")}K=!K;Q.find("[name=Preview]").toggleClass("xheEnabled");Q.find(".xheButton").not("[name=Preview],[name=Fullscreen],[name=About]").toggleClass("xheEnabled");setTimeout(F.setOpts,300)};this.toggleFullscreen=function(ar){if(H===ar){return}if(t){F.hidePanel()}var aq=i("#"+ah).find(".xheLayout"),ap=i("#"+ah);if(H){aq.attr("style",R);ab.height(af-Q.outerHeight())}else{R=aq.attr("style");aq.removeAttr("style");ab.height("100%");setTimeout(F.fixFullHeight,100)}H=!H;ap.toggleClass("xhe_Fullscreen");i("html").toggleClass("xhe_Fullfix");Q.find("[name=Fullscreen]").toggleClass("xheActive");setTimeout(F.setOpts,300)};this.showMenu=function(ar,at){var aq=i('<div class="xheMenu"></div>'),ap;i.each(ar,function(av,au){ap=i('<a href="javascript:void(0);" title="'+au.t+'">'+au.s+"</a>").click(function(){F.focus();at(au.v);F.hidePanel();return false});aq.append(ap)});F.showPanel(aq)};this.showColor=function(au){var aq=i('<div class="xheColor"></div>'),ar,ap,at=0;ar=i("<div></div>");i.each(o,function(aw,av){at++;ap=i('<a href="javascript:void(0);" title="'+av+'" style="background:'+av+'"><img src="'+ao+'img/spacer.gif" /></a>').click(function(){F.focus();au(av);F.hidePanel();return false});ar.append(ap);if(at%7==0){aq.append(ar);ar=i("<div></div>")}});aq.append(ar);F.showPanel(aq)};this.showPastetext=function(){var aq=i(a),ar=i("#xhePastetextValue",aq),ap=i("#xheSave",aq);ap.click(function(){F.focus();var at=ar.val();if(at){F.pasteText(at)}F.hidePanel();return false});F.showDialog(aq)};this.showLink=function(){var aq=i(b),au=F.getParent("a"),ar=i("#xheLinkText",aq),aw=i("#xheLinkHref",aq),av=i("#xheLinkTarget",aq),ap=i("#xheSave",aq),at=F.getSelect();if(au.length==1){aw.val(F.attr(au,"href"));av.attr("value",au.attr("target"))}else{if(at==""){ar.val(F.settings.defLinkText).closest("div").show()}}if(F.settings.upLinkUrl){F.uploadInit(aw,F.settings.upLinkUrl,F.settings.upLinkExt,function(ax){ax=ax.split(",");aw.val(ax[0]);if(ax[1]){ar.val(ax[1])}})}ap.click(function(){F.focus();var ay=aw.val();if(ay==""||au.length==0){F._exec("unlink")}if(ay!=""&&ay!="http://"){if(au.length==0){if(at==""){var ax=ar.val();if(!ax){ax=ay}F.pasteHTML('<a href="#xhe_tmpurl">'+ax+"</a>")}else{F._exec("createlink","#xhe_tmpurl")}au=i('a[href$="#xhe_tmpurl"]',O)}F.attr(au,"href",ay);if(av.val()!=""){au.attr("target",av.val())}else{au.removeAttr("target")}}F.hidePanel();return false});F.showDialog(aq)};this.showImg=function(){var ay=i(y),ar=F.getParent("img"),at=i("#xheImgSrc",ay),az=i("#xheImgAlt",ay),aB=i("#xheImgAlign",ay),au=i("#xheImgWidth",ay),av=i("#xheImgHeight",ay),aA=i("#xheImgBorder",ay),ap=i("#xheImgVspace",ay),aw=i("#xheImgHspace",ay),ax=i("#xheSave",ay);if(ar.length==1){at.val(F.attr(ar,"src"));az.val(ar.attr("alt"));aB.val(ar.attr("align"));au.val(ar.attr("width"));av.val(ar.attr("height"));aA.val(ar.attr("border"));var aq=ar.attr("vspace"),aC=ar.attr("hspace");ap.val(aq<=0?"":aq);aw.val(aC<=0?"":aC)}if(F.settings.upImgUrl){F.uploadInit(at,F.settings.upImgUrl,F.settings.upImgExt)}ax.click(function(){F.focus();var aE=at.val();if(aE!=""&&aE!="http://"){var aI=aE.split("|");if(aI.length>1){var aG='<img src="xhe_tmpurl"',aH;if(az.val()!=""){aG+=' alt="'+az.val()+'"'}if(aB.val()!=""){aG+=' align="'+aB.val()+'"'}if(au.val()!=""){aG+=' width="'+au.val()+'"'}if(av.val()!=""){aG+=' height="'+av.val()+'"'}if(aA.val()!=""){aG+=' border="'+aA.val()+'"'}if(ap.val()!=""){aG+=' vspace="'+ap.val()+'"'}if(aw.val()!=""){aG+=' hspace="'+aw.val()+'"'}aG+=" />";for(var aF in aI){aE=aI[aF];if(aE!=""){aE=aE.split(",");aH=aG;aH=aH.replace("xhe_tmpurl",aE[0]);if(aE[1]){aH='<a href="'+aE[1]+'" target="_blank">'+aH+"</a>"}F.pasteHTML(aH)}}}else{if(aI.length==1){aE=aI[0];if(aE!=""){aE=aE.split(",");if(ar.length==0){F.pasteHTML('<img src="'+aE[0]+'#xhe_tmpurl" />');ar=i('img[src$="#xhe_tmpurl"]',O)}F.attr(ar,"src",aE[0]);if(az.val()!=""){ar.attr("alt",az.val())}else{ar.removeAttr("alt")}if(aB.val()!=""){ar.attr("align",aB.val())}else{ar.removeAttr("align")}if(au.val()!=""){ar.attr("width",au.val())}else{ar.removeAttr("width")}if(av.val()!=""){ar.attr("height",av.val())}else{ar.removeAttr("height")}if(aA.val()!=""){ar.attr("border",aA.val())}else{ar.removeAttr("border")}if(ap.val()!=""){ar.attr("vspace",ap.val())}else{ar.removeAttr("vspace")}if(aw.val()!=""){ar.attr("hspace",aw.val())}else{ar.removeAttr("hspace")}if(aE[1]){var aD=ar.parent("a");if(aD.length==0){ar.wrap("<a></a>");aD=ar.parent("a")}F.attr(aD,"href",aE[1]);aD.attr("target","_blank")}}}}}else{if(ar.length==1){ar.remove()}}F.hidePanel();return false});F.showDialog(ay)};this.showEmbed=function(ap,aA,ax,aB,au,aq,ar){var aC=i(aA),at=F.getParent('embed[type="'+ax+'"],embed[classid="'+aB+'"]'),aw=i("#xhe"+ap+"Src",aC),av=i("#xhe"+ap+"Width",aC),ay=i("#xhe"+ap+"Height",aC),az=i("#xheSave",aC);if(aq){F.uploadInit(aw,aq,ar)}F.showDialog(aC);if(at.length==1){aw.val(F.attr(at,"src"));av.val(at.attr("width"));ay.val(at.attr("height"))}az.click(function(){F.focus();var aF=aw.val();if(aF!=""&&aF!="http://"){var aE=av.val(),aJ=ay.val(),aI=/^[0-9]+$/;if(!aI.test(aE)){aE=412}if(!aI.test(aJ)){aJ=300}var aK='<embed type="'+ax+'" classid="'+aB+'" src="xhe_tmpurl"'+au;var aD=aF.split("|");if(aD.length>1){var aH=aK+"";aH+=' width="'+aE+'" height="'+aJ+'" />';for(var aG in aD){aF=aD[aG];if(aF!=""){F.pasteHTML(aH.replace("xhe_tmpurl",aF))}}}else{if(aD.length==1){aF=aD[0];if(at.length==0){F.pasteHTML(aK.replace("xhe_tmpurl",aF+"#xhe_tmpurl")+" />");at=i('embed[src$="#xhe_tmpurl"]',O)}F.attr(at,"src",aF);at.attr("width",aE);at.attr("height",aJ)}}}else{if(at.length==1){at.remove()}}F.hidePanel();return false})};this.showEmot=function(av){var at=i('<div class="xheEmot"></div>');av=av?av:(aj?aj:"default");var aI=ai[av];var aC=U+av+"/",aA=0,ap=[],ay="";var aE=aI.width,aq=aI.height,aw=aI.line,au=aI.count,aF=aI.list;if(au){for(var aB=1;aB<=au;aB++){aA++;ap.push('<a href="javascript:void(0);" style="background-image:url('+aC+aB+'.gif);" emot="'+av+","+aB+'">&nbsp;</a>');if(aA%aw==0){ap.push("<br />")}}}else{i.each(aF,function(aK,aJ){aA++;ap.push('<a href="javascript:void(0);" style="background-image:url('+aC+aK+'.gif);" emot="'+av+","+aK+'" title="'+aJ+'">&nbsp;</a>');if(aA%aw==0){ap.push("<br />")}})}var ax=aw*(aE+12),aD=Math.ceil(aA/aw)*(aq+12),aG=ax*0.75;if(aD<=aG){aG=""}ay=i("<style>"+(aG?".xheEmot div{width:"+(ax+20)+"px;height:"+aG+"px;}":"")+".xheEmot div a{width:"+aE+"px;height:"+aq+"px;}</style><div>"+ap.join("")+"</div>");i("a",ay).click(function(){F.focus();F.pasteHTML('<img emot="'+i(this).attr("emot")+'">');F.hidePanel();return false});at.append(ay);var aH=0,ar=["<ul>"],az;i.each(ai,function(aK,aJ){aH++;ar.push("<li"+(av==aK?' class="cur"':"")+'><a href="javascript:void(0);" group="'+aK+'">'+aJ.name+"</a></li>")});if(aH>1){ar.push('</ul><br style="clear:both;" />');az=i(ar.join(""));i("a",az).click(function(){aj=i(this).attr("group");F.showEmot(aj);return false});at.append(az)}F.showPanel(at)};this.showTable=function(){var aq=i(h),ap=i("#xheTableRows",aq),aB=i("#xheTableColumns",aq),ay=i("#xheTableHeaders",aq),at=i("#xheTableWidth",aq),au=i("#xheTableHeight",aq),aA=i("#xheTableBorder",aq),ar=i("#xheTableCellSpacing",aq),aw=i("#xheTableCellPadding",aq),az=i("#xheTableAlign",aq),av=i("#xheTableCaption",aq),ax=i("#xheSave",aq);ax.click(function(){F.focus();var aO=av.val(),aN=aA.val(),aG=ap.val(),aC=aB.val(),aE=ay.val(),aD=at.val(),aK=au.val(),aI=ar.val(),aL=aw.val(),aM=az.val();var aJ,aH,aF="<table"+(aN!=""?' border="'+aN+'"':"")+(aD!=""?' width="'+aD+'"':"")+(aK!=""?' width="'+aK+'"':"")+(aI!=""?' cellspacing="'+aI+'"':"")+(aL!=""?' cellpadding="'+aL+'"':"")+(aM!=""?' align="'+aM+'"':"")+">";if(aO!=""){aF+="<caption>"+aO+"</caption>"}if(aE=="row"||aE=="both"){aF+="<tr>";for(aJ=0;aJ<aC;aJ++){aF+='<th scope="col">&nbsp;</th>'}aF+="</tr>";aG--}aF+="<tbody>";for(aJ=0;aJ<aG;aJ++){aF+="<tr>";for(aH=0;aH<aC;aH++){if(aH==0&&(aE=="col"||aE=="both")){aF+='<th scope="row">&nbsp;</th>'}else{aF+="<td>&nbsp;</td>"}}aF+="</tr>"}aF+="</tbody></table>";F.pasteHTML(aF);F.hidePanel();return false});F.showDialog(aq)};this.showAbout=function(){var aq=i(r),ap=i("#xheSave",aq);ap.click(function(){F.focus();F.hidePanel();return false});F.showDialog(aq)};this.attr=function(ar,at,ap){if(!at){return false}var aq="_xhe_"+at;if(ap){ar.attr(at,ap).removeAttr(aq).attr(aq,ap)}return ar.attr(aq)||ap};this.addShortcuts=function(ap,aq){ap=ap.toLowerCase();if(X[ap]==undefined){X[ap]=Array()}X[ap].push(aq)};this.checkShortcuts=function(ar){if(N||K){return true}ak=ar;var aq=ak.which,ap=B[aq],au=ap?ap:String.fromCharCode(aq).toLowerCase();sKey="";sKey+=ak.ctrlKey?"ctrl+":"";sKey+=ak.altKey?"alt+":"";sKey+=ak.shiftKey?"shift+":"";sKey+=au;var at=X[sKey];if(at){i.each(at,function(av,aw){if(i.isFunction(aw)){aw.call(F)}else{F.exec(aw)}});return false}};this.uploadInit=function(au,ar,aw,ap){var aq=i('<span class="xheUpload"><input type="text" style="visibility:hidden;" /><input type="button" value="'+F.settings.upBtnText+'" class="xheBtn" /></span>'),at=i(".xheBtn",aq);au.after(aq);at.before(au);if(ar.substr(0,1)=="!"){at.click(function(){t=false;F.showIframeModal(ar.substr(1),"上传文件",av,null,null,function(){t=true})})}else{aq.append('<input type="file" class="xheFile" size="13" name="filedata" />');var ax=i(".xheFile",aq);if(i.event.special.change){i.event.special.change={}}ax.change(function(){var az=ax.val();if(az!=""){if(az.match(new RegExp(".("+aw.replace(/,/g,"|")+")$","i"))){t=false;var ay=F.showModal("文件上传",'<div style="margin:22px 0;text-align:center;line-height:30px;">文件上传中,请稍候……<br /><img src="'+ao+'img/loading.gif"></div>',320,150,function(){t=true});F.ajaxUpload(ax,ar,function(aA){ay.remove();if(aA.err){alert(aA.err)}else{av(aA.msg)}},function(){ay.remove()})}else{alert("上传文件扩展名必需为: "+aw)}}})}function av(ay){var az=false,aA=F.settings.onUpload;if(ay.substr(0,1)=="!"){az=true;ay=ay.substr(1)}if(ap){ap(ay)}else{au.val(ay)}if(aA){aA(ay)}if(az){au.closest(".xheDialog").find("#xheSave").click()}}};this.ajaxUpload=function(at,ap,ay,av){var ax=new Date().getTime(),aw="jUploadFrame"+ax;var aq=i('<iframe name="'+aw+'" class="xheHideArea" />').appendTo("body");var ar=i('<form action="'+ap+'" target="'+aw+'" method="post" enctype="multipart/form-data" class="xheHideArea"></form>').appendTo("body");var az=i(at),au=az.clone().attr("disabled","true");az.before(au).appendTo(ar);ar.submit();aq.load(function(){setTimeout(function(){au.before(az).remove();aq.remove();ar.remove()},100);var aA=i(aq[0].contentWindow.document.body).text(),aC=Object;try{aC=eval("("+aA+")")}catch(aB){}if(aC.err!=undefined&&aC.msg!=undefined){ay(aC)}else{alert(ap+" 上传接口发生错误!rnrn返回的错误内容为: rnrn"+aA);av()}})};this.showIframeModal=function(az,au,ax,av,ar,aq){var ap=i('<iframe frameborder="0" src="'+az+'" style="width:100%;height:100%;display:none;" /><div class="xheModalIfmWait"></div>'),ay=i(ap[0]),at=i(ap[1]);var aw=F.showModal(au,ap,av,ar,aq);ay.load(function(){var aB=ay[0].contentWindow,aA=i(aB.document);aB.callback=function(aC){aA.unbind("keydown",aw.escCheck);aw.remove();ax(aC)};aA.keydown(aw.escCheck);ay.show();at.remove()})};this.showModal=function(az,ax,aA,aw,at){if(i(".xheModal").length==1){return false}var ar,aB,ap,ay,aq;aA=aA?aA:F.settings.modalWidth;aw=aw?aw:F.settings.modalHeight;ay=F.settings.layerShadow;ar=i('<div class="xheModal" style="width:'+(aA-1)+"px;height:"+aw+"px;margin-left:-"+Math.ceil(aA/2)+"px;"+(s&&l<=7?"":"margin-top:-"+Math.ceil(aw/2)+"px")+'">'+(F.settings.modalTitle?'<div class="xheModalTitle"><span class="xheModalClose" title="关闭 (Esc)"></span>'+az+"</div>":"")+'<div class="xheModalContent"></div></div>').appendTo("body");ap=i('<div class="xheModalOverlay"></div>').appendTo("body");if(ay>0){aB=i('<div class="xheModalShadow" style="width:'+ar.outerWidth()+"px;height:"+ar.outerHeight()+"px;margin-left:-"+(Math.ceil(aA/2)-ay-2)+"px;"+(s&&l<=7?"":"margin-top:-"+(Math.ceil(aw/2)-ay-2)+"px")+'"></div>').appendTo("body")}i(".xheModalContent",ar).css("height",aw-(F.settings.modalTitle?i(".xheModalTitle").outerHeight():0)).html(ax);if(s&&l==6){aq=i("select:visible").css("visibility","hidden")}function av(){if(aq){aq.css("visibility","visible")}i(document).unbind("keydown",au);ar.remove();if(ay>0){aB.remove()}ap.remove();if(at){at()}}this.remove=av;function au(aC){if(aC.which==27){av();return false}}this.escCheck=au;i(document).keydown(au);i(".xheModalClose",ar).click(this.remove);ap.show();if(ay>0){aB.show()}ar.show();return this};this.showDialog=function(at){var ar=i('<div class="xheDialog"></div>'),ap=i("#xheSave",at);if(ap.length==1){at.find("input[type=text]").keypress(function(av){if(av.which==13){ap.click();return false}});ap.after(' <input type="button" id="xheCancel" value="取消" />');i("#xheCancel",at).click(F.hidePanel);if(!F.settings.clickCancelDialog){m=false;var aq=i('<div class="xheFixCancel"></div>').appendTo("body").mousedown(function(){return false});var au=ab.offset();aq.css({left:au.left,top:au.top,width:ab.outerWidth(),height:ab.outerHeight()})}}ar.append(at);F.showPanel(ar)};this.clickCancelPanel=function(){if(m){F.hidePanel()}};this.showPanel=function(ar){if(t){F.hidePanel()}e.empty().append(ar).css("left",0).css("top",0);j=i(ak.target).closest("a");var at=j.offset();var aq=at.left,au=at.top;au+=j.outerHeight()-1;j.addClass("xheActive");q.css({left:aq+1,top:au}).show();if((aq+e.outerWidth())>document.body.clientWidth){aq-=(e.outerWidth()-j.outerWidth())}var ap=F.settings.layerShadow;if(ap>0){A.css({left:aq+ap,top:au+ap,width:e.outerWidth(),height:e.outerHeight()}).show()}e.css("left",aq).css("top",au).show();t=true};this.hidePanel=function(){if(t){j.removeClass("xheActive");A.hide();q.hide();e.hide();t=false;if(!m){i(".xheFixCancel").remove();m=true}}};this.exec=function(at){var av=v[at].e;if(av){return av.call(F)}at=at.toLowerCase();switch(at){case"cut":try{O.execCommand(at);if(!O.queryCommandSupported(at)){throw"Error"}}catch(ar){alert("您的浏览器安全设置不允许使用剪切操作,请使用键盘快捷键(Ctrl + X)来完成")}break;case"copy":try{O.execCommand(at);if(!O.queryCommandSupported(at)){throw"Error"}}catch(ar){alert("您的浏览器安全设置不允许使用复制操作,请使用键盘快捷键(Ctrl + C)来完成")}break;case"paste":try{O.execCommand(at);if(!O.queryCommandSupported(at)){throw"Error"}}catch(ar){alert("您的浏览器安全设置不允许使用粘贴操作,请使用键盘快捷键(Ctrl + V)来完成")}break;case"pastetext":if(window.clipboardData){F.pasteText(window.clipboardData.getData("Text",true))}else{F.showPastetext()}break;case"blocktag":var au=[];i.each(z,function(ax,aw){au.push({s:"<"+aw.n+">"+aw.t+"</"+aw.n+">",v:"<"+aw.n+">",t:aw.t})});F.showMenu(au,function(aw){F._exec("formatblock",aw)});break;case"fontface":var ap=[];i.each(d,function(ax,aw){aw.c=aw.c?aw.c:aw.n;ap.push({s:'<span style="font-family:'+aw.c+'">'+aw.n+"</span>",v:aw.c,t:aw.n})});F.showMenu(ap,function(aw){F._exec("fontname",aw)});break;case"fontsize":var aq=[];i.each(w,function(ax,aw){aq.push({s:'<span style="font-size:'+aw.s+'">'+aw.t+"("+aw.s+")</span>",v:ax+1,t:aw.t})});F.showMenu(aq,function(aw){F._exec("fontsize",aw)});break;case"fontcolor":F.showColor(function(aw){F._exec("forecolor",aw)});break;case"backcolor":F.showColor(function(aw){if(s){F._exec("backcolor",aw)}else{F.setCSS(true);F._exec("hilitecolor",aw);F.setCSS(false)}});break;case"align":F.showMenu(f,function(aw){F._exec(aw)});break;case"list":F.showMenu(g,function(aw){F._exec(aw)});break;case"link":F.showLink();break;case"img":F.showImg();break;case"flash":F.showEmbed("Flash",D,"application/x-shockwave-flash","clsid:d27cdb6e-ae6d-11cf-96b8-4445535400000",' wmode="opaque" quality="high" menu="false" play="true" loop="true"',F.settings.upFlashUrl,F.settings.upFlashExt);break;case"media":F.showEmbed("Media",x,"application/x-mplayer2","clsid:6bf52a52-394a-11d3-b153-00c04f79faa6",' enablecontextmenu="false" autostart="false"',F.settings.upMediaUrl,F.settings.upMediaExt);break;case"emot":F.showEmot();break;case"table":F.showTable();break;case"source":F.toggleSource();break;case"preview":F.togglePreview();break;case"fullscreen":F.toggleFullscreen();break;case"about":F.showAbout();break;default:F._exec(at);break}};this._exec=function(ap,aq){if(aq!=undefined){return O.execCommand(ap,false,aq)}else{return O.execCommand(ap,false,null)}};function S(aq,av){var au=location.protocol,ar=location.hostname,ap=location.port,at=location.pathname.replace(/[^/]+$/i,"");ap=(ap=="")?"80":ap;aq=i.trim(aq);if(av!="abs"){aq=aq.replace(new RegExp(au+"\/\/"+ar.replace(/./g,"\.")+"(?::"+ap+")"+(ap=="80"?"?":"")+"(/|$)","i"),"/")}if(av=="rel"){aq=aq.replace(new RegExp("^"+at.replace(/([/.+[]()])/g,"\$1"),"i"),"")}if(av!="rel"){if(!aq.match(/^((https?|file)://|/)/i)){aq=at+aq}}if(av=="abs"){if(!aq.match(/(https?|file):///i)){aq=au+"//"+location.host+aq}}return aq}};i(function(){i("textarea.xheditor,textarea[xheditor]").xheditor(true);i("textarea.xheditor-mini").xheditor(true,{tools:"mini"});i("textarea.xheditor-simple").xheditor(true,{tools:"simple"})})})(jQuery);