Ext.ux.form.TinyMCETextArea=Ext.extend(Ext.form.TextArea,{wysiwygIntialized:!1,intializationInProgress:!1,lastHeight:null,lastFrameHeight:null,noWysiwyg:!1,tinyMCEConfig:{},editor:void 0,disableEditor:!1,editorOwnerWindow:void 0,constructor:function(a){a=a||{};Ext.applyIf(a,{hideMode:"offsets"});Ext.applyIf(a.tinyMCEConfig,{hideMode:"offsets",mode:"exact",resize:!1});Ext.ux.form.TinyMCETextArea.superclass.constructor.call(this,a)},getEditorOwnerWindow:function(){if(Ext.isDefined(this.editorOwnerWindow))return this.editorOwnerWindow;
var a=Ext.getDom(this.getInputId());return this.editorOwnerWindow=a?a.ownerDocument.defaultView:void 0},afterRender:function(){var a=this;Ext.ux.form.TinyMCETextArea.superclass.afterRender.call(this,arguments);this.initEditor();a.on("blur",function(b,c,d){b=document.getElementById(a.getInputId());a.wysiwygIntialized?(c=a.getEditor())&&c.isHidden()&&(b&&(a.positionBeforeBlur={start:b.selectionStart,end:b.selectionEnd}),c.load()):b&&(a.positionBeforeBlur={start:b.selectionStart,end:b.selectionEnd})},
a);a.on("resize",function(b,c,d,f,e,h){a.syncEditorHeight(d)},a)},syncEditorHeight:function(a){this.lastHeight=a;if(this.wysiwygIntialized&&this.rendered){var b=this.getEditorOwnerWindow().tinymce.get(this.getInputId());if(b&&b.iframeElement&&!b.isHidden()){var b=Ext.get(b.iframeElement),c=b.up(".mce-edit-area"),c=c.up(".mce-container-body"),d=c.down(".mce-toolbar-grp");d&&(a-=d.getHeight());(d=c.down(".mce-menubar"))&&(a-=d.getHeight());(c=c.down(".mce-statusbar"))&&(a-=c.getHeight());this.lastFrameHeight=
a-3;b.setHeight(a-3)}}},withEd:function(a){var b=this,c=this.getEditor();if(c)if(c.initialized)c.initialized&&(b.editor=c,a.call(b));else this.on("initialized",function(){b.withEd(a)},b)},getInputId:function(){return this.inputId||(this.inputId=this.id)},isDisabled:function(){return this.disabled},insertAtCursor:function(a){var b=this.getEditor();b.execCommand("mceInsertContent",!1,a);b.undoManager.clear()},initEditor:function(){var a=this;if(!(a.noWysiwyg||a.intializationInProgress||a.wysiwygIntialized)){a.intializationInProgress=
!0;a.tinyMCEConfig.selector="textarea#"+a.getInputId();a.tinyMCEConfig.height=a.lastFrameHeight?a.lastFrameHeight:30;var b=null;a.tinyMCEConfig.setup&&(b=a.tinyMCEConfig.setup);a.tinyMCEConfig.setup=function(c){Ext.isDefined(a.editor)||(a.editor=c);var d=a.getEditorOwnerWindow(),f=d.tinymce.DOM.loadCSS,e=[];d.tinymce.DOM.loadCSS=function(b){b||(b="");Ext.each(b.split(","),function(b){if(!Ext.isEmpty(b)){e.push(b);var c=d.document.createElement("link");d.document.head.appendChild(c);c.addEventListener("load",
function(){e.splice(e.indexOf(b),1);d.document.head.removeChild(c);a.fireEvent("stylesheetloaded",b)});c.addEventListener("error",function(){e.splice(e.indexOf(b),1);a.fireEvent("stylesheetloaded",b)});c.setAttribute("rel","stylesheet");c.setAttribute("type","text/css");c.setAttribute("href",b)}});return f.apply(this,arguments)};c.on("init",function(b){function g(){if(0<e.length)a.on("stylesheetloaded",function(){g()},this);else a.syncEditorHeight(a.lastHeight||a.height)}d.tinymce.DOM.loadCSS=f;a.wysiwygIntialized=
!0;a.intializationInProgress=!1;(a.disableEditor||a.isDisabled())&&a.disable();a.fireEvent("initialized",a,c,{});(a.lastHeight||a.height)&&g()});b&&b(c)};a.getEditorOwnerWindow().tinymce.init(a.tinyMCEConfig);a.intializationInProgress=!1;a.wysiwygIntialized=!0}},getEditor:function(){var a=this.getEditorOwnerWindow();return a?a.tinymce.get(this.getInputId()):void 0},removeEditor:function(){if(this.intializationInProgress||!this.wysiwygIntialized)return this;var a=this.getEditor();a&&(a.save(),a.destroy(!1));
this.wysiwygIntialized=!1;return this},setValue:function(a){var b=this;if(b.wysiwygIntialized&&this.value!==a&&(this.value=a,this.rendered)){var c=b.getEditor();if(c)b.setContent(c,a);else b.getEditorOwnerWindow().tinymce.EditorManager.on("AddEditor",function(){b.withEd(function(){var c=b.getEditor();c.isDirty()||b.setContent(c,a)})},this)}return this.value},setContent:function(a,b){a.setContent(null===b||void 0===b?"":b,{format:"raw"});a.startContent=a.getContent({format:"raw"})},getValue:function(a){if(a=
this.getEditor()){if(!this.rendered||!a.initialized)return Ext.value(this.value,"");a=a.getContent();if(a===this.emptyText||void 0===a)a="";return a}},getRawValue:function(){var a=this.getEditor();if(a){if(!this.rendered||!a.initialized)return Ext.value(this.value,"");a=a.getContent({format:"raw"});a===this.emptyText&&(a="");return a}},initValue:function(){if(this.rendered)if(void 0!==this.value)this.setValue(this.value);else{var a=this.getEl().value;a&&this.setValue(a)}else Ext.ux.TinyMCE.superclass.initValue.call(this)},
focus:function(a,b){var c=this;if(c.isDisabled())return c;if(b)return isNaN(b)&&(b=10),setTimeout(function(){c.focus.call(c,a,!1)},b),c;if(!c.wysiwygIntialized)return Ext.ux.form.TinyMCETextArea.superclass.focus.call(this,arguments);var d=c.getEditor();if(d&&!d.isHidden()&&d.initialized)Ext.ux.form.TinyMCETextArea.superclass.focus.call(this,arguments),d.focus();else return this.withEd(function(){d.focus()}),Ext.ux.form.TinyMCETextArea.superclass.focus.call(this,arguments);return c},enable:function(){var a=
Ext.ux.form.TinyMCETextArea.superclass.enable.call(this,arguments);if(!a)return a;if(a=this.getEditor())a.theme.panel.find("*").disabled(!1),this.getEditorBody().setAttribute("contenteditable",!0);return this},disable:function(a){var b=this,c=Ext.ux.form.TinyMCETextArea.superclass.disable.call(this,arguments);if(!c)return c;b.withEd(function(){b.getEditor().theme.panel.find("*").disabled(!0);this.getEditorBody().setAttribute("contenteditable",!1)});return b},hide:function(){var a=this;Ext.ux.form.TinyMCETextArea.superclass.hide.call(this,
arguments);var b=a.getEditor();b&&b.iframeElement?b.hide():a.withEd(function(){a.getEditor().hide()});return a},show:function(){Ext.ux.form.TinyMCETextArea.superclass.show.call(this,arguments);var a=this.getEditor();a&&a.show();return this}});Ext.reg("zarafa.tinymcetextarea",Ext.ux.form.TinyMCETextArea);//# sourceMappingURL=ux-thirdparty.js.map
