AUI.add("aui-editable",function(D){var H=D.Lang,J=H.String,B=H.isFunction,E=D.ClassNameManager.getClassName,F="hover",L="editable",C=E(L,"editing"),G=E(L,F),I="contentBox";var K=D.Component.create({NAME:L,ATTRS:{cancelButton:{valueFn:function(){var A=this;return{id:"cancel",icon:"circle-close",handler:{context:A,fn:A.cancel}};}},contentText:{value:"",setter:function(M){var A=this;M=H.trim(M);A._toText(M);return M;}},formatInput:{value:null,validator:B},formatOutput:{value:null,validator:B},node:{setter:function(M){var A=D.one(M);if(!A){D.error("AUI.Editable: Invalid Node Given: "+M);}else{A=A.item(0);}return A;}},eventType:{value:"click"},renderTo:{value:document.body,setter:function(N){var A=this;var M;if(N=="node"){M=A.get(N);}else{M=D.one(N);}if(!M){D.error("AUI.Editable: Invalid renderTo Given: "+N);}else{M=M.item(0);}return M;}},saveButton:{valueFn:function(){var A=this;return{id:"save",icon:"circle-check",handler:{context:A,fn:A.save}};}},icons:{value:[]},inputType:{value:"text",setter:function(M){var A=this;if(M!="text"&&M!="textarea"){M=D.Attribute.INVALID_VALUE;}return M;}},visible:{value:false}},UI_ATTRS:["node"],prototype:{initializer:function(){var A=this;A._uiSetNode(A.get("node"));A._createEvents();},renderUI:function(){var A=this;var M=A.get(I);var O=A.get("inputType");var Q={};var N=A.get("icons");if(N!==false){var S=A.get("cancelButton");var P=A.get("saveButton");if(S!==false){N.push(S);}if(P!==false){N.push(P);}Q.icons=N;}if(O!="text"){D.mix(Q,{field:{autoSize:true},fieldWidget:D.Textarea});}var R=new D.Combobox(Q).render(M);A._comboBox=R;A.inputNode=R.get("node");},bindUI:function(){var A=this;var M=A.get(I);var O=A.get("node");var N=A.inputNode;N.on("keypress",A._onKeypressEditable,A);A.after("contentTextChange",A._syncContentText);M.swallowEvent("click");D.getDoc().after("click",A._afterFocusedChangeEditable,A);},syncUI:function(){var A=this;var M=A.get("node").get("innerHTML");M=M.replace(/\n|\r/gim,"");M=H.trim(M);M=A._toText(M);A._setInput(M);A.set("contentText",M,{initial:true});},cancel:function(){var A=this;A.fire("cancel");},save:function(M){var A=this;A.fire("save");},_afterFocusedChangeEditable:function(M){var A=this;A.fire("stopEditing",A.get("visible"));},_createEvents:function(){var A=this;A.publish("startEditing",{bubbles:true,defaultFn:A._defStartEditingFn,emitFacade:true,queable:false});A.publish("stopEditing",{bubbles:true,defaultFn:A._defStopEditingFn,emitFacade:true,queable:false});A.publish("save",{bubbles:true,defaultFn:A._defSaveFn,emitFacade:true,queable:false});A.publish("cancel",{bubbles:true,defaultFn:A._defCancelFn,emitFacade:true,queable:false});},_defCancelFn:function(M){var A=this;A.fire("stopEditing",false);},_defStartEditingFn:function(A){var S=this;var P=S.get("boundingBox");var O=S.get("node");var Q=S.inputNode;var M=O.get("offsetHeight");var R=O.get("offsetWidth");S.show();O.addClass(C);var T=O.getXY();P.setStyles({height:M+"px",left:T[0]+"px",top:T[1]+"px",width:R+"px"});var N=S._comboBox._field;N.set("width",R);N.fire("adjustSize");Q.focus();Q.select();},_defStopEditingFn:function(N,M){var A=this;A.hide();A.get("node").removeClass(C);if(M){A.set("contentText",A.inputNode.get("value"));}else{A._setInput(A.get("contentText"));}},_defSaveFn:function(M){var A=this;A.fire("stopEditing",true);},_onKeypressEditable:function(M){var A=this;var N=M.keyCode;if(N==27){M.preventDefault();A.cancel();}else{if(N==13&&(A.get("inputType")=="text")){A.save();}}},_onMouseEnterEditable:function(M){var A=this;A.get("node").addClass(G);},_onMouseLeaveEditable:function(M){var A=this;A.get("node").removeClass(G);},_setInput:function(N){var A=this;var M=A.get("formatInput");if(M){N=M.call(A,N);}else{N=A._toText(N);}A.inputNode.set("value",J.unescapeEntities(N));},_setOutput:function(N){var M=this;var A=M.get("formatOutput");if(A){N=A.call(M,N);}else{N=M._toHTML(N);}M.get("node").set("innerHTML",N);},_startEditing:function(M){var A=this;if(!A.get("rendered")){A.render(A.get("renderTo"));}A.fire("startEditing");M.halt();},_syncContentText:function(N){var A=this;if(!N.initial){var M=N.newVal;A._setInput(M);A._setOutput(M);}},_toHTML:function(M){var A=this;return String(M).replace(/\n/gim,"<br/>");},_toText:function(M){var A=this;M=String(M);M=M.replace(/<br\s*\/?>/gim,"\n");M=M.replace(/(<\/?[^>]+>|\t)/gim,"");return M;},_uiSetNode:function(N){var A=this;if(A._mouseEnterHandler){A._mouseEnterHandler.detach();}if(A._mouseLeaveHandler){A._mouseLeaveHandler.detach();}if(A._interactionHandler){A._interactionHandler.detach();}var M=A.get("eventType");A._mouseEnterHandler=N.on("mouseenter",A._onMouseEnterEditable,A);A._mouseLeaveHandler=N.on("mouseleave",A._onMouseLeaveEditable,A);A._interactionHandler=N.on(M,A._startEditing,A);}}});D.Editable=K;},"1.0.1",{skinnable:true,requires:["aui-base","aui-form-combobox"]});