]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui3/build/editor/editor.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui3 / build / editor / editor.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add("frame",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.extend(A,B.Base,{_ready:null,_rendered:null,_iframe:null,_instance:null,_create:function(C){var I,H,E,G;this._iframe=B.Node.create(A.HTML);this._iframe.setStyle("visibility","hidden");this._iframe.set("src",this.get("src"));this.get("container").append(this._iframe);this._iframe.set("height","99%");var D="",F=((this.get("extracss"))?'<style id="extra_css">'+this.get("extracss")+"</style>":"");D=B.substitute(A.PAGE_HTML,{DIR:this.get("dir"),LANG:this.get("lang"),TITLE:this.get("title"),META:A.META,LINKED_CSS:this.get("linkedcss"),CONTENT:this.get("content"),BASE_HREF:this.get("basehref"),DEFAULT_CSS:A.DEFAULT_CSS,EXTRA_CSS:F});if(B.config.doc.compatMode!="BackCompat"){D=A.getDocType()+"\n"+D;}else{}E=this._resolveWinDoc();E.doc.open();E.doc.write(D);E.doc.close();if(this.get("designMode")){E.doc.designMode="on";}if(!E.doc.documentElement){var J=B.later(1,this,function(){if(E.doc&&E.doc.documentElement){C(E);J.cancel();}},null,true);}else{C(E);}},_resolveWinDoc:function(D){var C=(D)?D:{};C.win=B.Node.getDOMNode(this._iframe.get("contentWindow"));C.doc=B.Node.getDOMNode(this._iframe.get("contentWindow.document"));if(!C.doc){C.doc=B.config.doc;}if(!C.win){C.win=B.config.win;}return C;},_onDomEvent:function(E){var D,C;E.frameX=E.frameY=0;if(E.pageX>0||E.pageY>0){if(E.type.substring(0,3)!=="key"){C=this._instance.one("win");D=this._iframe.getXY();E.frameX=D[0]+E.pageX-C.get("scrollLeft");E.frameY=D[1]+E.pageY-C.get("scrollTop");}}E.frameTarget=E.target;E.frameCurrentTarget=E.currentTarget;E.frameEvent=E;this.fire("dom:"+E.type,E);},initializer:function(){this.publish("ready",{emitFacade:true,defaultFn:this._defReadyFn});},destructor:function(){var C=this.getInstance();C.one("doc").detachAll();C=null;this._iframe.remove();},_DOMPaste:function(F){var D=this.getInstance(),C="",E=D.config.win;if(F._event.originalTarget){C=F._event.originalTarget;}if(F._event.clipboardData){C=F._event.clipboardData.getData("Text");}if(E.clipboardData){C=E.clipboardData.getData("Text");if(C===""){if(!E.clipboardData.setData("Text",C)){C=null;}}}F.frameTarget=F.target;F.frameCurrentTarget=F.currentTarget;F.frameEvent=F;if(C){F.clipboardData={data:C,getData:function(){return C;}};}else{F.clipboardData=null;}this.fire("dom:paste",F);},_defReadyFn:function(){var E=this.getInstance(),C=B.bind(this._onDomEvent,this),D=((B.UA.ie)?B.throttle(C,200):C);E.Node.DOM_EVENTS.activate=1;E.Node.DOM_EVENTS.beforedeactivate=1;E.Node.DOM_EVENTS.focusin=1;E.Node.DOM_EVENTS.deactivate=1;E.Node.DOM_EVENTS.focusout=1;B.each(A.DOM_EVENTS,function(G,F){if(G===1){if(F!=="focus"&&F!=="blur"&&F!=="paste"){if(F.substring(0,3)==="key"){if(F==="keydown"){E.on(F,C,E.config.doc);}else{E.on(F,D,E.config.doc);}}else{E.on(F,C,E.config.doc);}}}},this);E.Node.DOM_EVENTS.paste=1;E.on("paste",B.bind(this._DOMPaste,this),E.one("body"));E.on("focus",C,E.config.win);E.on("blur",C,E.config.win);E._use=E.use;E.use=B.bind(this.use,this);this._iframe.setStyles({visibility:"inherit"});E.one("body").setStyle("display","block");if(B.UA.ie){this._fixIECursors();}},_fixIECursors:function(){var F=this.getInstance(),D=F.all("table"),E=F.all("br"),C;if(D.size()&&E.size()){C=D.item(0).get("sourceIndex");E.each(function(J){var H=J.get("parentNode"),I=H.get("children"),G=H.all(">br");if(H.test("div")){if(I.size()>2){J.replace(F.Node.create("<wbr>"));}else{if(J.get("sourceIndex")>C){if(G.size()){J.replace(F.Node.create("<wbr>"));}}else{if(G.size()>1){J.replace(F.Node.create("<wbr>"));}}}}});}},_onContentReady:function(E){if(!this._ready){this._ready=true;var D=this.getInstance(),C=B.clone(this.get("use"));this.fire("contentready");if(E){D.config.doc=B.Node.getDOMNode(E.target);}C.push(B.bind(function(){if(D.Selection){D.Selection.DEFAULT_BLOCK_TAG=this.get("defaultblock");}this.fire("ready");},this));D.use.apply(D,C);D.one("doc").get("documentElement").addClass("yui-js-enabled");}},_resolveBaseHref:function(C){if(!C||C===""){C=B.config.doc.location.href;if(C.indexOf("?")!==-1){C=C.substring(0,C.indexOf("?"));}C=C.substring(0,C.lastIndexOf("/"))+"/";}return C;},_getHTML:function(C){if(this._ready){var D=this.getInstance();C=D.one("body").get("innerHTML");}return C;},_setHTML:function(C){if(this._ready){var D=this.getInstance();D.one("body").set("innerHTML",C);}else{this.on("contentready",B.bind(function(E,G){var F=this.getInstance();F.one("body").set("innerHTML",E);},this,C));}return C;},_getLinkedCSS:function(C){if(!B.Lang.isArray(C)){C=[C];}var D="";if(!this._ready){B.each(C,function(E){if(E!==""){D+='<link rel="stylesheet" href="'+E+'" type="text/css">';}});}else{D=C;}return D;},_setLinkedCSS:function(C){if(this._ready){var D=this.getInstance();D.Get.css(C);}return C;},_setExtraCSS:function(C){if(this._ready){var E=this.getInstance(),D=E.get("#extra_css");D.remove();E.one("head").append('<style id="extra_css">'+C+"</style>");}return C;},_instanceLoaded:function(D){this._instance=D;this._onContentReady();var E=this._instance.config.doc;if(this.get("designMode")){if(!B.UA.ie){try{E.execCommand("styleWithCSS",false,false);E.execCommand("insertbronreturn",false,false);}catch(C){}}}},use:function(){var E=this.getInstance(),D=B.Array(arguments),C=false;if(B.Lang.isFunction(D[D.length-1])){C=D.pop();}if(C){D.push(function(){C.apply(E,arguments);});}E._use.apply(E,D);},delegate:function(E,D,C,G){var F=this.getInstance();if(!F){return false;}if(!G){G=C;C="body";}return F.delegate(E,D,C,G);},getInstance:function(){return this._instance;},render:function(C){if(this._rendered){return this;}this._rendered=true;if(C){this.set("container",C);}this._create(B.bind(function(G){var I,J,D=B.bind(function(K){this._instanceLoaded(K);},this),F=B.clone(this.get("use")),E={debug:false,win:G.win,doc:G.doc},H=B.bind(function(){E=this._resolveWinDoc(E);I=YUI(E);try{I.use("node-base",D);if(J){clearInterval(J);}}catch(K){J=setInterval(function(){H();},350);}},this);F.push(H);B.use.apply(B,F);},this));return this;
9 },_handleFocus:function(){var D=this.getInstance(),C=new D.Selection();if(C.anchorNode){var F=C.anchorNode,E=F.get("childNodes");if(E.size()==1){if(E.item(0).test("br")){C.selectNode(F,true,false);}if(E.item(0).test("p")){F=E.item(0).one("br.yui-cursor").get("parentNode");C.selectNode(F,true,false);}}}},focus:function(C){if(B.UA.ie){try{B.one("win").focus();this.getInstance().one("win").focus();}catch(E){}if(C===true){this._handleFocus();}if(B.Lang.isFunction(C)){C();}}else{try{B.one("win").focus();B.later(100,this,function(){this.getInstance().one("win").focus();if(C===true){this._handleFocus();}if(B.Lang.isFunction(C)){C();}});}catch(D){}}return this;},show:function(){this._iframe.setStyles({position:"static",left:""});if(B.UA.gecko){try{this._instance.config.doc.designMode="on";}catch(C){}this.focus();}return this;},hide:function(){this._iframe.setStyles({position:"absolute",left:"-999999px"});return this;}},{DOM_EVENTS:{dblclick:1,click:1,paste:1,mouseup:1,mousedown:1,keyup:1,keydown:1,keypress:1,activate:1,deactivate:1,beforedeactivate:1,focusin:1,focusout:1},DEFAULT_CSS:"body { 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}"/>{LINKED_CSS}<style id="editor_css">{DEFAULT_CSS}</style>{EXTRA_CSS}</head><body>{CONTENT}</body></html>',getDocType:function(){var C=B.config.doc.doctype,D=A.DOC_TYPE;if(C){D="<!DOCTYPE "+C.name+((C.publicId)?" "+C.publicId:"")+((C.systemId)?" "+C.systemId:"")+">";}else{if(B.config.doc.all){C=B.config.doc.all[0];if(C.nodeType){if(C.nodeType===8){if(C.nodeValue){if(C.nodeValue.toLowerCase().indexOf("doctype")!==-1){D="<!"+C.nodeValue+">";}}}}}}return D;},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"/>',NAME:"frame",ATTRS:{title:{value:"Blank Page"},dir:{value:"ltr"},lang:{value:"en-US"},src:{value:"javascript"+((B.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(C){return B.one(C);}},node:{readOnly:true,value:null,getter:function(){return this._iframe;}},id:{writeOnce:true,getter:function(C){if(!C){C="iframe-"+B.guid();}return C;}},linkedcss:{value:"",getter:"_getLinkedCSS",setter:"_setLinkedCSS"},extracss:{value:"",setter:"_setExtraCSS"},host:{value:false},defaultblock:{value:"p"}}});B.Frame=A;},"3.3.0",{requires:["base","node","selector-css3","substitute"],skinnable:false});YUI.add("selection",function(B){var A="textContent",D="innerHTML",C="fontFamily";if(B.UA.ie){A="nodeValue";}B.Selection=function(L){var I,M,F,G,E,K;if(B.config.win.getSelection){I=B.config.win.getSelection();}else{if(B.config.doc.selection){I=B.config.doc.selection.createRange();}}this._selection=I;if(I.pasteHTML){this.isCollapsed=(I.compareEndPoints("StartToEnd",I))?false:true;if(this.isCollapsed){this.anchorNode=this.focusNode=B.one(I.parentElement());if(L){F=B.config.doc.elementFromPoint(L.clientX,L.clientY);}if(!F){M=I.parentElement();G=M.childNodes;E=I.duplicate();for(K=0;K<G.length;K++){if(E.inRange(I)){if(!F){F=G[K];}}}}this.ieNode=F;if(F){if(F.nodeType!==3){if(F.firstChild){F=F.firstChild;}if(F&&F.tagName&&F.tagName.toLowerCase()==="body"){if(F.firstChild){F=F.firstChild;}}}this.anchorNode=this.focusNode=B.Selection.resolve(F);this.anchorOffset=this.focusOffset=(this.anchorNode.nodeValue)?this.anchorNode.nodeValue.length:0;this.anchorTextNode=this.focusTextNode=B.one(F);}}else{if(I.htmlText){var J=B.Node.create(I.htmlText);if(J.get("id")){var H=J.get("id");this.anchorNode=this.focusNode=B.one("#"+H);}else{J=J.get("childNodes");this.anchorNode=this.focusNode=J.item(0);}}}}else{this.isCollapsed=I.isCollapsed;this.anchorNode=B.Selection.resolve(I.anchorNode);this.focusNode=B.Selection.resolve(I.focusNode);this.anchorOffset=I.anchorOffset;this.focusOffset=I.focusOffset;this.anchorTextNode=B.one(I.anchorNode);this.focusTextNode=B.one(I.focusNode);}if(B.Lang.isString(I.text)){this.text=I.text;}else{if(I.toString){this.text=I.toString();}else{this.text="";}}};B.Selection.filter=function(E){var H=(new Date()).getTime();var G=B.all(B.Selection.ALL),K=B.all("strong,em"),N=B.config.doc,P=N.getElementsByTagName("hr"),F={},I="",L;var J=(new Date()).getTime();G.each(function(R){var Q=B.Node.getDOMNode(R);if(Q.style[C]){F["."+R._yuid]=Q.style[C];R.addClass(R._yuid);Q.style[C]="inherit";Q.removeAttribute("face");if(Q.getAttribute("style")===""){Q.removeAttribute("style");}if(Q.getAttribute("style")){if(Q.getAttribute("style").toLowerCase()==="font-family: "){Q.removeAttribute("style");}}}});var O=(new Date()).getTime();B.all(".hr").addClass("yui-skip").addClass("yui-non");B.each(P,function(S){var R=N.createElement("div");R.className="hr yui-non yui-skip";R.setAttribute("readonly",true);R.setAttribute("contenteditable",false);if(S.parentNode){S.parentNode.replaceChild(R,S);}var Q=R.style;Q.border="1px solid #ccc";Q.lineHeight="0";Q.fontSize="0";Q.marginTop="5px";Q.marginBottom="5px";Q.marginLeft="0px";Q.marginRight="0px";Q.padding="0";});B.each(F,function(R,Q){I+=Q+" { font-family: "+R.replace(/"/gi,"")+"; }";});B.StyleSheet(I,"editor");K.each(function(T,Q){var R=T.get("tagName").toLowerCase(),S="i";if(R==="strong"){S="b";}B.Selection.prototype._swap(K.item(Q),S);});L=B.all("ol,ul");L.each(function(R,Q){var S=R.all("li");if(!S.size()){R.remove();
10 }});if(E){B.Selection.filterBlocks();}var M=(new Date()).getTime();};B.Selection.filterBlocks=function(){var F=(new Date()).getTime();var M=B.config.doc.body.childNodes,H,G,P=false,J=true,E,Q,R,O,L,N,S;if(M){for(H=0;H<M.length;H++){G=B.one(M[H]);if(!G.test(B.Selection.BLOCKS)){J=true;if(M[H].nodeType==3){N=M[H][A].match(B.Selection.REG_CHAR);S=M[H][A].match(B.Selection.REG_NON);if(N===null&&S){J=false;}}if(J){if(!P){P=[];}P.push(M[H]);}}else{P=B.Selection._wrapBlock(P);}}P=B.Selection._wrapBlock(P);}Q=B.all(B.Selection.DEFAULT_BLOCK_TAG);if(Q.size()===1){R=Q.item(0).all("br");if(R.size()===1){if(!R.item(0).test(".yui-cursor")){R.item(0).remove();}var I=Q.item(0).get("innerHTML");if(I===""||I===" "){Q.set("innerHTML",B.Selection.CURSOR);E=new B.Selection();E.focusCursor(true,true);}}}else{Q.each(function(U){var T=U.get("innerHTML");if(T===""){U.remove();}});}if(!B.UA.ie){}var K=(new Date()).getTime();};B.Selection.REG_CHAR=/[a-zA-Z-0-9_]/gi;B.Selection.REG_NON=/[\s\S|\n|\t]/gi;B.Selection.REG_NOHTML=/<\S[^><]*>/g;B.Selection._wrapBlock=function(F){if(F){var E=B.Node.create("<"+B.Selection.DEFAULT_BLOCK_TAG+"></"+B.Selection.DEFAULT_BLOCK_TAG+">"),H=B.one(F[0]),G;for(G=1;G<F.length;G++){E.append(F[G]);}H.replace(E);E.prepend(H);}return false;};B.Selection.unfilter=function(){var G=B.all("body [class]"),H="",F,I,E=B.one("body");G.each(function(J){if(J.hasClass(J._yuid)){J.setStyle(C,J.getStyle(C));J.removeClass(J._yuid);if(J.getAttribute("class")===""){J.removeAttribute("class");}}});F=B.all(".yui-non");F.each(function(J){if(!J.hasClass("yui-skip")&&J.get("innerHTML")===""){J.remove();}else{J.removeClass("yui-non").removeClass("yui-skip");}});I=B.all("body [id]");I.each(function(J){if(J.get("id").indexOf("yui_3_")===0){J.removeAttribute("id");J.removeAttribute("_yuid");}});if(E){H=E.get("innerHTML");}B.all(".hr").addClass("yui-skip").addClass("yui-non");return H;};B.Selection.resolve=function(F){if(F&&F.nodeType===3){try{F=F.parentNode;}catch(E){F="body";}}return B.one(F);};B.Selection.getText=function(F){var E=F.get("innerHTML").replace(B.Selection.REG_NOHTML,"");E=E.replace("<span><br></span>","").replace("<br>","");return E;};B.Selection.DEFAULT_BLOCK_TAG="p";B.Selection.ALL="[style],font[face]";B.Selection.BLOCKS="p,div,ul,ol,table,style";B.Selection.TMP="yui-tmp";B.Selection.DEFAULT_TAG="span";B.Selection.CURID="yui-cursor";B.Selection.CUR_WRAPID="yui-cursor-wrapper";B.Selection.CURSOR='<span><br class="yui-cursor"></span>';B.Selection.hasCursor=function(){var E=B.all("#"+B.Selection.CUR_WRAPID);return E.size();};B.Selection.cleanCursor=function(){var F,E="br.yui-cursor";F=B.all(E);if(F.size()){F.each(function(G){var I=G.get("parentNode.parentNode.childNodes"),H;if(I.size()>1){G.remove();}else{H=B.Selection.getText(I.item(0));if(H!==""){G.remove();}}});}};B.Selection.prototype={text:null,isCollapsed:null,anchorNode:null,anchorOffset:null,anchorTextNode:null,focusNode:null,focusOffset:null,focusTextNode:null,_selection:null,_wrap:function(G,E){var F=B.Node.create("<"+E+"></"+E+">");F.set(D,G.get(D));G.set(D,"");G.append(F);return B.Node.getDOMNode(F);},_swap:function(G,E){var F=B.Node.create("<"+E+"></"+E+">");F.set(D,G.get(D));G.replace(F,G);return B.Node.getDOMNode(F);},getSelected:function(){B.Selection.filter();B.config.doc.execCommand("fontname",null,B.Selection.TMP);var F=B.all(B.Selection.ALL),E=[];F.each(function(H,G){if(H.getStyle(C)==B.Selection.TMP){H.setStyle(C,"");H.removeAttribute("face");if(H.getAttribute("style")===""){H.removeAttribute("style");}if(!H.test("body")){E.push(B.Node.getDOMNode(F.item(G)));}}});return B.all(E);},insertContent:function(E){return this.insertAtCursor(E,this.anchorTextNode,this.anchorOffset,true);},insertAtCursor:function(K,F,H,N){var P=B.Node.create("<"+B.Selection.DEFAULT_TAG+' class="yui-non"></'+B.Selection.DEFAULT_TAG+">"),E,I,G,O,J=this.createRange(),M;if(F&&F.test("body")){M=B.Node.create("<span></span>");F.append(M);F=M;}if(J.pasteHTML){O=B.Node.create(K);try{J.pasteHTML('<span id="rte-insert"></span>');}catch(L){}E=B.one("#rte-insert");if(E){E.set("id","");E.replace(O);return O;}else{B.on("available",function(){E.set("id","");E.replace(O);},"#rte-insert");}}else{if(H>0){E=F.get(A);I=B.one(B.config.doc.createTextNode(E.substr(0,H)));G=B.one(B.config.doc.createTextNode(E.substr(H)));F.replace(I,F);O=B.Node.create(K);if(O.get("nodeType")===11){M=B.Node.create("<span></span>");M.append(O);O=M;}I.insert(O,"after");if(G){O.insert(P,"after");P.insert(G,"after");this.selectNode(P,N);}}else{if(F.get("nodeType")===3){F=F.get("parentNode");}O=B.Node.create(K);K=F.get("innerHTML").replace(/\n/gi,"");if(K===""||K==="<br>"){F.append(O);}else{if(O.get("parentNode")){F.insert(O,"before");}else{B.one("body").prepend(O);}}if(F.get("firstChild").test("br")){F.get("firstChild").remove();}}}return O;},wrapContent:function(F){F=(F)?F:B.Selection.DEFAULT_TAG;if(!this.isCollapsed){var H=this.getSelected(),K=[],G,I,J,E;H.each(function(N,L){var M=N.get("tagName").toLowerCase();if(M==="font"){K.push(this._swap(H.item(L),F));}else{K.push(this._wrap(H.item(L),F));}},this);G=this.createRange();J=K[0];I=K[K.length-1];if(this._selection.removeAllRanges){G.setStart(K[0],0);G.setEnd(I,I.childNodes.length);this._selection.removeAllRanges();this._selection.addRange(G);}else{G.moveToElementText(B.Node.getDOMNode(J));E=this.createRange();E.moveToElementText(B.Node.getDOMNode(I));G.setEndPoint("EndToEnd",E);G.select();}K=B.all(K);return K;}else{return B.all([]);}},replace:function(K,I){var F=this.createRange(),J,E,G,H;if(F.getBookmark){G=F.getBookmark();E=this.anchorNode.get("innerHTML").replace(K,I);this.anchorNode.set("innerHTML",E);F.moveToBookmark(G);H=B.one(F.parentElement());}else{J=this.anchorTextNode;E=J.get(A);G=E.indexOf(K);E=E.replace(K,"");J.set(A,E);H=this.insertAtCursor(I,J,G,true);}return H;},remove:function(){this._selection.removeAllRanges();return this;},createRange:function(){if(B.config.doc.selection){return B.config.doc.selection.createRange();}else{return B.config.doc.createRange();
11 }},selectNode:function(H,J,E){if(!H){return;}E=E||0;H=B.Node.getDOMNode(H);var F=this.createRange();if(F.selectNode){F.selectNode(H);this._selection.removeAllRanges();this._selection.addRange(F);if(J){try{this._selection.collapse(H,E);}catch(G){this._selection.collapse(H,0);}}}else{if(H.nodeType===3){H=H.parentNode;}try{F.moveToElementText(H);}catch(I){}if(J){F.collapse(((E)?false:true));}F.select();}return this;},setCursor:function(){this.removeCursor(false);return this.insertContent(B.Selection.CURSOR);},getCursor:function(){return B.all("#"+B.Selection.CURID);},removeCursor:function(E){var F=this.getCursor();if(F){if(E){F.removeAttribute("id");F.set("innerHTML",'<br class="yui-cursor">');}else{F.remove();}}return F;},focusCursor:function(G,E){if(G!==false){G=true;}if(E!==false){E=true;}var F=this.removeCursor(true);if(F){F.each(function(H){this.selectNode(H,G,E);},this);}},toString:function(){return"Selection Object";}};},"3.3.0",{requires:["node"],skinnable:false});YUI.add("exec-command",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.extend(A,B.Base,{_lastKey:null,_inst:null,command:function(F,E){var D=A.COMMANDS[F];if(D){return D.call(this,F,E);}else{return this._command(F,E);}},_command:function(F,E){var D=this.getInstance();try{try{D.config.doc.execCommand("styleWithCSS",null,1);}catch(I){try{D.config.doc.execCommand("useCSS",null,0);}catch(H){}}D.config.doc.execCommand(F,null,E);}catch(G){}},getInstance:function(){if(!this._inst){this._inst=this.get("host").getInstance();}return this._inst;},initializer:function(){B.mix(this.get("host"),{execCommand:function(E,D){return this.exec.command(E,D);},_execCommand:function(E,D){return this.exec._command(E,D);}});this.get("host").on("dom:keypress",B.bind(function(D){this._lastKey=D.keyCode;},this));}},{NAME:"execCommand",NS:"exec",ATTRS:{host:{value:false}},COMMANDS:{wrap:function(F,D){var E=this.getInstance();return(new E.Selection()).wrapContent(D);},inserthtml:function(F,D){var E=this.getInstance();if(E.Selection.hasCursor()||B.UA.ie){return(new E.Selection()).insertContent(D);}else{this._command("inserthtml",D);}},insertandfocus:function(H,E){var G=this.getInstance(),D,F;if(G.Selection.hasCursor()){E+=G.Selection.CURSOR;D=this.command("inserthtml",E);F=new G.Selection();F.focusCursor(true,true);}else{this.command("inserthtml",E);}return D;},insertbr:function(F){var E=this.getInstance(),G,D=new E.Selection();D.setCursor();G=D.getCursor();G.insert("<br>","before");D.focusCursor(true,false);return((G&&G.previous)?G.previous():null);},insertimage:function(E,D){return this.command("inserthtml",'<img src="'+D+'">');},addclass:function(F,D){var E=this.getInstance();return(new E.Selection()).getSelected().addClass(D);},removeclass:function(F,D){var E=this.getInstance();return(new E.Selection()).getSelected().removeClass(D);},forecolor:function(F,G){var E=this.getInstance(),D=new E.Selection(),H;if(!B.UA.ie){this._command("useCSS",false);}if(E.Selection.hasCursor()){if(D.isCollapsed){if(D.anchorNode&&(D.anchorNode.get("innerHTML")==="&nbsp;")){D.anchorNode.setStyle("color",G);H=D.anchorNode;}else{H=this.command("inserthtml",'<span style="color: '+G+'">'+E.Selection.CURSOR+"</span>");D.focusCursor(true,true);}return H;}else{return this._command(F,G);}}else{this._command(F,G);}},backcolor:function(F,G){var E=this.getInstance(),D=new E.Selection(),H;if(B.UA.gecko||B.UA.opera){F="hilitecolor";}if(!B.UA.ie){this._command("useCSS",false);}if(E.Selection.hasCursor()){if(D.isCollapsed){if(D.anchorNode&&(D.anchorNode.get("innerHTML")==="&nbsp;")){D.anchorNode.setStyle("backgroundColor",G);H=D.anchorNode;}else{H=this.command("inserthtml",'<span style="background-color: '+G+'">'+E.Selection.CURSOR+"</span>");D.focusCursor(true,true);}return H;}else{return this._command(F,G);}}else{this._command(F,G);}},hilitecolor:function(){return A.COMMANDS.backcolor.apply(this,arguments);},fontname:function(F,G){this._command("fontname",G);var E=this.getInstance(),D=new E.Selection();if(D.isCollapsed&&(this._lastKey!=32)){if(D.anchorNode.test("font")){D.anchorNode.set("face",G);}}},fontsize:function(F,H){this._command("fontsize",H);var E=this.getInstance(),D=new E.Selection();if(D.isCollapsed&&D.anchorNode&&(this._lastKey!=32)){if(B.UA.webkit){if(D.anchorNode.getStyle("lineHeight")){D.anchorNode.setStyle("lineHeight","");}}if(D.anchorNode.test("font")){D.anchorNode.set("size",H);}else{if(B.UA.gecko){var G=D.anchorNode.ancestor(E.Selection.DEFAULT_BLOCK_TAG);if(G){G.setStyle("fontSize","");}}}}}}});var C=function(I,Q,N){var J=this.getInstance(),O=J.config.doc,G=O.selection.createRange(),F=O.queryCommandValue(I),K,E,H,D,L,P,M;if(F){K=G.htmlText;E=new RegExp(N,"g");H=K.match(E);if(H){K=K.replace(N+";","").replace(N,"");G.pasteHTML('<var id="yui-ie-bs">');D=O.getElementById("yui-ie-bs");L=O.createElement("div");P=O.createElement(Q);L.innerHTML=K;if(D.parentNode!==J.config.doc.body){D=D.parentNode;}M=L.childNodes;D.parentNode.replaceChild(P,D);B.each(M,function(R){P.appendChild(R);});G.collapse();G.moveToElementText(P);G.select();}}this._command(I);};if(B.UA.ie){A.COMMANDS.bold=function(){C.call(this,"bold","b","FONT-WEIGHT: bold");};A.COMMANDS.italic=function(){C.call(this,"italic","i","FONT-STYLE: italic");};A.COMMANDS.underline=function(){C.call(this,"underline","u","TEXT-DECORATION: underline");};}B.namespace("Plugin");B.Plugin.ExecCommand=A;},"3.3.0",{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;},"3.3.0",{requires:["editor-base"],skinnable:false});
12 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(I){var H=this.get("host").getInstance(),E,C,G,F,D=prompt(A.STRINGS.PROMPT,A.STRINGS.DEFAULT);if(D){F=H.config.doc.createElement("div");D=H.config.doc.createTextNode(D);F.appendChild(D);D=F.innerHTML;this.get("host")._execCommand(I,D);G=new H.Selection();E=G.getSelected();if(!G.isCollapsed&&E.size()){C=E.item(0).one("a");if(C){E.item(0).replace(C);}if(B.UA.gecko){if(C.get("parentNode").test("span")){if(C.get("parentNode").one("br.yui-cursor")){C.get("parentNode").insert(C,"before");}}}}else{this.get("host").execCommand("inserthtml",'<a href="'+D+'">'+D+"</a>");}}return C;}});},"3.3.0",{requires:["editor-base"],skinnable:false});YUI.add("editor-base",function(D){var C=function(){C.superclass.constructor.apply(this,arguments);},B=":last-child",A="body";D.extend(C,D.Base,{frame:null,initializer:function(){var E=new D.Frame({designMode:true,title:C.STRINGS.title,use:C.USE,dir:this.get("dir"),extracss:this.get("extracss"),linkedcss:this.get("linkedcss"),defaultblock:this.get("defaultblock"),host:this}).plug(D.Plugin.ExecCommand);E.after("ready",D.bind(this._afterFrameReady,this));E.addTarget(this);this.frame=E;this.publish("nodeChange",{emitFacade:true,bubbles:true,defaultFn:this._defNodeChangeFn});},destructor:function(){this.frame.destroy();this.detachAll();},copyStyles:function(H,G){if(H.test("a")){return;}var E=["color","fontSize","fontFamily","backgroundColor","fontStyle"],F={};D.each(E,function(I){F[I]=H.getStyle(I);});if(H.ancestor("b,strong")){F.fontWeight="bold";}if(H.ancestor("u")){if(!F.textDecoration){F.textDecoration="underline";}}G.setStyles(F);},_lastBookmark:null,_resolveChangedNode:function(I){var H=this.getInstance(),F,E,G;if(H&&I&&I.test("html")){F=H.one(A).one(B);while(!G){if(F){E=F.one(B);if(E){F=E;}else{G=true;}}else{G=true;}}if(F){if(F.test("br")){if(F.previous()){F=F.previous();}else{F=F.get("parentNode");}}if(F){I=F;}}}return I;},_defNodeChangeFn:function(R){var I=(new Date()).getTime();var P=this.getInstance(),H,S,O=P.Selection.DEFAULT_BLOCK_TAG;if(D.UA.ie){try{H=P.config.doc.selection.createRange();if(H.getBookmark){this._lastBookmark=H.getBookmark();}}catch(F){}}R.changedNode=this._resolveChangedNode(R.changedNode);switch(R.changedType){case"keydown":if(!D.UA.gecko){if(!C.NC_KEYS[R.changedEvent.keyCode]&&!R.changedEvent.shiftKey&&!R.changedEvent.ctrlKey&&(R.changedEvent.keyCode!==13)){}}break;case"tab":if(!R.changedNode.test("li, li *")&&!R.changedEvent.shiftKey){R.changedEvent.frameEvent.preventDefault();if(D.UA.webkit){this.execCommand("inserttext","\t");}else{if(D.UA.gecko){this.frame.exec._command("inserthtml","<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");}else{if(D.UA.ie){H=new P.Selection();H._selection.pasteHTML(C.TABKEY);}}}}break;}if(D.UA.webkit&&R.commands&&(R.commands.indent||R.commands.outdent)){var T=P.all(".webkit-indent-blockquote");if(T.size()){T.setStyle("margin","");}}var N=this.getDomPath(R.changedNode,false),E={},M,G,K=[],L="",J="";if(R.commands){E=R.commands;}D.each(N,function(Z){var V=Z.tagName.toLowerCase(),a=C.TAG2CMD[V];if(a){E[a]=1;}var Y=Z.currentStyle||Z.style;if((""+Y.fontWeight)=="bold"){E.bold=1;}if(D.UA.ie){if(Y.fontWeight>400){E.bold=1;}}if(Y.fontStyle=="italic"){E.italic=1;}if(Y.textDecoration=="underline"){E.underline=1;}if(Y.textDecoration=="line-through"){E.strikethrough=1;}var b=P.one(Z);if(b.getStyle("fontFamily")){var X=b.getStyle("fontFamily").split(",")[0].toLowerCase();if(X){M=X;}if(M){M=M.replace(/'/g,"").replace(/"/g,"");}}G=C.NORMALIZE_FONTSIZE(b);var W=Z.className.split(" ");D.each(W,function(c){if(c!==""&&(c.substr(0,4)!=="yui_")){K.push(c);}});L=C.FILTER_RGB(b.getStyle("color"));var U=C.FILTER_RGB(Y.backgroundColor);if(U!=="transparent"){if(U!==""){J=U;}}});R.dompath=P.all(N);R.classNames=K;R.commands=E;if(!R.fontFamily){R.fontFamily=M;}if(!R.fontSize){R.fontSize=G;}if(!R.fontColor){R.fontColor=L;}if(!R.backgroundColor){R.backgroundColor=J;}var Q=(new Date()).getTime();},getDomPath:function(G,E){var I=[],F,H=this.frame.getInstance();F=H.Node.getDOMNode(G);while(F!==null){if((F===H.config.doc.documentElement)||(F===H.config.doc)||!F.tagName){F=null;break;}if(!H.DOM.inDoc(F)){F=null;break;}if(F.nodeName&&F.nodeType&&(F.nodeType==1)){I.push(F);}if(F==H.config.doc.body){F=null;break;}F=F.parentNode;}if(I.length===0){I[0]=H.config.doc.body;}if(E){return H.all(I.reverse());}else{return I.reverse();}},_afterFrameReady:function(){var E=this.frame.getInstance();this.frame.on("dom:mouseup",D.bind(this._onFrameMouseUp,this));this.frame.on("dom:mousedown",D.bind(this._onFrameMouseDown,this));this.frame.on("dom:keydown",D.bind(this._onFrameKeyDown,this));if(D.UA.ie){this.frame.on("dom:activate",D.bind(this._onFrameActivate,this));this.frame.on("dom:beforedeactivate",D.bind(this._beforeFrameDeactivate,this));}this.frame.on("dom:keyup",D.bind(this._onFrameKeyUp,this));this.frame.on("dom:keypress",D.bind(this._onFrameKeyPress,this));E.Selection.filter();this.fire("ready");},_beforeFrameDeactivate:function(){var F=this.getInstance(),E=F.config.doc.selection.createRange();if((!E.compareEndPoints("StartToEnd",E))){E.pasteHTML('<var id="yui-ie-cursor">');}},_onFrameActivate:function(){var G=this.getInstance(),F=new G.Selection(),E=F.createRange(),H=G.all("#yui-ie-cursor");if(H.size()){H.each(function(I){I.set("id","");E.moveToElementText(I._node);E.move("character",-1);E.move("character",1);E.select();E.text="";I.remove();});}},_onFrameMouseUp:function(E){this.fire("nodeChange",{changedNode:E.frameTarget,changedType:"mouseup",changedEvent:E.frameEvent});},_onFrameMouseDown:function(E){this.fire("nodeChange",{changedNode:E.frameTarget,changedType:"mousedown",changedEvent:E.frameEvent});},_currentSelection:null,_currentSelectionTimer:null,_currentSelectionClear:null,_onFrameKeyDown:function(G){var F,E;
13 if(!this._currentSelection){if(this._currentSelectionTimer){this._currentSelectionTimer.cancel();}this._currentSelectionTimer=D.later(850,this,function(){this._currentSelectionClear=true;});F=this.frame.getInstance();E=new F.Selection(G);this._currentSelection=E;}else{E=this._currentSelection;}F=this.frame.getInstance();E=new F.Selection();this._currentSelection=E;if(E&&E.anchorNode){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:"keydown",changedEvent:G.frameEvent});if(C.NC_KEYS[G.keyCode]){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:C.NC_KEYS[G.keyCode],changedEvent:G.frameEvent});this.fire("nodeChange",{changedNode:E.anchorNode,changedType:C.NC_KEYS[G.keyCode]+"-down",changedEvent:G.frameEvent});}}},_onFrameKeyPress:function(F){var E=this._currentSelection;if(E&&E.anchorNode){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:"keypress",changedEvent:F.frameEvent});if(C.NC_KEYS[F.keyCode]){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:C.NC_KEYS[F.keyCode]+"-press",changedEvent:F.frameEvent});}}},_onFrameKeyUp:function(F){var E=this._currentSelection;if(E&&E.anchorNode){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:"keyup",selection:E,changedEvent:F.frameEvent});if(C.NC_KEYS[F.keyCode]){this.fire("nodeChange",{changedNode:E.anchorNode,changedType:C.NC_KEYS[F.keyCode]+"-up",selection:E,changedEvent:F.frameEvent});}}if(this._currentSelectionClear){this._currentSelectionClear=this._currentSelection=null;}},execCommand:function(I,K){var F=this.frame.execCommand(I,K),H=this.frame.getInstance(),G=new H.Selection(),E={},J={changedNode:G.anchorNode,changedType:"execcommand",nodes:F};switch(I){case"forecolor":J.fontColor=K;break;case"backcolor":J.backgroundColor=K;break;case"fontsize":J.fontSize=K;break;case"fontname":J.fontFamily=K;break;}E[I]=1;J.commands=E;this.fire("nodeChange",J);return F;},getInstance:function(){return this.frame.getInstance();},render:function(E){this.frame.set("content",this.get("content"));this.frame.render(E);return this;},focus:function(E){this.frame.focus(E);return this;},show:function(){this.frame.show();return this;},hide:function(){this.frame.hide();return this;},getContent:function(){var E="",F=this.getInstance();if(F&&F.Selection){E=F.Selection.unfilter();}E=E.replace(/ _yuid="([^>]*)"/g,"");return E;}},{NORMALIZE_FONTSIZE:function(G){var E=G.getStyle("fontSize"),F=E;switch(E){case"-webkit-xxx-large":E="48px";break;case"xx-large":E="32px";break;case"x-large":E="24px";break;case"large":E="18px";break;case"medium":E="16px";break;case"small":E="13px";break;case"x-small":E="10px";break;}if(F!==E){G.setStyle("fontSize",E);}return E;},TABKEY:'<span class="tab">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>',FILTER_RGB:function(G){if(G.toLowerCase().indexOf("rgb")!=-1){var J=new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)","gi");var F=G.replace(J,"$1,$2,$3,$4,$5").split(",");if(F.length==5){var I=parseInt(F[1],10).toString(16);var H=parseInt(F[2],10).toString(16);var E=parseInt(F[3],10).toString(16);I=I.length==1?"0"+I:I;H=H.length==1?"0"+H:H;E=E.length==1?"0"+E:E;G="#"+I+H+E;}}return G;},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 class="yui-cursor">',setter:function(E){if(E.substr(0,1)==="\n"){E=E.substr(1);}if(E===""){E='<br class="yui-cursor">';}if(E===" "){if(D.UA.gecko){E='<br class="yui-cursor">';}}return this.frame.set("content",E);},getter:function(){return this.frame.get("content");}},dir:{writeOnce:true,value:"ltr"},linkedcss:{value:"",setter:function(E){if(this.frame){this.frame.set("linkedcss",E);}return E;}},extracss:{value:false,setter:function(E){if(this.frame){this.frame.set("extracss",E);}return E;}},defaultblock:{value:"p"}}});D.EditorBase=C;},"3.3.0",{requires:["base","frame","node","exec-command","selection","editor-para"],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,"");}});},"3.3.0",{requires:["editor-base"],skinnable:false});
14 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;},initializer:function(){var I=this.get(C);this.firstEvent=true;I.after(A,H.bind(this._afterNodeChange,this));I.after("dom:mouseup",H.bind(this._afterMouseUp,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(L,P){var O=this.getInstance(),J=new O.Selection(),I,M,N,Q,K;O.Selection.filterBlocks();if(J.isCollapsed){M=G.blockParent(J.anchorNode);if(!P){K=M.getAttribute(B);if(!K||K=="ltr"){P="rtl";}else{P="ltr";}}M.setAttribute(B,P);I=M;}else{N=J.getSelected();Q=[];N.each(function(R){Q.push(G.blockParent(R));});Q=O.all(G.addParents(Q));Q.setAttribute(B,P);I=Q;}this.get(C).get(C).editorBidi._checkForChange();return I;};},"3.3.0",{requires:["editor-base"],skinnable:false});YUI.add("editor-para",function(A){var D=function(){D.superclass.constructor.apply(this,arguments);},K="host",F="body",C="nodeChange",J="parentNode",B=F+" > p",H="p",G="<br>",I="firstChild",E="li";A.extend(D,A.Base,{_fixFirstPara:function(){var L=this.get(K),N=L.getInstance(),M;N.one("body").set("innerHTML","<"+H+">"+N.Selection.CURSOR+"</"+H+">");var O=N.one(B);M=new N.Selection();M.selectNode(O,true,false);},_onNodeChange:function(u){var g=this.get(K),P=g.getInstance(),V,c,a,w,q,i=P.Selection.DEFAULT_BLOCK_TAG,X,N,R,r,T,L,h,m,S,o,y,v,k,Z,Y,s=":last-child";switch(u.changedType){case"enter-up":var M=((this._lastPara)?this._lastPara:u.changedNode),x=M.one("br.yui-cursor");if(this._lastPara){delete this._lastPara;}if(x){if(x.previous()||x.next()){x.remove();}}if(!M.test(i)){var f=M.ancestor(i);if(f){M=f;f=null;}}if(M.test(i)){var j=M.previous(),l,U,W=false;if(j){l=j.one(s);while(!W){if(l){U=l.one(s);if(U){l=U;}else{W=true;}}else{W=true;}}if(l){g.copyStyles(l,M);}}}break;case"enter":if(A.UA.webkit){if(u.changedEvent.shiftKey){g.execCommand("insertbr");u.changedEvent.preventDefault();}}if(A.UA.gecko&&g.get("defaultblock")!=="p"){a=u.changedNode;if(!a.test(E)&&!a.ancestor(E)){if(!a.test(i)){a=a.ancestor(i);}w=P.Node.create("<"+i+"></"+i+">");a.insert(w,"after");q=new P.Selection();if(q.anchorOffset){X=q.anchorNode.get("textContent");c=P.one(P.config.doc.createTextNode(X.substr(0,q.anchorOffset)));N=P.one(P.config.doc.createTextNode(X.substr(q.anchorOffset)));r=q.anchorNode;r.setContent("");L=r.cloneNode();L.append(N);h=false;S=r;while(!h){S=S.get(J);if(S&&!S.test(i)){m=S.cloneNode();m.set("innerHTML","");m.append(L);R=S.get("childNodes");var Q=false;R.each(function(b){if(Q){m.append(b);}if(b===r){Q=true;}});r=S;L=m;}else{h=true;}}N=L;q.anchorNode.append(c);if(N){w.append(N);}}if(w.get(I)){w=w.get(I);}w.prepend(P.Selection.CURSOR);q.focusCursor(true,true);V=P.Selection.getText(w);if(V!==""){P.Selection.cleanCursor();}u.changedEvent.preventDefault();}}break;case"keydown":if(P.config.doc.childNodes.length<2){var O=P.config.doc.body.innerHTML;if(O&&O.length<5&&O.toLowerCase()==G){this._fixFirstPara();}}break;case"backspace-up":case"backspace-down":case"delete-up":if(!A.UA.ie){o=P.all(B);v=P.one(F);if(o.item(0)){v=o.item(0);}y=v.one("br");if(y){y.removeAttribute("id");y.removeAttribute("class");}c=P.Selection.getText(v);c=c.replace(/ /g,"").replace(/\n/g,"");Z=v.all("img");if(c.length===0&&!Z.size()){if(!v.test(H)){this._fixFirstPara();}k=null;if(u.changedNode&&u.changedNode.test(H)){k=u.changedNode;}if(!k&&g._lastPara&&g._lastPara.inDoc()){k=g._lastPara;}if(k&&!k.test(H)){k=k.ancestor(H);}if(k){if(!k.previous()&&k.get(J)&&k.get(J).test(F)){u.changedEvent.frameEvent.halt();}}}if(A.UA.webkit){if(u.changedNode){v=u.changedNode;if(v.test("li")&&(!v.previous()&&!v.next())){V=v.get("innerHTML").replace(G,"");if(V===""){if(v.get(J)){v.get(J).replace(P.Node.create(G));u.changedEvent.frameEvent.halt();u.preventDefault();P.Selection.filterBlocks();}}}}}}if(A.UA.gecko){w=u.changedNode;Y=P.config.doc.createTextNode(" ");w.appendChild(Y);w.removeChild(Y);}break;}if(A.UA.gecko){if(u.changedNode&&!u.changedNode.test(i)){var k=u.changedNode.ancestor(i);if(k){this._lastPara=k;}}}},_afterEditorReady:function(){var M=this.get(K),N=M.getInstance(),L;if(N){N.Selection.filterBlocks();L=N.Selection.DEFAULT_BLOCK_TAG;B=F+" > "+L;H=L;}},_afterContentChange:function(){var L=this.get(K),M=L.getInstance();if(M&&M.Selection){M.Selection.filterBlocks();}},_afterPaste:function(){var L=this.get(K),N=L.getInstance(),M=new N.Selection();
15 A.later(50,L,function(){N.Selection.filterBlocks();});},initializer:function(){var L=this.get(K);if(L.editorBR){A.error("Can not plug EditorPara and EditorBR at the same time.");return;}L.on(C,A.bind(this._onNodeChange,this));L.after("ready",A.bind(this._afterEditorReady,this));L.after("contentChange",A.bind(this._afterContentChange,this));if(A.Env.webkit){L.after("dom:paste",A.bind(this._afterPaste,this));}}},{NAME:"editorPara",NS:"editorPara",ATTRS:{host:{value:false}}});A.namespace("Plugin");A.Plugin.EditorPara=D;},"3.3.0",{requires:["node"],skinnable:false});YUI.add("editor-br",function(C){var D=function(){D.superclass.constructor.apply(this,arguments);},A="host",B="li";C.extend(D,C.Base,{_onKeyDown:function(I){if(I.stopped){I.halt();return;}if(I.keyCode==13){var F=this.get(A),H=F.getInstance(),G=new H.Selection(),E="";if(G){if(C.UA.ie){if(!G.anchorNode||(!G.anchorNode.test(B)&&!G.anchorNode.ancestor(B))){G._selection.pasteHTML("<br>");G._selection.collapse(false);G._selection.select();I.halt();}}if(C.UA.webkit){if(!G.anchorNode.test(B)&&!G.anchorNode.ancestor(B)){F.frame._execCommand("insertlinebreak",null);I.halt();}}}}},_afterEditorReady:function(){var E=this.get(A).getInstance();try{E.config.doc.execCommand("insertbronreturn",null,true);}catch(F){}if(C.UA.ie||C.UA.webkit){E.on("keydown",C.bind(this._onKeyDown,this),E.config.doc);}},_onNodeChange:function(G){switch(G.changedType){case"backspace-up":case"backspace-down":case"delete-up":var F=this.get(A).getInstance();var H=G.changedNode;var E=F.config.doc.createTextNode(" ");H.appendChild(E);H.removeChild(E);break;}},initializer:function(){var E=this.get(A);if(E.editorPara){C.error("Can not plug EditorBR and EditorPara at the same time.");return;}E.after("ready",C.bind(this._afterEditorReady,this));if(C.UA.gecko){E.on("nodeChange",C.bind(this._onNodeChange,this));}}},{NAME:"editorBR",NS:"editorBR",ATTRS:{host:{value:false}}});C.namespace("Plugin");C.Plugin.EditorBR=D;},"3.3.0",{requires:["node"],skinnable:false});YUI.add("editor",function(A){},"3.3.0",{skinnable:false,use:["frame","selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","createlink-base"]});