1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/webtrees_ynh.git synced 2024-09-03 18:26:37 +02:00
webtrees_ynh/sources/packages/ckeditor-4.5.2-custom/plugins/scayt/dialogs/options.js

1 line
No EOL
8.5 KiB
JavaScript

CKEDITOR.dialog.add("scaytDialog",function(e){var d=e.scayt,a='<p><img src="'+d.getLogo()+'" /></p><p>'+d.getLocal("version")+d.getVersion()+"</p><p>"+d.getLocal("text_copyrights")+"</p>",h=CKEDITOR.document,c={isChanged:function(){return null===this.newLang||this.currentLang===this.newLang?!1:!0},currentLang:d.getLang(),newLang:null,reset:function(){this.currentLang=d.getLang();this.newLang=null},id:"lang"},a=[{id:"options",label:d.getLocal("tab_options"),onShow:function(){},elements:[{type:"vbox",id:"scaytOptions",children:function(){var g=d.getApplicationConfig(),i=[],f={"ignore-all-caps-words":"label_allCaps","ignore-domain-names":"label_ignoreDomainNames","ignore-words-with-mixed-cases":"label_mixedCase","ignore-words-with-numbers":"label_mixedWithDigits"},j;for(j in g){g={type:"checkbox"},g.id=j,g.label=d.getLocal(f[j]),i.push(g)}return i}(),onShow:function(){this.getChild();for(var f=e.scayt,g=0;g<this.getChild().length;g++){this.getChild()[g].setValue(f.getApplicationConfig()[this.getChild()[g].id])}}}]},{id:"langs",label:d.getLocal("tab_languages"),elements:[{id:"leftLangColumn",type:"vbox",align:"left",widths:["100"],children:[{type:"html",id:"langBox",style:"overflow: hidden; white-space: normal;",html:'<div><div style="float:left;width:45%;margin-left:5px;" id="left-col-'+e.name+'"></div><div style="float:left;width:45%;margin-left:15px;" id="right-col-'+e.name+'"></div></div>',onShow:function(){var f=e.scayt.getLang();h.getById("scaytLang_"+f).$.checked=!0}}]}]},{id:"dictionaries",label:d.getLocal("tab_dictionaries"),elements:[{type:"vbox",id:"rightCol_col__left",children:[{type:"html",id:"dictionaryNote",html:""},{type:"text",id:"dictionaryName",label:d.getLocal("label_fieldNameDic")||"Dictionary name",onShow:function(g){var i=g.sender,f=e.scayt;setTimeout(function(){i.getContentElement("dictionaries","dictionaryNote").getElement().setText("");null!=f.getUserDictionaryName()&&""!=f.getUserDictionaryName()&&i.getContentElement("dictionaries","dictionaryName").setValue(f.getUserDictionaryName())},0)}},{type:"hbox",id:"notExistDic",align:"left",style:"width:auto;",widths:["50%","50%"],children:[{type:"button",id:"createDic",label:d.getLocal("btn_createDic"),title:d.getLocal("btn_createDic"),onClick:function(){var g=this.getDialog(),i=b,f=e.scayt,j=g.getContentElement("dictionaries","dictionaryName").getValue();f.createUserDictionary(j,function(k){k.error||i.toggleDictionaryButtons.call(g,!0);k.dialog=g;k.command="create";k.name=j;e.fire("scaytUserDictionaryAction",k)},function(k){k.dialog=g;k.command="create";k.name=j;e.fire("scaytUserDictionaryActionError",k)})}},{type:"button",id:"restoreDic",label:d.getLocal("btn_restoreDic"),title:d.getLocal("btn_restoreDic"),onClick:function(){var g=this.getDialog(),i=e.scayt,f=b,j=g.getContentElement("dictionaries","dictionaryName").getValue();i.restoreUserDictionary(j,function(k){k.dialog=g;k.error||f.toggleDictionaryButtons.call(g,!0);k.command="restore";k.name=j;e.fire("scaytUserDictionaryAction",k)},function(k){k.dialog=g;k.command="restore";k.name=j;e.fire("scaytUserDictionaryActionError",k)})}}]},{type:"hbox",id:"existDic",align:"left",style:"width:auto;",widths:["50%","50%"],children:[{type:"button",id:"removeDic",label:d.getLocal("btn_deleteDic"),title:d.getLocal("btn_deleteDic"),onClick:function(){var g=this.getDialog(),i=e.scayt,f=b,j=g.getContentElement("dictionaries","dictionaryName"),k=j.getValue();i.removeUserDictionary(k,function(l){j.setValue("");l.error||f.toggleDictionaryButtons.call(g,!1);l.dialog=g;l.command="remove";l.name=k;e.fire("scaytUserDictionaryAction",l)},function(l){l.dialog=g;l.command="remove";l.name=k;e.fire("scaytUserDictionaryActionError",l)})}},{type:"button",id:"renameDic",label:d.getLocal("btn_renameDic"),title:d.getLocal("btn_renameDic"),onClick:function(){var g=this.getDialog(),i=e.scayt,f=g.getContentElement("dictionaries","dictionaryName").getValue();i.renameUserDictionary(f,function(j){j.dialog=g;j.command="rename";j.name=f;e.fire("scaytUserDictionaryAction",j)},function(j){j.dialog=g;j.command="rename";j.name=f;e.fire("scaytUserDictionaryActionError",j)})}}]},{type:"html",id:"dicInfo",html:'<div id="dic_info_editor1" style="margin:5px auto; width:95%;white-space:normal;">'+d.getLocal("text_descriptionDic")+"</div>"}]}]},{id:"about",label:d.getLocal("tab_about"),elements:[{type:"html",id:"about",style:"margin: 5px 5px;",html:'<div><div id="scayt_about_">'+a+"</div></div>"}]}];e.on("scaytUserDictionaryAction",function(i){var k=SCAYT.prototype.UILib,g=i.data.dialog,l=g.getContentElement("dictionaries","dictionaryNote").getElement(),m=i.editor.scayt,j;void 0===i.data.error?(j=m.getLocal("message_success_"+i.data.command+"Dic"),j=j.replace("%s",i.data.name),l.setText(j),k.css(l.$,{color:"blue"})):(""===i.data.name?l.setText(m.getLocal("message_info_emptyDic")):(j=m.getLocal("message_error_"+i.data.command+"Dic"),j=j.replace("%s",i.data.name),l.setText(j)),k.css(l.$,{color:"red"}),null!=m.getUserDictionaryName()&&""!=m.getUserDictionaryName()?g.getContentElement("dictionaries","dictionaryName").setValue(m.getUserDictionaryName()):g.getContentElement("dictionaries","dictionaryName").setValue(""))});e.on("scaytUserDictionaryActionError",function(i){var k=SCAYT.prototype.UILib,g=i.data.dialog,l=g.getContentElement("dictionaries","dictionaryNote").getElement(),m=i.editor.scayt,j;""===i.data.name?l.setText(m.getLocal("message_info_emptyDic")):(j=m.getLocal("message_error_"+i.data.command+"Dic"),j=j.replace("%s",i.data.name),l.setText(j));k.css(l.$,{color:"red"});null!=m.getUserDictionaryName()&&""!=m.getUserDictionaryName()?g.getContentElement("dictionaries","dictionaryName").setValue(m.getUserDictionaryName()):g.getContentElement("dictionaries","dictionaryName").setValue("")});var b={title:d.getLocal("text_title"),resizable:CKEDITOR.DIALOG_RESIZE_BOTH,minWidth:340,minHeight:260,onLoad:function(){if(0!=e.config.scayt_uiTabs[1]){var f=b,g=f.getLangBoxes.call(this);g.getParent().setStyle("white-space","normal");f.renderLangList(g);this.definition.minWidth=this.getSize().width;this.resize(this.definition.minWidth,this.definition.minHeight)}},onCancel:function(){c.reset()},onHide:function(){e.unlockSelection()},onShow:function(){e.fire("scaytDialogShown",this);if(0!=e.config.scayt_uiTabs[2]){var g=e.scayt,i=this.getContentElement("dictionaries","dictionaryName"),f=this.getContentElement("dictionaries","existDic").getElement().getParent(),j=this.getContentElement("dictionaries","notExistDic").getElement().getParent();f.hide();j.hide();null!=g.getUserDictionaryName()&&""!=g.getUserDictionaryName()?(this.getContentElement("dictionaries","dictionaryName").setValue(g.getUserDictionaryName()),f.show()):(i.setValue(""),j.show())}},onOk:function(){var f=b,g=e.scayt;this.getContentElement("options","scaytOptions");f=f.getChangedOption.call(this);g.commitOption({changedOptions:f})},toggleDictionaryButtons:function(g){var i=this.getContentElement("dictionaries","existDic").getElement().getParent(),f=this.getContentElement("dictionaries","notExistDic").getElement().getParent();g?(i.show(),f.hide()):(i.hide(),f.show())},getChangedOption:function(){var g={};if(1==e.config.scayt_uiTabs[0]){for(var i=this.getContentElement("options","scaytOptions").getChild(),f=0;f<i.length;f++){i[f].isChanged()&&(g[i[f].id]=i[f].getValue())}}c.isChanged()&&(g[c.id]=e.config.scayt_sLang=c.currentLang=c.newLang);return g},buildRadioInputs:function(i,l){var f=new CKEDITOR.dom.element("div");CKEDITOR.document.createElement("div");var m="scaytLang_"+l,n=CKEDITOR.dom.element.createFromHtml('<input id="'+m+'" type="radio" value="'+l+'" name="scayt_lang" />'),k=new CKEDITOR.dom.element("label"),j=e.scayt;f.setStyles({"white-space":"normal",position:"relative","padding-bottom":"2px"});n.on("click",function(g){c.newLang=g.sender.getValue()});k.appendText(i);k.setAttribute("for",m);f.append(n);f.append(k);l===j.getLang()&&(n.setAttribute("checked",!0),n.setAttribute("defaultChecked","defaultChecked"));return f},renderLangList:function(g){var l=g.find("#left-col-"+e.name).getItem(0);g=g.find("#right-col-"+e.name).getItem(0);var f=d.getLangList(),m={},n=[],i=0,j;for(j in f.ltr){m[j]=f.ltr[j]}for(j in f.rtl){m[j]=f.rtl[j]}for(j in m){n.push([j,m[j]])}n.sort(function(o,k){var p=0;o[1]>k[1]?p=1:o[1]<k[1]&&(p=-1);return p});m={};for(f=0;f<n.length;f++){m[n[f][0]]=n[f][1]}n=Math.round(n.length/2);for(j in m){i++,this.buildRadioInputs(m[j],j).appendTo(i<=n?l:g)}},getLangBoxes:function(){return this.getContentElement("langs","langBox").getElement()},contents:function(g,i){var f=[],j=i.config.scayt_uiTabs;if(j){for(var k in j){1==j[k]&&f.push(g[k])}f.push(g[g.length-1])}else{return g}return f}(a,e)};return b});