CKEDITOR.dialog.add("scaytDialog",(function(t){var e=t.scayt,i='<p><img alt="logo" title="logo" src="'+e.getLogo()+'" /></p><p>'+e.getLocal("version")+e.getVersion()+'</p><p><a href="'+e.getOption("CKUserManual")+'" target="_blank" style="text-decoration: underline; color: blue; cursor: pointer;">'+e.getLocal("btn_userManual")+"</a></p><p>"+e.getLocal("text_copyrights")+"</p>",n=CKEDITOR.document,o={isChanged:function(){return null!==this.newLang&&this.currentLang!==this.newLang},currentLang:e.getLang(),newLang:null,reset:function(){this.currentLang=e.getLang(),this.newLang=null},id:"lang"};i=[{id:"options",label:e.getLocal("tab_options"),onShow:function(){},elements:[{type:"vbox",id:"scaytOptions",children:function(){var t,i=e.getApplicationConfig(),n=[],o={"ignore-all-caps-words":"label_allCaps","ignore-domain-names":"label_ignoreDomainNames","ignore-words-with-mixed-cases":"label_mixedCase","ignore-words-with-numbers":"label_mixedWithDigits"};for(t in i)(i={type:"checkbox"}).id=t,i.label=e.getLocal(o[t]),n.push(i);return n}(),onShow:function(){this.getChild();for(var e=t.scayt,i=0;i<this.getChild().length;i++)this.getChild()[i].setValue(e.getApplicationConfig()[this.getChild()[i].id])}}]},{id:"langs",label:e.getLocal("tab_languages"),elements:[{id:"leftLangColumn",type:"vbox",align:"left",widths:["100"],children:[{type:"html",id:"langBox",style:"overflow: hidden; white-space: normal;margin-bottom:15px;",html:'<div><div style="float:left;width:45%;margin-left:5px;" id="left-col-'+t.name+'" class="scayt-lang-list"></div><div style="float:left;width:45%;margin-left:15px;" id="right-col-'+t.name+'" class="scayt-lang-list"></div></div>',onShow:function(){var e=t.scayt.getLang();n.getById("scaytLang_"+t.name+"_"+e).$.checked=!0}}]}]},{id:"dictionaries",label:e.getLocal("tab_dictionaries"),elements:[{type:"vbox",id:"rightCol_col__left",children:[{type:"html",id:"dictionaryNote",html:""},{type:"text",id:"dictionaryName",label:e.getLocal("label_fieldNameDic")||"Dictionary name",onShow:function(e){var i=e.sender,n=t.scayt;e=SCAYT.prototype.UILib;var o=i.getContentElement("dictionaries","dictionaryName").getInputElement().$;n.isLicensed()||(o.disabled=!0,e.css(o,{cursor:"not-allowed"})),setTimeout((function(){i.getContentElement("dictionaries","dictionaryNote").getElement().setText(""),null!=n.getUserDictionaryName()&&""!=n.getUserDictionaryName()&&i.getContentElement("dictionaries","dictionaryName").setValue(n.getUserDictionaryName())}),0)}},{type:"hbox",id:"udButtonsHolder",align:"left",widths:["auto"],style:"width:auto;",children:[{type:"button",id:"createDic",label:e.getLocal("btn_createDic"),title:e.getLocal("btn_createDic"),onLoad:function(){this.getDialog();var e=t.scayt,i=SCAYT.prototype.UILib,n=this.getElement().$,o=this.getElement().getChild(0).$;e.isLicensed()||(i.css(n,{cursor:"not-allowed"}),i.css(o,{cursor:"not-allowed"}))},onClick:function(){var e=this.getDialog(),i=a,n=t.scayt,o=e.getContentElement("dictionaries","dictionaryName").getValue();n.isLicensed()&&n.createUserDictionary(o,(function(n){n.error||i.toggleDictionaryState.call(e,"dictionaryState"),n.dialog=e,n.command="create",n.name=o,t.fire("scaytUserDictionaryAction",n)}),(function(i){i.dialog=e,i.command="create",i.name=o,t.fire("scaytUserDictionaryActionError",i)}))}},{type:"button",id:"restoreDic",label:e.getLocal("btn_connectDic"),title:e.getLocal("btn_connectDic"),onLoad:function(){this.getDialog();var e=t.scayt,i=SCAYT.prototype.UILib,n=this.getElement().$,o=this.getElement().getChild(0).$;e.isLicensed()||(i.css(n,{cursor:"not-allowed"}),i.css(o,{cursor:"not-allowed"}))},onClick:function(){var e=this.getDialog(),i=t.scayt,n=a,o=e.getContentElement("dictionaries","dictionaryName").getValue();i.isLicensed()&&i.restoreUserDictionary(o,(function(i){i.dialog=e,i.error||n.toggleDictionaryState.call(e,"dictionaryState"),i.command="restore",i.name=o,t.fire("scaytUserDictionaryAction",i)}),(function(i){i.dialog=e,i.command="restore",i.name=o,t.fire("scaytUserDictionaryActionError",i)}))}},{type:"button",id:"disconnectDic",label:e.getLocal("btn_disconnectDic"),title:e.getLocal("btn_disconnectDic"),onClick:function(){var e=this.getDialog(),i=t.scayt,n=a,o=e.getContentElement("dictionaries","dictionaryName"),r=o.getValue();i.isLicensed()&&(i.disconnectFromUserDictionary({}),o.setValue(""),n.toggleDictionaryState.call(e,"initialState"),t.fire("scaytUserDictionaryAction",{dialog:e,command:"disconnect",name:r}))}},{type:"button",id:"removeDic",label:e.getLocal("btn_deleteDic"),title:e.getLocal("btn_deleteDic"),onClick:function(){var e=this.getDialog(),i=t.scayt,n=a,o=e.getContentElement("dictionaries","dictionaryName"),r=o.getValue();i.isLicensed()&&i.removeUserDictionary(r,(function(i){o.setValue(""),i.error||n.toggleDictionaryState.call(e,"initialState"),i.dialog=e,i.command="remove",i.name=r,t.fire("scaytUserDictionaryAction",i)}),(function(i){i.dialog=e,i.command="remove",i.name=r,t.fire("scaytUserDictionaryActionError",i)}))}},{type:"button",id:"renameDic",label:e.getLocal("btn_renameDic"),title:e.getLocal("btn_renameDic"),onClick:function(){var e=this.getDialog(),i=t.scayt,n=e.getContentElement("dictionaries","dictionaryName").getValue();i.isLicensed()&&i.renameUserDictionary(n,(function(i){i.dialog=e,i.command="rename",i.name=n,t.fire("scaytUserDictionaryAction",i)}),(function(i){i.dialog=e,i.command="rename",i.name=n,t.fire("scaytUserDictionaryActionError",i)}))}},{type:"button",id:"editDic",label:e.getLocal("btn_goToDic"),title:e.getLocal("btn_goToDic"),onLoad:function(){this.getDialog()},onClick:function(){var t=this.getDialog(),e=t.getContentElement("dictionaries","addWordField");a.clearWordList.call(t),e.setValue(""),a.getUserDictionary.call(t),a.toggleDictionaryState.call(t,"wordsState")}}]},{type:"hbox",id:"dicInfo",align:"left",children:[{type:"html",id:"dicInfoHtml",html:'<div id="dic_info_editor1" style="margin:5px auto; width:95%;white-space:normal;">'+(t.scayt.isLicensed&&t.scayt.isLicensed()?'<a href="'+e.getOption("CKUserManual")+'" target="_blank" style="text-decoration: underline; color: blue; cursor: pointer;">'+e.getLocal("text_descriptionDicForPaid")+"</a>":e.getLocal("text_descriptionDicForFree"))+"</div>"}]},{id:"addWordAction",type:"hbox",style:"width: 100%; margin-bottom: 0;",widths:["40%","60%"],children:[{id:"addWord",type:"vbox",style:"min-width: 150px;",children:[{type:"text",id:"addWordField",label:"Add word",maxLength:"64"}]},{id:"addWordButtons",type:"vbox",style:"margin-top: 20px;",children:[{type:"hbox",id:"addWordButton",align:"left",children:[{type:"button",id:"addWord",label:e.getLocal("btn_addWord"),title:e.getLocal("btn_addWord"),onClick:function(){var e=this.getDialog(),i=t.scayt,n=e.getContentElement("dictionaries","itemList"),o=e.getContentElement("dictionaries","addWordField"),a=o.getValue(),r=i.getOption("wordBoundaryRegex"),c=this;a&&(-1!==a.search(r)?t.fire("scaytUserDictionaryAction",{dialog:e,command:"wordWithBannedSymbols",name:a,error:!0}):n.inChildren(a)?(o.setValue(""),t.fire("scaytUserDictionaryAction",{dialog:e,command:"wordAlreadyAdded",name:a})):(this.disable(),i.addWordToUserDictionary(a,(function(i){i.error||(o.setValue(""),n.addChild(a,!0)),i.dialog=e,i.command="addWord",i.name=a,c.enable(),t.fire("scaytUserDictionaryAction",i)}),(function(i){i.dialog=e,i.command="addWord",i.name=a,c.enable(),t.fire("scaytUserDictionaryActionError",i)}))))}},{type:"button",id:"backToDic",label:e.getLocal("btn_dictionaryPreferences"),title:e.getLocal("btn_dictionaryPreferences"),align:"right",onClick:function(){var e=this.getDialog(),i=t.scayt;null!=i.getUserDictionaryName()&&""!=i.getUserDictionaryName()?a.toggleDictionaryState.call(e,"dictionaryState"):a.toggleDictionaryState.call(e,"initialState")}}]}]}]},{id:"wordsHolder",type:"hbox",style:"width: 100%; height: 170px; margin-bottom: 0;",children:[{type:"scaytItemList",id:"itemList",align:"left",style:"width: 100%; height: 170px; overflow: auto",onClick:function(e){var i=e.data.$;e=t.scayt;var n=SCAYT.prototype.UILib,o=(i=i.target||i.srcElement,n.parent(i)[0]),a=n.attr(o,"data-cke-scayt-ud-word"),r=this.getDialog(),c=r.getContentElement("dictionaries","itemList"),l=this;n.hasClass(i,"cke_scaytItemList_remove")&&!this.isBlocked()&&(this.block(),e.deleteWordFromUserDictionary(a,(function(e){e.error||c.removeChild(o,a),l.unblock(),e.dialog=r,e.command="deleteWord",e.name=a,t.fire("scaytUserDictionaryAction",e)}),(function(e){l.unblock(),e.dialog=r,e.command="deleteWord",e.name=a,t.fire("scaytUserDictionaryActionError",e)})))}}]}]}]},{id:"about",label:e.getLocal("tab_about"),elements:[{type:"html",id:"about",style:"margin: 5px 5px;",html:'<div><div id="scayt_about_">'+i+"</div></div>"}]}];t.on("scaytUserDictionaryAction",(function(t){var e,i=SCAYT.prototype.UILib,n=t.data.dialog,o=n.getContentElement("dictionaries","dictionaryNote").getElement(),a=t.editor.scayt;void 0===t.data.error?(e=(e=a.getLocal("message_success_"+t.data.command+"Dic")).replace("%s",t.data.name),o.setText(e),i.css(o.$,{color:"blue"})):(""===t.data.name?o.setText(a.getLocal("message_info_emptyDic")):(e=(e=a.getLocal("message_error_"+t.data.command+"Dic")).replace("%s",t.data.name),o.setText(e)),i.css(o.$,{color:"red"}),null!=a.getUserDictionaryName()&&""!=a.getUserDictionaryName()?n.getContentElement("dictionaries","dictionaryName").setValue(a.getUserDictionaryName()):n.getContentElement("dictionaries","dictionaryName").setValue(""))})),t.on("scaytUserDictionaryActionError",(function(t){var e,i=SCAYT.prototype.UILib,n=t.data.dialog,o=n.getContentElement("dictionaries","dictionaryNote").getElement(),a=t.editor.scayt;""===t.data.name?o.setText(a.getLocal("message_info_emptyDic")):(e=(e=a.getLocal("message_error_"+t.data.command+"Dic")).replace("%s",t.data.name),o.setText(e)),i.css(o.$,{color:"red"}),null!=a.getUserDictionaryName()&&""!=a.getUserDictionaryName()?n.getContentElement("dictionaries","dictionaryName").setValue(a.getUserDictionaryName()):n.getContentElement("dictionaries","dictionaryName").setValue("")}));var a={title:"SCAYT",resizable:CKEDITOR.DIALOG_RESIZE_BOTH,minWidth:"moono-lisa"==(CKEDITOR.skinName||t.config.skin)?450:340,minHeight:300,onLoad:function(){if(0!=t.config.scayt_uiTabs[1]){var e=a,i=e.getLangBoxes.call(this);this.getContentElement("dictionaries","addWordField"),i.getParent().setStyle("white-space","normal"),e.renderLangList(i),this.definition.minWidth=this.getSize().width,this.resize(this.definition.minWidth,this.definition.minHeight)}},onCancel:function(){o.reset()},onHide:function(){t.unlockSelection()},onShow:function(){if(t.fire("scaytDialogShown",this),0!=t.config.scayt_uiTabs[2]){var e=this.getContentElement("dictionaries","addWordField");a.clearWordList.call(this),e.setValue(""),a.getUserDictionary.call(this),a.toggleDictionaryState.call(this,"wordsState")}},onOk:function(){var e=a,i=t.scayt;this.getContentElement("options","scaytOptions"),e=e.getChangedOption.call(this),i.commitOption({changedOptions:e})},toggleDictionaryButtons:function(t){var e=this.getContentElement("dictionaries","existDic").getElement().getParent(),i=this.getContentElement("dictionaries","notExistDic").getElement().getParent();t?(e.show(),i.hide()):(e.hide(),i.show())},getChangedOption:function(){var e={};if(1==t.config.scayt_uiTabs[0])for(var i=this.getContentElement("options","scaytOptions").getChild(),n=0;n<i.length;n++)i[n].isChanged()&&(e[i[n].id]=i[n].getValue());return o.isChanged()&&(e[o.id]=t.config.scayt_sLang=o.currentLang=o.newLang),e},buildRadioInputs:function(e,i,n){n=new CKEDITOR.dom.element("div");var a="scaytLang_"+t.name+"_"+i,r=CKEDITOR.dom.element.createFromHtml('<input id="'+a+'" type="radio" value="'+i+'" name="scayt_lang" />'),c=new CKEDITOR.dom.element("label"),l=t.scayt;return n.setStyles({"white-space":"normal",position:"relative","padding-bottom":"2px"}),r.on("click",(function(t){o.newLang=t.sender.getValue()})),c.appendText(e),c.setAttribute("for",a),n.append(r),n.append(c),i===l.getLang()&&(r.setAttribute("checked",!0),r.setAttribute("defaultChecked","defaultChecked")),n},renderLangList:function(i){var n=t.name.replace(/(:|\.|\[|\]|,|=|@)/g,"\\$1"),o=i.find("#left-col-"+n).getItem(0);i=i.find("#right-col-"+n).getItem(0);var a,r=e.getScaytLangList(),c=(n=e.getGraytLangList(),{}),l=[],s=0,d=!1;for(a in r.ltr)c[a]=r.ltr[a];for(a in r.rtl)c[a]=r.rtl[a];for(a in c)l.push([a,c[a]]);for(l.sort((function(t,e){var i=0;return t[1]>e[1]?i=1:t[1]<e[1]&&(i=-1),i})),c={},d=0;d<l.length;d++)c[l[d][0]]=l[d][1];for(a in l=Math.round(l.length/2),c)s++,d=a in n.ltr||a in n.rtl,this.buildRadioInputs(c[a],a,d).appendTo(s<=l?o:i)},getLangBoxes:function(){return this.getContentElement("langs","langBox").getElement()},toggleDictionaryState:function(t){var e=this.getContentElement("dictionaries","dictionaryName").getElement().getParent(),i=this.getContentElement("dictionaries","udButtonsHolder").getElement().getParent(),n=this.getContentElement("dictionaries","createDic").getElement().getParent(),o=this.getContentElement("dictionaries","restoreDic").getElement().getParent(),a=this.getContentElement("dictionaries","disconnectDic").getElement().getParent(),r=this.getContentElement("dictionaries","removeDic").getElement().getParent(),c=this.getContentElement("dictionaries","renameDic").getElement().getParent(),l=this.getContentElement("dictionaries","dicInfo").getElement().getParent(),s=this.getContentElement("dictionaries","addWordAction").getElement().getParent(),d=this.getContentElement("dictionaries","wordsHolder").getElement().getParent();switch(t){case"initialState":e.show(),i.show(),n.show(),o.show(),a.hide(),r.hide(),c.hide(),l.show(),s.hide(),d.hide();break;case"wordsState":e.hide(),i.hide(),l.hide(),s.show(),d.show();break;case"dictionaryState":e.show(),i.show(),n.hide(),o.hide(),a.show(),r.show(),c.show(),l.show(),s.hide(),d.hide()}},clearWordList:function(){this.getContentElement("dictionaries","itemList").removeAllChild()},getUserDictionary:function(){var e=this,i=t.scayt;i.getUserDictionary(i.getUserDictionaryName(),(function(t){t.error||a.renderItemList.call(e,t.wordlist)}))},renderItemList:function(t){for(var e=this.getContentElement("dictionaries","itemList"),i=0;i<t.length;i++)e.addChild(t[i])},contents:function(t,e){var i=[],n=e.config.scayt_uiTabs;if(!n)return t;for(var o in n)1==n[o]&&i.push(t[o]);return i.push(t[t.length-1]),i}(i,t)};return a})),CKEDITOR.tools.extend(CKEDITOR.ui.dialog,{scaytItemList:function(t,e,i){if(arguments.length){var n=this;t.on("load",(function(){n.getElement().on("click",(function(t){}))})),CKEDITOR.ui.dialog.uiElement.call(this,t,e,i,"",null,null,(function(){var t=['<p class="cke_dialog_ui_',e.type,'"'];return e.style&&t.push('style="'+e.style+'" '),t.push(">"),t.push("</p>"),t.join("")}))}}}),CKEDITOR.ui.dialog.scaytItemList.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{children:[],blocked:!1,addChild:function(t,e){var i=new CKEDITOR.dom.element("p"),n=new CKEDITOR.dom.element("a"),o=this.getElement().getChildren().getItem(0);this.children.push(t),i.addClass("cke_scaytItemList-child"),i.setAttribute("data-cke-scayt-ud-word",t),i.appendText(t),n.addClass("cke_scaytItemList_remove"),n.addClass("cke_dialog_close_button"),n.setAttribute("href","javascript:void(0)"),i.append(n),o.append(i,!!e)},inChildren:function(t){return SCAYT.prototype.Utils.inArray(this.children,t)},removeChild:function(t,e){this.children.splice(SCAYT.prototype.Utils.indexOf(this.children,e),1),this.getElement().getChildren().getItem(0).$.removeChild(t)},removeAllChild:function(){this.children=[],this.getElement().getChildren().getItem(0).setHtml("")},block:function(){this.blocked=!0},unblock:function(){this.blocked=!1},isBlocked:function(){return this.blocked}}),commonBuilder={build:function(t,e,i){return new CKEDITOR.ui.dialog[e.type](t,e,i)}},CKEDITOR.dialog.addUIElement("scaytItemList",commonBuilder);