YUI.add("moodle-atto_html-button",function(o,t){o.namespace("M.atto_html").Button=o.Base.create("button",o.M.editor_atto.EditorPlugin,[],{_codeMirror:null,initializer:function(){this.addButton({icon:"e/source_code",callback:this._toggleHTML});var t=this.get("host").textarea.ancestor("form");t&&t.on("submit",function(){this.get("isHTML")&&this._hideCodeMirror()},this)},_toggleHTML:function(){this.set("isHTML",!this.get("isHTML")),this.get("isHTML")?this._showCodeMirror():this._hideCodeMirror()},_showCodeMirror:function(){var t,e,i=this.get("host");i.disablePlugins(),i.enablePlugins(this.name),i.updateOriginal(),t={width:this.editor.getComputedStyle("width"),height:this.editor.getComputedStyle("height")},e=o.M.atto_html.beautify.html_beautify(i.textarea.get("value"),{indent_size:4,indent_inner_html:!0}),i.textarea.set("value",e),this._codeMirror=o.M.atto_html.CodeMirror.fromTextArea(i.textarea.getDOMNode(),{lineNumbers:!0,mode:"htmlmixed",tabSize:2,lineWrapping:!0}),this._codeMirror.on("change",function(t){t.save()}),this.editor.hide(),this._codeMirror.setSize(t.width,t.height),this._codeMirror.focus()},_hideCodeMirror:function(){var t=this.get("host");t.disablePlaceholderForEmptyContent(),t.enablePlugins(),t.updateFromTextArea(),this._codeMirror&&(o.one(this._codeMirror.getWrapperElement()).hide(),this._codeMirror.toTextArea(),o.Object.each(this._codeMirror._handlers,function(t,e){o.Array.each(t,function(t){this.off(e,t)},this)},this._codeMirror),delete this._codeMirror,this._codeMirror=null),t.textarea.hide(),this.editor.show(),t.focus(),this.markUpdated(),t.enablePlaceholderForEmptyContent()}},{ATTRS:{isHTML:{value:!1}}})},"@VERSION@",{requires:["promise","moodle-editor_atto-plugin","moodle-atto_html-beautify","moodle-atto_html-codemirror","event-valuechange"]});