editor-min.js revision a9877c9114840d695f43d6fd96f07f905de0d968
YUI.add("frame",function(A){YUI.add("frame",function(C){var B=function(){B.superclass.constructor.apply(this,arguments);};C.extend(B,C.Base,{_ready:null,_rendered:null,_iframe:null,_instance:null,_create:function(D){var J,I,F,H;this._iframe=C.Node.create(B.HTML);this._iframe.setStyle("visibility","hidden");this._iframe.set("src",this.get("src"));this.get("container").append(this._iframe);var E="",G=((this.get("extracss"))?'<style id="extra_css">'+this.get("extracss")+"</style>":"");E=C.substitute(B.PAGE_HTML,{DIR:this.get("dir"),LANG:this.get("lang"),TITLE:this.get("title"),META:B.META,CONTENT:this.get("content"),BASE_HREF:this.get("basehref"),DEFAULT_CSS:B.DEFAULT_CSS,EXTRA_CSS:G});if(C.config.doc.compatMode!="BackCompat"){E=B.DOC_TYPE+"\n"+E;}else{}F=this._resolveWinDoc();F.doc.open();F.doc.write(E);F.doc.close();if(this.get("designMode")){F.doc.designMode="on";}if(!F.doc.documentElement){var K=C.later(1,this,function(){if(F.doc&&F.doc.documentElement){D(F);K.cancel();}},null,true);}else{D(F);}},_resolveWinDoc:function(E){var D=(E)?E:{};D.win=C.Node.getDOMNode(this._iframe.get("contentWindow"));D.doc=C.Node.getDOMNode(this._iframe.get("contentWindow.document"));if(!D.doc){D.doc=C.config.doc;}if(!D.win){D.win=C.config.win;}return D;},_onDomEvent:function(F){var E,D;F.frameX=F.frameY=0;if(F.pageX>0||F.pageY>0){if(F.type.substring(0,3)!=="key"){D=this._instance.one("win");E=this._iframe.getXY();F.frameX=E[0]+F.pageX-D.get("scrollLeft");F.frameY=E[1]+F.pageY-D.get("scrollTop");}}F.frameTarget=F.target;F.frameCurrentTarget=F.currentTarget;F.frameEvent=F;C.later(1,this,function(G){this.fire("dom:"+G.type,G);},F);},initializer:function(){this.publish("ready",{emitFacade:true,defaultFn:this._defReadyFn});},destructor:function(){var D=this.getInstance();D.one("doc").detachAll();D=null;this._iframe.remove();},_DOMPaste:function(G){var E=this.getInstance(),D="",F=E.config.win;if(G._event.originalTarget){D=G._event.originalTarget;}if(G._event.clipboardData){D=G._event.clipboardData.getData("Text");}if(F.clipboardData){D=F.clipboardData.getData("Text");if(D==""){if(!F.clipboardData.setData("Text",D)){D=null;}}}G.frameTarget=G.target;G.frameCurrentTarget=G.currentTarget;G.frameEvent=G;if(D){G.clipboardData={data:D,getData:function(){return D;}};}else{G.clipboardData=null;}this.fire("dom:paste",G);},_defReadyFn:function(){var E=this.getInstance(),D=C.bind(this._onDomEvent,this);E.Node.DOM_EVENTS.paste=1;C.each(B.DOM_EVENTS,function(G,F){if(G===1){if(F!=="focus"&&F!=="blur"&&F!=="paste"){if(F.substring(0,3)==="key"){E.on(F,C.throttle(D,200),E.config.doc);}else{E.on(F,D,E.config.doc);}}}},this);E.on("paste",C.bind(this._DOMPaste,this),E.one("body"));E.on("focus",D,E.config.win);E.on("blur",D,E.config.win);E._use=E.use;E.use=C.bind(this.use,this);this._iframe.setStyles({visibility:"inherit"});E.one("body").setStyle("display","block");},_onContentReady:function(F){if(!this._ready){this._ready=true;var E=this.getInstance(),D=C.clone(this.get("use"));this.fire("contentready");if(F){E.config.doc=C.Node.getDOMNode(F.target);}D.push(C.bind(function(){this.fire("ready");},this));E.use.apply(E,D);E.one("doc").get("documentElement").addClass("yui-js-enabled");}},_resolveBaseHref:function(D){if(!D||D===""){D=C.config.doc.location.href;if(D.indexOf("?")!==-1){D=D.substring(0,D.indexOf("?"));}D=D.substring(0,D.lastIndexOf("/"))+"/";}return D;},_getHTML:function(D){if(this._ready){var E=this.getInstance();D=E.one("body").get("innerHTML");}return D;},_setHTML:function(D){if(this._ready){var E=this.getInstance();E.one("body").set("innerHTML",D);}else{this.on("contentready",C.bind(function(F,H){var G=this.getInstance();G.one("body").set("innerHTML",F);},this,D));}return D;},_setExtraCSS:function(D){if(this._ready){var F=this.getInstance(),E=F.get("#extra_css");E.remove();F.one("head").append('<style id="extra_css">'+D+"</style>");}return D;},_instanceLoaded:function(D){this._instance=D;this._onContentReady();var E=this._instance.config.doc;if(this.get("designMode")){if(!C.UA.ie){this._instance.on("domready",function(G){try{E.execCommand("styleWithCSS",false,false);E.execCommand("insertbronreturn",false,false);}catch(F){}});}}},use:function(){var F=this.getInstance(),E=C.Array(arguments),D=false;if(C.Lang.isFunction(E[E.length-1])){D=E.pop();}if(D){E.push(function(){D.apply(F,arguments);});}F._use.apply(F,E);},delegate:function(F,E,D,H){var G=this.getInstance();if(!G){return false;}if(!H){H=D;D="body";}return G.delegate(F,E,D,H);},getInstance:function(){return this._instance;},render:function(D){if(this._rendered){return this;}this._rendered=true;if(D){this.set("container",D);}this._create(C.bind(function(H){var J,K,E=C.bind(function(L){this._instanceLoaded(L);},this),G=C.clone(this.get("use")),F={debug:false,win:H.win,doc:H.doc},I=C.bind(function(){F=this._resolveWinDoc(F);J=YUI(F);try{J.use("node-base",E);if(K){clearInterval(K);}}catch(L){K=setInterval(function(){I();},350);}},this);G.push(I);C.use.apply(C,G);},this));return this;},focus:function(D){try{C.one("win").focus();C.later(100,this,function(){this.getInstance().one("win").focus();if(C.Lang.isFunction(D)){D();}});}catch(E){}return this;},show:function(){this._iframe.setStyles({position:"static",left:""});if(C.UA.gecko){try{this._instance.config.doc.designMode="on";}catch(D){}this.focus();}return this;},hide:function(){this._iframe.setStyles({position:"absolute",left:"-999999px"});return this;}},{DOM_EVENTS:{paste:1,mouseup:1,mousedown:1,keyup:1,keydown:1,keypress:1},DEFAULT_CSS:"html { height: 95%; } body { padding: 7px; background-color: #fff; font: 13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } img { cursor: pointer !important; border: none; }",HTML:'<iframe border="0" frameBorder="0" marginWidth="0" marginHeight="0" leftMargin="0" topMargin="0" allowTransparency="true" width="100%" height="99%"></iframe>',PAGE_HTML:'<html dir="{DIR}" lang="{LANG}"><head><title>{TITLE}</title>{META}<base href="{BASE_HREF}"/><style id="editor_css">{DEFAULT_CSS}</style>{EXTRA_CSS}</head><body>{CONTENT}</body></html>',DOC_TYPE:'<!DOCTYPE HTML PUBLIC "-/'+"/W3C/"+"/DTD HTML 4.01/"+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd">',META:'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">',NAME:"frame",ATTRS:{title:{value:"Blank Page"},dir:{value:"ltr"},lang:{value:"en-US"},src:{value:"javascript"+((C.UA.ie)?":false":":")+";"},designMode:{writeOnce:true,value:false},content:{value:"<br>",setter:"_setHTML",getter:"_getHTML"},basehref:{value:false,getter:"_resolveBaseHref"},use:{writeOnce:true,value:["substitute","node","node-style","selector-css3"]},container:{value:"body",setter:function(D){return C.one(D);
}},id:{writeOnce:true,getter:function(D){if(!D){D="iframe-"+C.guid();}return D;}},extracss:{value:"",setter:"_setExtraCSS"},host:{value:false}}});C.Frame=B;},"@VERSION@",{requires:["base","node","selector-css3","substitute"],skinnable:false});},"@VERSION@",{requires:["base","node","selector-css3","substitute"],skinnable:false});YUI.add("selection",function(A){YUI.add("selection",function(C){var B="textContent",E="innerHTML",D="fontFamily";if(C.UA.ie){B="nodeValue";}C.Selection=function(K){var L,J,F,H,G,I;if(C.config.win.getSelection){L=C.config.win.getSelection();}else{if(C.config.doc.selection){L=C.config.doc.selection.createRange();}}this._selection=L;if(L.pasteHTML){this.isCollapsed=(L.compareEndPoints("StartToEnd",L))?false:true;if(this.isCollapsed){this.anchorNode=this.focusNode=C.one(L.parentElement());if(K){F=C.config.doc.elementFromPoint(K.clientX,K.clientY);}if(!F){J=L.parentElement();H=J.childNodes;G=L.duplicate();for(I=0;I<H.length;I++){if(G.inRange(L)){F=H[I];}}}this.ieNode=F;if(F){if(F.nodeType!==3){if(F.firstChild){F=F.firstChild;}}this.anchorNode=this.focusNode=C.Selection.resolve(F);this.anchorOffset=this.focusOffset=(this.anchorNode.nodeValue)?this.anchorNode.nodeValue.length:0;this.anchorTextNode=this.focusTextNode=C.one(F);}}}else{this.isCollapsed=L.isCollapsed;this.anchorNode=C.Selection.resolve(L.anchorNode);this.focusNode=C.Selection.resolve(L.focusNode);this.anchorOffset=L.anchorOffset;this.focusOffset=L.focusOffset;this.anchorTextNode=C.one(L.anchorNode);this.focusTextNode=C.one(L.focusNode);}if(C.Lang.isString(L.text)){this.text=L.text;}else{this.text=L.toString();}};C.Selection.filter=function(F){var I=(new Date()).getTime();var H=C.all(C.Selection.ALL),L=C.all("strong,em"),G={},J="",M;var K=(new Date()).getTime();H.each(function(Q){var P=C.Node.getDOMNode(Q);if(P.style[D]){G["."+Q._yuid]=P.style[D];Q.addClass(Q._yuid);P.style[D]="";P.removeAttribute("face");if(P.getAttribute("style")===""){P.removeAttribute("style");}if(P.getAttribute("style")){if(P.getAttribute("style").toLowerCase()==="font-family: "){P.removeAttribute("style");}}}});var O=(new Date()).getTime();C.each(G,function(Q,P){J+=P+" { font-family: "+Q.replace(/"/gi,"")+"; }";});C.StyleSheet(J,"editor");L.each(function(S,P){var Q=S.get("tagName").toLowerCase(),R="i";if(Q==="strong"){R="b";}C.Selection.prototype._swap(L.item(P),R);});M=C.all("ol,ul");M.each(function(Q,P){var R=Q.all("li");if(!R.size()){Q.remove();}});if(F){C.Selection.filterBlocks();}var N=(new Date()).getTime();};C.Selection.filterBlocks=function(){var G=(new Date()).getTime();var N=C.config.doc.body.childNodes,I,H,Q=false,K=true,F,R,S,P,M,O,T;if(N){for(I=0;I<N.length;I++){H=C.one(N[I]);if(!H.test(C.Selection.BLOCKS)){K=true;if(N[I].nodeType==3){O=N[I][B].match(C.Selection.REG_CHAR);T=N[I][B].match(C.Selection.REG_NON);if(O===null&&T){K=false;}}if(K){if(!Q){Q=[];}Q.push(N[I]);}}else{Q=C.Selection._wrapBlock(Q);}}Q=C.Selection._wrapBlock(Q);}R=C.all("p");if(R.size()===1){S=R.item(0).all("br");if(S.size()===1){S.item(0).remove();var J=R.item(0).get("innerHTML");if(J==""||J==" "){R.set("innerHTML",C.Selection.CURSOR);F=new C.Selection();F.focusCursor(true,true);}}}else{R.each(function(V){var U=V.get("innerHTML");if(U===""){V.remove();}});}if(!C.UA.ie){P=C.all("div, p");P.each(function(V){var U=V.get("innerHTML");if(U===""){V.remove();}else{if(V.get("childNodes").size()==1){if(V.ancestor("p")){V.replace(V.get("firstChild"));}}}});M=C.all(".Apple-style-span, .apple-style-span");M.each(function(U){U.setAttribute("style","");});}var L=(new Date()).getTime();};C.Selection.REG_CHAR=/[a-zA-Z-0-9_]/gi;C.Selection.REG_NON=/[\s\S|\n|\t]/gi;C.Selection._wrapBlock=function(G){if(G){var F=C.Node.create("<p></p>"),I=C.one(G[0]),H;for(H=1;H<G.length;H++){F.append(G[H]);}I.replace(F);F.prepend(I);}return false;};C.Selection.unfilter=function(){var G=C.all("body [class]"),H="",F,I;G.each(function(J){if(J.hasClass(J._yuid)){J.setStyle(D,J.getStyle(D));J.removeClass(J._yuid);if(J.getAttribute("class")===""){J.removeAttribute("class");}}});F=C.all(".yui-non");F.each(function(J){if(J.get("innerHTML")===""){J.remove();}else{J.removeClass("yui-non");}});I=C.all("body [id]");I.each(function(J){if(J.get("id").indexOf("yui_3_")===0){J.removeAttribute("id");J.removeAttribute("_yuid");}});H=C.one("body").get("innerHTML");G.each(function(J){J.addClass(J._yuid);J.setStyle(D,"");if(J.getAttribute("style")===""){J.removeAttribute("style");}});return H;};C.Selection.resolve=function(F){if(F&&F.nodeType===3){F=F.parentNode;}return C.one(F);};C.Selection.getText=function(H){var F=H.get("innerHTML").replace(C.Selection.STRIP_HTML,""),I=F.match(C.Selection.REG_CHAR),G=F.match(C.Selection.REG_NON);if(I===null&&G){F="";}return F;};C.Selection.ALL="[style],font[face]";C.Selection.STRIP_HTML=/<\S[^><]*>/g;C.Selection.BLOCKS="p,div,ul,ol,table,style";C.Selection.TMP="yui-tmp";C.Selection.DEFAULT_TAG="span";C.Selection.CURID="yui-cursor";C.Selection.CUR_WRAPID="yui-cursor-wrapper";C.Selection.CURSOR='<span id="'+C.Selection.CURID+'"><span id="'+C.Selection.CUR_WRAPID+'">&nbsp;</span></span>';C.Selection.cleanCursor=function(){var F=C.config.doc.getElementById(C.Selection.CUR_WRAPID);if(F){F.id="";if(F.innerHTML=="&nbsp;"||F.innerHTML=="<br>"){if(F.parentNode){F.parentNode.removeChild(F);}}}};C.Selection.prototype={text:null,isCollapsed:null,anchorNode:null,anchorOffset:null,anchorTextNode:null,focusNode:null,focusOffset:null,focusTextNode:null,_selection:null,_wrap:function(H,F){var G=C.Node.create("<"+F+"></"+F+">");G.set(E,H.get(E));H.set(E,"");H.append(G);return C.Node.getDOMNode(G);},_swap:function(H,F){var G=C.Node.create("<"+F+"></"+F+">");G.set(E,H.get(E));H.replace(G,H);return C.Node.getDOMNode(G);},getSelected:function(){C.Selection.filter();C.config.doc.execCommand("fontname",null,C.Selection.TMP);var G=C.all(C.Selection.ALL),F=[];G.each(function(I,H){if(I.getStyle(D,C.Selection.TMP)){I.setStyle(D,"");I.removeAttribute("face");if(I.getAttribute("style")===""){I.removeAttribute("style");
}if(!I.test("body")){F.push(C.Node.getDOMNode(G.item(H)));}}});return C.all(F);},insertContent:function(F){return this.insertAtCursor(F,this.anchorTextNode,this.anchorOffset,true);},insertAtCursor:function(L,G,I,O){var Q=C.Node.create("<"+C.Selection.DEFAULT_TAG+' class="yui-non"></'+C.Selection.DEFAULT_TAG+">"),F,J,H,P,K=this.createRange(),N;if(G&&G.test("body")){N=C.Node.create("<span></span>");G.append(N);G=N;}if(K.pasteHTML){P=C.Node.create(L);try{K.pasteHTML('<span id="rte-insert"></span>');}catch(M){}F=C.one("#rte-insert");if(F){F.set("id","");F.replace(P);return P;}else{C.on("available",function(){F.set("id","");F.replace(P);},"#rte-insert");}}else{if(I>0){F=G.get(B);J=C.one(C.config.doc.createTextNode(F.substr(0,I)));H=C.one(C.config.doc.createTextNode(F.substr(I)));G.replace(J,G);P=C.Node.create(L);if(P.get("nodeType")===11){N=C.Node.create("<span></span>");N.append(P);P=N;}J.insert(P,"after");if(H){P.insert(Q,"after");Q.insert(H,"after");this.selectNode(Q,O);}}else{if(G.get("nodeType")===3){G=G.get("parentNode");}P=C.Node.create(L);G.insert(P,"before");}}return P;},wrapContent:function(G){G=(G)?G:C.Selection.DEFAULT_TAG;if(!this.isCollapsed){var I=this.getSelected(),L=[],H,J,K,F;I.each(function(O,M){var N=O.get("tagName").toLowerCase();if(N==="font"){L.push(this._swap(I.item(M),G));}else{L.push(this._wrap(I.item(M),G));}},this);H=this.createRange();K=L[0];J=L[L.length-1];if(this._selection.removeAllRanges){H.setStart(L[0],0);H.setEnd(J,J.childNodes.length);this._selection.removeAllRanges();this._selection.addRange(H);}else{H.moveToElementText(C.Node.getDOMNode(K));F=this.createRange();F.moveToElementText(C.Node.getDOMNode(J));H.setEndPoint("EndToEnd",F);H.select();}L=C.all(L);return L;}else{return C.all([]);}},replace:function(L,J){var G=this.createRange(),K,F,H,I;if(G.getBookmark){H=G.getBookmark();F=this.anchorNode.get("innerHTML").replace(L,J);this.anchorNode.set("innerHTML",F);G.moveToBookmark(H);I=C.one(G.parentElement());}else{K=this.anchorTextNode;F=K.get(B);H=F.indexOf(L);F=F.replace(L,"");K.set(B,F);I=this.insertAtCursor(J,K,H,true);}return I;},remove:function(){this._selection.removeAllRanges();return this;},createRange:function(){if(C.config.doc.selection){return C.config.doc.selection.createRange();}else{return C.config.doc.createRange();}},selectNode:function(I,K,F){F=F||0;I=C.Node.getDOMNode(I);var G=this.createRange();if(G.selectNode){G.selectNode(I);this._selection.removeAllRanges();this._selection.addRange(G);if(K){try{this._selection.collapse(I,F);}catch(H){this._selection.collapse(I,0);}}}else{if(I.nodeType===3){I=I.parentNode;}try{G.moveToElementText(I);}catch(J){}if(K){G.collapse(((F)?false:true));}G.select();}return this;},setCursor:function(){return this.insertContent(C.Selection.CURSOR);},getCursor:function(){return C.one("#"+C.Selection.CURID);},removeCursor:function(F){var G=this.getCursor();if(G){if(F){G.removeAttribute("id");G.set("innerHTML",'<span id="'+C.Selection.CUR_WRAPID+'">&nbsp;</span>');}else{G.remove();}}return G;},focusCursor:function(H,F){if(H!==false){H=true;}if(F!==false){F=true;}var G=this.removeCursor(true);if(G){this.selectNode(G,H,F);}},toString:function(){return"Selection Object";}};});},"@VERSION@",{requires:["node"],skinnable:false});YUI.add("exec-command",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.extend(A,B.Base,{_inst:null,command:function(E,D){var C=A.COMMANDS[E];if(C){return C.call(this,E,D);}else{return this._command(E,D);}},_command:function(E,D){var C=this.getInstance();try{C.config.doc.execCommand(E,false,D);}catch(F){}},getInstance:function(){if(!this._inst){this._inst=this.get("host").getInstance();}return this._inst;},initializer:function(){B.mix(this.get("host"),{execCommand:function(D,C){return this.exec.command(D,C);},_execCommand:function(D,C){return this.exec._command(D,C);}});}},{NAME:"execCommand",NS:"exec",ATTRS:{host:{value:false}},COMMANDS:{wrap:function(E,C){var D=this.getInstance();return(new D.Selection()).wrapContent(C);},inserthtml:function(E,C){var D=this.getInstance();return(new D.Selection()).insertContent(C);},insertandfocus:function(G,D){var F=this.getInstance(),C,E;D+=F.Selection.CURSOR;C=this.command("inserthtml",D);E=new F.Selection();E.focusCursor(true,true);return C;},insertbr:function(E){var D=this.getInstance(),F,C=new D.Selection();C.setCursor();F=C.getCursor();F.insert("<br>","before");C.focusCursor(true,false);return F.previous();},insertimage:function(D,C){return this.command("inserthtml",'<img src="'+C+'">');},addclass:function(E,C){var D=this.getInstance();return(new D.Selection()).getSelected().addClass(C);},removeclass:function(E,C){var D=this.getInstance();return(new D.Selection()).getSelected().removeClass(C);},backcolor:function(E,F){var D=this.getInstance(),C=new D.Selection(),G;if(B.UA.gecko||B.UA.opera){E="hilitecolor";}if(!B.UA.ie){this._command("styleWithCSS","true");}if(C.isCollapsed){if(C.anchorNode&&(C.anchorNode.get("innerHTML")==="&nbsp;")){C.anchorNode.setStyle("backgroundColor",F);G=C.anchorNode;G.set("innerHTML","<br>");}else{G=this.command("inserthtml",'<span style="background-color: '+F+'">'+D.Selection.CURSOR+"</span>");C.focusCursor(true,true);}return G;}else{return this._command(E,F);}if(!B.UA.ie){this._command("styleWithCSS",false);}},hilitecolor:function(){return A.COMMANDS.backcolor.apply(this,arguments);},fontname:function(E,F){var D=this.getInstance(),C=new D.Selection(),G;if(C.isCollapsed){if(C.anchorNode&&(C.anchorNode.get("innerHTML")==="&nbsp;")){C.anchorNode.setStyle("fontFamily",F);G=C.anchorNode;}else{G=this.command("inserthtml",'<span style="font-family: '+F+'">'+D.Selection.CURSOR+"</span>");C.focusCursor(true,true);}return G;}else{return this._command("fontname",F);}},fontsize:function(F,G){var E=this.getInstance(),D=new E.Selection(),H,C;if(D.isCollapsed){H=this.command("inserthtml",'<font size="'+G+'">&nbsp;</font>');C=H.get("previousSibling");if(C&&C.get("nodeType")===3){if(C.get("length")<2){C.remove();}}D.selectNode(H.get("firstChild"),true,false);
return H;}else{return this._command("fontsize",G);}}}});B.namespace("Plugin");B.Plugin.ExecCommand=A;},"@VERSION@",{requires:["frame"],skinnable:false});YUI.add("editor-tab",function(C){var B=function(){B.superclass.constructor.apply(this,arguments);},A="host";C.extend(B,C.Base,{_onNodeChange:function(E){var D="indent";if(E.changedType==="tab"){if(!E.changedNode.test("li, li *")){E.changedEvent.halt();E.preventDefault();if(E.changedEvent.shiftKey){D="outdent";}this.get(A).execCommand(D,"");}}},initializer:function(){this.get(A).on("nodeChange",C.bind(this._onNodeChange,this));}},{NAME:"editorTab",NS:"tab",ATTRS:{host:{value:false}}});C.namespace("Plugin");C.Plugin.EditorTab=B;},"@VERSION@",{requires:["editor-base"],skinnable:false});YUI.add("createlink-base",function(B){var A={};A.STRINGS={PROMPT:"Please enter the URL for the link to point to:",DEFAULT:"http://"};B.namespace("Plugin");B.Plugin.CreateLinkBase=A;B.mix(B.Plugin.ExecCommand.COMMANDS,{createlink:function(H){var G=this.get("host").getInstance(),E,C,F,D=prompt(A.STRINGS.PROMPT,A.STRINGS.DEFAULT);if(D){this.get("host")._execCommand(H,D);F=new G.Selection();E=F.getSelected();if(!F.isCollapsed&&E.size()){C=E.item(0).one("a");if(C){E.item(0).replace(C);}}else{this.get("host").execCommand("inserthtml",'<a href="'+D+'">'+D+"</a>");}}return C;}});},"@VERSION@",{requires:["editor-base"],skinnable:false});YUI.add("editor-base",function(A){YUI.add("editor-base",function(C){var B=function(){B.superclass.constructor.apply(this,arguments);};C.extend(B,C.Base,{frame:null,initializer:function(){var D=new C.Frame({designMode:true,title:B.STRINGS.title,use:B.USE,dir:this.get("dir"),extracss:this.get("extracss"),host:this}).plug(C.Plugin.ExecCommand);D.after("ready",C.bind(this._afterFrameReady,this));this.frame=D;this.publish("nodeChange",{emitFacade:true,bubbles:true,defaultFn:this._defNodeChangeFn});},destructor:function(){this.frame.destroy();this.detachAll();},copyStyles:function(G,F){var D=["color","fontSize","fontFamily","backgroundColor","fontStyle"],E={};C.each(D,function(H){E[H]=G.getStyle(H);});if(G.ancestor("b,strong")){E.fontWeight="bold";}F.setStyles(E);},_defNodeChangeFn:function(Q){var H=(new Date()).getTime();var O=this.getInstance();switch(Q.changedType){case"keydown":O.Selection.cleanCursor();break;case"enter":if(C.UA.webkit){if(Q.changedEvent.shiftKey){this.execCommand("insertbr");Q.changedEvent.preventDefault();}}break;case"tab":if(!Q.changedNode.test("li, li *")&&!Q.changedEvent.shiftKey){Q.changedEvent.preventDefault();var G=new O.Selection();G.setCursor();var R=G.getCursor();R.insert(B.TABKEY,"before");G.focusCursor();}break;case"enter-up":if(Q.changedNode.test("p")){var K=Q.changedNode.previous(),F,S,T=false;if(K){F=K.one(":last-child");while(!T){if(F){S=F.one(":last-child");if(S){F=S;}else{T=true;}}else{T=true;}}if(F){this.copyStyles(F,Q.changedNode);}}}break;}var N=this.getDomPath(Q.changedNode,false),D={},M,E,J=[],L="",I="";if(Q.commands){D=Q.commands;}C.each(N,function(b){var Z=O.Node.getDOMNode(b),V=Z.tagName.toLowerCase(),a=B.TAG2CMD[V];if(a){D[a]=1;}var Y=Z.currentStyle||Z.style;if((""+Y.fontWeight)=="bold"){D.bold=1;}if(Y.fontStyle=="italic"){D.italic=1;}if(Y.textDecoration=="underline"){D.underline=1;}if(Y.textDecoration=="line-through"){D.strikethrough=1;}if(Y.fontFamily){var X=Y.fontFamily.split(",")[0].toLowerCase();if(X){M=X;}if(M){M=M.replace(/'/g,"").replace(/"/g,"");}}E=Y.fontSize;var W=Z.className.split(" ");C.each(W,function(c){if(c!==""&&(c.substr(0,4)!=="yui_")){J.push(c);}});L=B.FILTER_RGB(Y.color);var U=B.FILTER_RGB(Y.backgroundColor);if(U!=="transparent"){I=U;}});Q.dompath=O.all(N);Q.classNames=J;Q.commands=D;if(!Q.fontFamily){Q.fontFamily=M;}if(!Q.fontSize){Q.fontSize=E;}if(!Q.fontColor){Q.fontColor=L;}if(!Q.backgroundColor){Q.backgroundColor=I;}var P=(new Date()).getTime();},getDomPath:function(F,D){var H=[],E,G=this.frame.getInstance();E=G.Node.getDOMNode(F);while(E!==null){if((E===G.config.doc.documentElement)||(E===G.config.doc)||!E.tagName){E=null;break;}if(!G.DOM.inDoc(E)){E=null;break;}if(E.nodeName&&E.nodeType&&(E.nodeType==1)){H.push(E);}if(E==G.config.doc.body){E=null;break;}E=E.parentNode;}if(H.length===0){H[0]=G.config.doc.body;}if(D){return G.all(H.reverse());}else{return H.reverse();}},_afterFrameReady:function(){var D=this.frame.getInstance();this.frame.on("dom:mouseup",C.bind(this._onFrameMouseUp,this));this.frame.on("dom:mousedown",C.bind(this._onFrameMouseDown,this));this.frame.on("dom:keydown",C.bind(this._onFrameKeyDown,this));this.frame.on("dom:keyup",C.throttle(C.bind(this._onFrameKeyUp,this),500));this.frame.on("dom:keypress",C.throttle(C.bind(this._onFrameKeyPress,this),500));D.Selection.filter();this.fire("ready");},_onFrameMouseUp:function(D){this.fire("nodeChange",{changedNode:D.frameTarget,changedType:"mouseup",changedEvent:D.frameEvent});},_onFrameMouseDown:function(D){this.fire("nodeChange",{changedNode:D.frameTarget,changedType:"mousedown",changedEvent:D.frameEvent});},_currentSelection:null,_currentSelectionTimer:null,_currentSelectionClear:null,_onFrameKeyDown:function(F){if(!this._currentSelection){if(this._currentSelectionTimer){this._currentSelectionTimer.cancel();}this._currentSelectionTimer=C.later(850,this,function(){this._currentSelectionClear=true;});var E=this.frame.getInstance(),D=new E.Selection(F);this._currentSelection=D;}else{var D=this._currentSelection;}var E=this.frame.getInstance(),D=new E.Selection();this._currentSelection=D;if(D&&D.anchorNode){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:"keydown",changedEvent:F.frameEvent});if(B.NC_KEYS[F.keyCode]){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:B.NC_KEYS[F.keyCode],changedEvent:F.frameEvent});this.fire("nodeChange",{changedNode:D.anchorNode,changedType:B.NC_KEYS[F.keyCode]+"-down",changedEvent:F.frameEvent});}}},_onFrameKeyPress:function(E){var D=this._currentSelection;if(D&&D.anchorNode){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:"keypress",changedEvent:E.frameEvent});
if(B.NC_KEYS[E.keyCode]){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:B.NC_KEYS[E.keyCode]+"-press",changedEvent:E.frameEvent});}}},_onFrameKeyUp:function(E){var D=this._currentSelection;if(D&&D.anchorNode){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:"keyup",selection:D,changedEvent:E.frameEvent});if(B.NC_KEYS[E.keyCode]){this.fire("nodeChange",{changedNode:D.anchorNode,changedType:B.NC_KEYS[E.keyCode]+"-up",selection:D,changedEvent:E.frameEvent});}}if(this._currentSelectionClear){this._currentSelectionClear=this._currentSelection=null;}},execCommand:function(H,J){var E=this.frame.execCommand(H,J),G=this.frame.getInstance(),F=new G.Selection(),D={},I={changedNode:F.anchorNode,changedType:"execcommand",nodes:E};switch(H){case"forecolor":I.fontColor=J;break;case"backcolor":I.backgroundColor=J;break;case"fontsize":I.fontSize=J;break;case"fontname":I.fontFamily=J;break;}D[H]=1;I.commands=D;this.fire("nodeChange",I);return E;},getInstance:function(){return this.frame.getInstance();},render:function(D){this.frame.set("content",this.get("content"));this.frame.render(D);return this;},focus:function(D){this.frame.focus(D);return this;},show:function(){this.frame.show();return this;},hide:function(){this.frame.hide();return this;},getContent:function(){var D="",E=this.getInstance();if(E&&E.Selection){D=E.Selection.unfilter();}D=D.replace(/ _yuid="([^>]*)"/g,"");return D;}},{TABKEY:'<span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>',FILTER_RGB:function(F){if(F.toLowerCase().indexOf("rgb")!=-1){var I=new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)","gi");var E=F.replace(I,"$1,$2,$3,$4,$5").split(",");if(E.length==5){var H=parseInt(E[1],10).toString(16);var G=parseInt(E[2],10).toString(16);var D=parseInt(E[3],10).toString(16);H=H.length==1?"0"+H:H;G=G.length==1?"0"+G:G;D=D.length==1?"0"+D:D;F="#"+H+G+D;}}return F;},TAG2CMD:{"b":"bold","strong":"bold","i":"italic","em":"italic","u":"underline","sup":"superscript","sub":"subscript","img":"insertimage","a":"createlink","ul":"insertunorderedlist","ol":"insertorderedlist"},NC_KEYS:{8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",46:"delete"},USE:["substitute","node","selector-css3","selection","stylesheet"],NAME:"editorBase",STRINGS:{title:"Rich Text Editor"},ATTRS:{content:{value:"<br>",setter:function(D){if(D.substr(0,1)==="\n"){D=D.substr(1);}if(D===""){D="<br>";}return this.frame.set("content",D);},getter:function(){return this.frame.get("content");}},dir:{writeOnce:true,value:"ltr"},extracss:{value:false,setter:function(D){if(this.frame){this.frame.set("extracss",D);}return D;}}}});C.EditorBase=B;},"@VERSION@",{requires:["base","frame","node","exec-command"],skinnable:false});},"@VERSION@",{requires:["base","frame","node","exec-command"],skinnable:false});YUI.add("editor-lists",function(F){var E=function(){E.superclass.constructor.apply(this,arguments);},B="li",C="ol",D="ul",A="host";F.extend(E,F.Base,{_onNodeChange:function(L){var J=this.get(A).getInstance(),G,O,P,H,I,M,N=false,Q,K=false;if(F.UA.ie&&L.changedType==="enter"){if(L.changedNode.test(B+", "+B+" *")){L.changedEvent.halt();L.preventDefault();O=L.changedNode;P=J.Node.create("<"+B+">"+E.NON+"</"+B+">");if(!O.test(B)){O=O.ancestor(B);}O.insert(P,"after");G=new J.Selection();G.selectNode(P.get("firstChild"),true,false);}}if(L.changedType==="tab"){if(L.changedNode.test(B+", "+B+" *")){L.changedEvent.halt();L.preventDefault();O=L.changedNode;I=L.changedEvent.shiftKey;M=O.ancestor(C+","+D);Q=D;if(M.get("tagName").toLowerCase()===C){Q=C;}if(!O.test(B)){O=O.ancestor(B);}if(I){if(O.ancestor(B)){O.ancestor(B).insert(O,"after");N=true;K=true;}}else{if(O.previous(B)){H=J.Node.create("<"+Q+"></"+Q+">");O.previous(B).append(H);H.append(O);N=true;}}}if(N){if(!O.test(B)){O=O.ancestor(B);}O.all(E.REMOVE).remove();if(F.UA.ie){O=O.append(E.NON).one(E.NON_SEL);}(new J.Selection()).selectNode(O,true,K);}}},initializer:function(){this.get(A).on("nodeChange",F.bind(this._onNodeChange,this));}},{NON:'<span class="yui-non">&nbsp;</span>',NON_SEL:"span.yui-non",REMOVE:"br",NAME:"editorLists",NS:"lists",ATTRS:{host:{value:false}}});F.namespace("Plugin");F.Plugin.EditorLists=E;F.mix(F.Plugin.ExecCommand.COMMANDS,{insertunorderedlist:function(I){var H=this.get("host").getInstance(),G;this.get("host")._execCommand(I,"");},insertorderedlist:function(I){var H=this.get("host").getInstance(),G;this.get("host")._execCommand(I,"");}});},"@VERSION@",{requires:["editor-base"],skinnable:false});YUI.add("editor-bidi",function(H){var G=function(){G.superclass.constructor.apply(this,arguments);},C="host",B="dir",D="BODY",A="nodeChange",F="bidiContextChange",E=D+" > p";H.extend(G,H.Base,{lastDirection:null,firstEvent:null,_checkForChange:function(){var J=this.get(C),L=J.getInstance(),K=new L.Selection(),I,M;if(K.isCollapsed){I=G.blockParent(K.focusNode);M=I.getStyle("direction");if(M!==this.lastDirection){J.fire(F,{changedTo:M});this.lastDirection=M;}}else{J.fire(F,{changedTo:"select"});this.lastDirection=null;}},_afterNodeChange:function(I){if(this.firstEvent||G.EVENTS[I.changedType]){this._checkForChange();this.firstEvent=false;}},_afterMouseUp:function(I){this._checkForChange();this.firstEvent=false;},_fixFirstPara:function(){var I=this.get(C),K=I.getInstance(),J;K.one("body").setContent("<p>"+K.Selection.CURSOR+"</p>");J=new K.Selection();J.focusCursor(true,false);},_onNodeChange:function(N){var L=this.get(C),M=L.getInstance();switch(N.changedType){case"keydown":if(M.config.doc.childNodes.length<2){var I=M.config.doc.body.innerHTML;if(I&&I.length<5&&I.toLowerCase()=="<br>"){this._fixFirstPara();}}break;case"backspace-up":case"delete-up":var O=M.all(E),J,K;if(O.size()<2){K=M.one(D);if(O.item(0)){K=O.item(0);}if(M.Selection.getText(K)===""&&!K.test("p")){this._fixFirstPara();}else{if(K.test("p")&&K.get("innerHTML").length===0){N.changedEvent.halt();}}}break;}},_afterEditorReady:function(){var I=this.get(C),J=I.getInstance();
if(J){J.Selection.filterBlocks();}},_afterContentChange:function(){var I=this.get(C),J=I.getInstance();if(J&&J.Selection){J.Selection.filterBlocks();}},_afterPaste:function(){var I=this.get(C),K=I.getInstance(),J=new K.Selection();J.setCursor();H.later(50,I,function(){K.Selection.filterBlocks();J.focusCursor(true,true);});},initializer:function(){var I=this.get(C);this.firstEvent=true;I.after(A,H.bind(this._afterNodeChange,this));I.on(A,H.bind(this._onNodeChange,this));I.after("dom:mouseup",H.bind(this._afterMouseUp,this));I.after("ready",H.bind(this._afterEditorReady,this));I.after("contentChange",H.bind(this._afterContentChange,this));I.after("dom:paste",H.bind(this._afterPaste,this));}},{EVENTS:{"backspace-up":true,"pageup-up":true,"pagedown-down":true,"end-up":true,"home-up":true,"left-up":true,"up-up":true,"right-up":true,"down-up":true,"delete-up":true},BLOCKS:H.Selection.BLOCKS+",LI,HR,"+D,DIV_WRAPPER:"<DIV></DIV>",blockParent:function(K,J){var I=K,M,L;if(!I){I=H.one(D);}if(!I.test(G.BLOCKS)){I=I.ancestor(G.BLOCKS);}if(J&&I.test(D)){M=H.Node.create(G.DIV_WRAPPER);I.get("children").each(function(O,N){if(N===0){L=O;}else{M.append(O);}});L.replace(M);M.prepend(L);I=M;}return I;},_NODE_SELECTED:"bidiSelected",addParents:function(L){var I,K,J;for(I=0;I<L.length;I+=1){L[I].setData(G._NODE_SELECTED,true);}for(I=0;I<L.length;I+=1){K=L[I].get("parentNode");if(!K.test(D)&&!K.getData(G._NODE_SELECTED)){J=true;K.get("children").some(function(M){if(!M.getData(G._NODE_SELECTED)){J=false;return true;}});if(J){L.push(K);K.setData(G._NODE_SELECTED,true);}}}for(I=0;I<L.length;I+=1){L[I].clearData(G._NODE_SELECTED);}return L;},NAME:"editorBidi",NS:"editorBidi",ATTRS:{host:{value:false}}});H.namespace("Plugin");H.Plugin.EditorBidi=G;H.Plugin.ExecCommand.COMMANDS.bidi=function(M,N){var L=this.getInstance(),K=new L.Selection(),J,P,I,O;L.Selection.filterBlocks();if(K.isCollapsed){P=G.blockParent(K.anchorNode);P.setAttribute(B,N);J=P;}else{I=K.getSelected();O=[];I.each(function(Q){if(!Q.test(D)){O.push(G.blockParent(Q));}});O=L.all(G.addParents(O));O.setAttribute(B,N);J=O;}this.get(C).get(C).editorBidi.checkForChange();return J;};},"@VERSION@",{requires:["editor-base","selection"],skinnable:false});YUI.add("editor",function(A){},"@VERSION@",{skinnable:false,use:["frame","selection","exec-command","editor-base"]});