CKEDITOR.dialog.add("pbckcodeDialog",function(b){var f,e=new PBSyntaxHighlighter(b.settings.highlighter),c,d,g;return{title:b.lang.pbckcode.title,minWidth:600,minHeight:400,contents:[{id:"editor",label:b.lang.pbckcode.editor,elements:[{type:"hbox",children:[{type:"select",id:"code-select",className:"cke_pbckcode_form",label:b.lang.pbckcode.mode,items:b.settings.modes,"default":b.settings.modes[0][1],setup:function(a){a&&(a=a.getAscendant("pre",!0),this.setValue(a.getAttribute("data-pbcklang")))},
commit:function(a){a&&(a=a.getAscendant("pre",!0),a.setAttribute("data-pbcklang",this.getValue()))},onChange:function(){d.setMode("ace/mode/"+this.getValue())}},{type:"select",id:"code-tabsize-select",className:"cke_pbckcode_form",label:b.lang.pbckcode.tabSize,items:["1","2","4","8"],"default":b.settings.tab_size,setup:function(a){a&&(a=a.getAscendant("pre",!0),this.setValue(a.getAttribute("data-pbcktabsize")))},commit:function(a){a&&(a=a.getAscendant("pre",!0),a.setAttribute("data-pbcktabsize",this.getValue()))},
onChange:function(a){a&&(g.convertIndentation(d," ",this.getValue()),d.setTabSize(this.getValue()))}}]},{type:"html",html:"\x3cdiv\x3e\x3c/div\x3e",id:"code-textarea",className:"cke_pbckcode_ace",style:"position: absolute; top: 80px; left: 10px; right: 10px; bottom: 50px;",setup:function(a){a=a.getHtml();a=a.replace(RegExp("\x3cbr/\x3e","g"),"\n").replace(RegExp("\x3cbr\x3e","g"),"\n").replace(RegExp("\x26lt;","g"),"\x3c").replace(RegExp("\x26gt;","g"),"\x3e").replace(RegExp("\x26amp;","g"),"\x26").replace(RegExp("\x26nbsp;",
"g")," ");c.setValue(a)},commit:function(a){a.setText(c.getValue())}}]}],onLoad:function(){f=this;c=ace.edit(f.getContentElement("editor","code-textarea").getElement().getId());b.aceEditor=c;c.setTheme("ace/theme/"+b.settings.theme);c.setHighlightActiveLine(!0);c.setShowInvisibles(!0);d=c.getSession();d.setMode("ace/mode/"+b.settings.modes[0][1]);d.setTabSize(b.settings.tab_size);d.setUseSoftTabs(!0);g=ace.require("ace/ext/whitespace")},onShow:function(){var a=b.getSelection().getStartElement();a&&
(a=a.getAscendant("pre",!0));a&&"pre"===a.getName()?("pre"!==e.getTag()&&(a=a.getChild(0)),this.insertMode=!1):(a=new CKEDITOR.dom.element("pre"),"pre"!==e.getTag()&&a.append(new CKEDITOR.dom.element("code")),this.insertMode=!0);this.element=a;c.focus();c.setValue("");this.insertMode||this.setupContent(this.element)},onOk:function(){var a,c;a=c=this.element;this.insertMode?"pre"!==e.getTag()&&(c=this.element.getChild(0)):a=c.getAscendant("pre",!0);this.commitContent(c);e.setCls(a.getAttribute("data-pbcklang")+
" "+b.settings.cls);c.setAttribute("class",e.getCls());this.insertMode&&b.insertElement(a)}}});CKEDITOR.dialog.on("resize",function(b){b=b.editor.aceEditor;void 0!==b&&b.resize()});