JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.4.0_full
[ckeditor.git] / plugins / scayt / dialogs / options.js
index 4c22026..aec9a1c 100644 (file)
@@ -1,8 +1,17 @@
-/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-CKEDITOR.dialog.add('scaytcheck',function(a){var b=true,c,d=CKEDITOR.document,e=[],f,g=[],h=false,i=['dic_create,dic_restore','dic_rename,dic_delete'],j=[{id:'options',label:a.lang.scayt.optionsTab,elements:[{type:'html',id:'options',html:'<div class="inner_options">\t<div class="messagebox"></div>\t<div style="display:none;">\t\t<input type="checkbox" value="0" id="allCaps" />\t\t<label for="allCaps" id="label_allCaps"></label>\t</div>\t<div style="display:none;">\t\t<input type="checkbox" value="0" id="ignoreDomainNames" />\t\t<label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>\t</div>\t<div style="display:none;">\t<input type="checkbox" value="0" id="mixedCase" />\t\t<label for="mixedCase" id="label_mixedCase"></label>\t</div>\t<div style="display:none;">\t\t<input type="checkbox" value="0" id="mixedWithDigits" />\t\t<label for="mixedWithDigits" id="label_mixedWithDigits"></label>\t</div></div>'}]},{id:'langs',label:a.lang.scayt.languagesTab,elements:[{type:'html',id:'langs',html:'<div class="inner_langs">\t<div class="messagebox"></div>\t   <div style="float:left;width:47%;margin-left:5px;" id="scayt_lcol" ></div>   <div style="float:left;width:47%;margin-left:15px;" id="scayt_rcol"></div></div>'}]},{id:'dictionaries',label:a.lang.scayt.dictionariesTab,elements:[{type:'html',style:'',id:'dic',html:'<div class="inner_dictionary" style="text-align:left; white-space:normal;">\t<div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message"> </div>\t<div style="margin:5px auto; width:80%;white-space:normal;">        <span class="cke_dialog_ui_labeled_label" >Dictionary name</span><br>\t\t<span class="cke_dialog_ui_labeled_content" >\t\t\t<div class="cke_dialog_ui_input_text">\t\t\t\t<input id="dic_name" type="text" class="cke_dialog_ui_input_text"/>\t\t</div></span></div>\t\t<div style="margin:5px auto; width:80%;white-space:normal;">\t\t\t<a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore">\t\t\t\t</a>\t\t</div>\t<div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info"></div></div>'}]},{id:'about',label:a.lang.scayt.aboutTab,elements:[{type:'html',id:'about',style:'margin: 10px 40px;',html:'<div id="scayt_about"></div>'}]}],k={title:a.lang.scayt.title,minWidth:340,minHeight:200,onShow:function(){var u=this;\r
-u.data=a.fire('scaytDialog',{});u.options=u.data.scayt_control.option();u.sLang=u.data.scayt_control.sLang;if(!u.data||!u.data.scayt||!u.data.scayt_control){alert('Error loading application service');u.hide();return;}var v=0;if(b)u.data.scayt.getCaption('en',function(w){if(v++>0)return;c=w;n.apply(u);o.apply(u);b=false;});else o.apply(u);u.selectPage(u.data.tab);},onOk:function(){var z=this;var u=z.data.scayt_control,v=u.option(),w=0;for(var x in z.options)if(v[x]!=z.options[x]&&w===0){u.option(z.options);w++;}var y=z.chosed_lang;if(y&&z.data.sLang!=y){u.setLang(y);w++;}if(w>0)u.refresh();},contents:g},l=CKEDITOR.plugins.scayt.getScayt(a);if(l)e=l.uiTags;for(f in e)if(e[f]==1)g[g.length]=j[f];if(e[2]==1)h=true;function m(){var u=d.getById('dic_name').getValue();if(!u){p(' Dictionary name should not be empty. ');return false;}window.dic[this.getId()].apply(null,[this,u,i]);return true;};var n=function(){var u=this,v=u.data.scayt.getLangList(),w=['dic_create','dic_delete','dic_rename','dic_restore'],x=['mixedCase','mixedWithDigits','allCaps','ignoreDomainNames'],y;if(h){for(y in w){var z=w[y];d.getById(z).setHtml('<span class="cke_dialog_ui_button">'+c['button_'+z]+'</span>');}d.getById('dic_info').setHtml(c.dic_info);}for(y in x){var A='label_'+x[y],B=d.getById(A);if('undefined'!=typeof B&&'undefined'!=typeof c[A]&&'undefined'!=typeof u.options[x[y]]){B.setHtml(c[A]);var C=B.getParent();C.$.style.display='block';}}var D='<p>'+c.about_throwt_image+'</p>'+'<p>'+c.version+u.data.scayt.version.toString()+'</p>'+'<p>'+c.about_throwt_copy+'</p>';d.getById('scayt_about').setHtml(D);var E=function(N,O){var P=d.createElement('label');P.setAttribute('for','cke_option'+N);P.setHtml(O[N]);if(u.sLang==N)u.chosed_lang=N;var Q=d.createElement('div'),R=CKEDITOR.dom.element.createFromHtml('<input id="cke_option'+N+'" type="radio" '+(u.sLang==N?'checked="checked"':'')+' value="'+N+'" name="scayt_lang" />');R.on('click',function(){this.$.checked=true;u.chosed_lang=N;});Q.append(R);Q.append(P);return{lang:O[N],code:N,radio:Q};},F=[];for(y in v.rtl)F[F.length]=E(y,v.ltr);for(y in v.ltr)F[F.length]=E(y,v.ltr);F.sort(function(N,O){return O.lang>N.lang?-1:1;});var G=d.getById('scayt_lcol'),H=d.getById('scayt_rcol');for(y=0;y<F.length;y++){var I=y<F.length/2?G:H;I.append(F[y].radio);}var J={};J.dic_create=function(N,O,P){var Q=P[0]+','+P[1],R=c.err_dic_create,S=c.succ_dic_create;window.scayt.createUserDictionary(O,function(T){s(Q);r(P[1]);S=S.replace('%s',T.dname);q(S);},function(T){R=R.replace('%s',T.dname);\r
-p(R+'( '+(T.message||'')+')');});};J.dic_rename=function(N,O){var P=c.err_dic_rename||'',Q=c.succ_dic_rename||'';window.scayt.renameUserDictionary(O,function(R){Q=Q.replace('%s',R.dname);t(O);q(Q);},function(R){P=P.replace('%s',R.dname);t(O);p(P+'( '+(R.message||'')+' )');});};J.dic_delete=function(N,O,P){var Q=P[0]+','+P[1],R=c.err_dic_delete,S=c.succ_dic_delete;window.scayt.deleteUserDictionary(function(T){S=S.replace('%s',T.dname);s(Q);r(P[0]);t('');q(S);},function(T){R=R.replace('%s',T.dname);p(R);});};J.dic_restore=u.dic_restore||(function(N,O,P){var Q=P[0]+','+P[1],R=c.err_dic_restore,S=c.succ_dic_restore;window.scayt.restoreUserDictionary(O,function(T){S=S.replace('%s',T.dname);s(Q);r(P[1]);q(S);},function(T){R=R.replace('%s',T.dname);p(R);});});var K=(i[0]+','+i[1]).split(','),L;for(y=0,L=K.length;y<L;y+=1){var M=d.getById(K[y]);if(M)M.on('click',m,this);}},o=function(){var u=this;for(var v in u.options){var w=d.getById(v);if(w){w.removeAttribute('checked');if(u.options[v]==1)w.setAttribute('checked','checked');if(b)w.on('click',function(){u.options[this.getId()]=this.$.checked?1:0;});}}if(h){window.scayt.getNameUserDictionary(function(x){var y=x.dname;if(y){d.getById('dic_name').setValue(y);r(i[1]);}else r(i[0]);},function(){d.getById('dic_name').setValue('');});q('');}};function p(u){d.getById('dic_message').setHtml('<span style="color:red;">'+u+'</span>');};function q(u){d.getById('dic_message').setHtml('<span style="color:blue;">'+u+'</span>');};function r(u){u=String(u);var v=u.split(',');for(var w=0,x=v.length;w<x;w+=1)d.getById(v[w]).$.style.display='inline';};function s(u){u=String(u);var v=u.split(',');for(var w=0,x=v.length;w<x;w+=1)d.getById(v[w]).$.style.display='none';};function t(u){d.getById('dic_name').$.value=u;};return k;});\r
+CKEDITOR.dialog.add("scaytDialog",function(f){var g=f.scayt,k='<p><img src="'+g.getLogo()+'" /></p><p>'+g.getLocal("version")+g.getVersion()+"</p><p>"+g.getLocal("text_copyrights")+"</p>",l=CKEDITOR.document,i={isChanged:function(){return null===this.newLang||this.currentLang===this.newLang?!1:!0},currentLang:g.getLang(),newLang:null,reset:function(){this.currentLang=g.getLang();this.newLang=null},id:"lang"},k=[{id:"options",label:g.getLocal("tab_options"),onShow:function(){},elements:[{type:"vbox",
+id:"scaytOptions",children:function(){var a=g.getApplicationConfig(),e=[],b={"ignore-all-caps-words":"label_allCaps","ignore-domain-names":"label_ignoreDomainNames","ignore-words-with-mixed-cases":"label_mixedCase","ignore-words-with-numbers":"label_mixedWithDigits"},d;for(d in a){var c={type:"checkbox"};c.id=d;c.label=g.getLocal(b[d]);e.push(c)}return e}(),onShow:function(){this.getChild();for(var a=f.scayt,e=0;e<this.getChild().length;e++)this.getChild()[e].setValue(a.getApplicationConfig()[this.getChild()[e].id])}}]},
+{id:"langs",label:g.getLocal("tab_languages"),elements:[{id:"leftLangColumn",type:"vbox",align:"left",widths:["100"],children:[{type:"html",id:"langBox",style:"overflow: hidden; white-space: normal;",html:'<form><div style="float:left;width:45%;margin-left:5px;" id="left-col-'+f.name+'"></div><div style="float:left;width:45%;margin-left:15px;" id="right-col-'+f.name+'"></div></form>',onShow:function(){var a=f.scayt.getLang();l.getById("scaytLang_"+a).$.checked=!0}}]}]},{id:"dictionaries",label:g.getLocal("tab_dictionaries"),
+elements:[{type:"vbox",id:"rightCol_col__left",children:[{type:"html",id:"dictionaryNote",html:""},{type:"text",id:"dictionaryName",label:g.getLocal("label_fieldNameDic")||"Dictionary name",onShow:function(a){var e=a.sender,b=f.scayt;setTimeout(function(){e.getContentElement("dictionaries","dictionaryNote").getElement().setText("");null!=b.getUserDictionaryName()&&""!=b.getUserDictionaryName()&&e.getContentElement("dictionaries","dictionaryName").setValue(b.getUserDictionaryName())},0)}},{type:"hbox",
+id:"notExistDic",align:"left",style:"width:auto;",widths:["50%","50%"],children:[{type:"button",id:"createDic",label:g.getLocal("btn_createDic"),title:g.getLocal("btn_createDic"),onClick:function(){var a=this.getDialog(),e=j,b=f.scayt,d=a.getContentElement("dictionaries","dictionaryName").getValue();b.createUserDictionary(d,function(c){c.error||e.toggleDictionaryButtons.call(a,!0);c.dialog=a;c.command="create";c.name=d;f.fire("scaytUserDictionaryAction",c)},function(c){c.dialog=a;c.command="create";
+c.name=d;f.fire("scaytUserDictionaryActionError",c)})}},{type:"button",id:"restoreDic",label:g.getLocal("btn_restoreDic"),title:g.getLocal("btn_restoreDic"),onClick:function(){var a=this.getDialog(),e=f.scayt,b=j,d=a.getContentElement("dictionaries","dictionaryName").getValue();e.restoreUserDictionary(d,function(c){c.dialog=a;c.error||b.toggleDictionaryButtons.call(a,!0);c.command="restore";c.name=d;f.fire("scaytUserDictionaryAction",c)},function(c){c.dialog=a;c.command="restore";c.name=d;f.fire("scaytUserDictionaryActionError",
+c)})}}]},{type:"hbox",id:"existDic",align:"left",style:"width:auto;",widths:["50%","50%"],children:[{type:"button",id:"removeDic",label:g.getLocal("btn_deleteDic"),title:g.getLocal("btn_deleteDic"),onClick:function(){var a=this.getDialog(),e=f.scayt,b=j,d=a.getContentElement("dictionaries","dictionaryName"),c=d.getValue();e.removeUserDictionary(c,function(e){d.setValue("");e.error||b.toggleDictionaryButtons.call(a,!1);e.dialog=a;e.command="remove";e.name=c;f.fire("scaytUserDictionaryAction",e)},function(b){b.dialog=
+a;b.command="remove";b.name=c;f.fire("scaytUserDictionaryActionError",b)})}},{type:"button",id:"renameDic",label:g.getLocal("btn_renameDic"),title:g.getLocal("btn_renameDic"),onClick:function(){var a=this.getDialog(),e=f.scayt,b=a.getContentElement("dictionaries","dictionaryName").getValue();e.renameUserDictionary(b,function(d){d.dialog=a;d.command="rename";d.name=b;f.fire("scaytUserDictionaryAction",d)},function(d){d.dialog=a;d.command="rename";d.name=b;f.fire("scaytUserDictionaryActionError",d)})}}]},
+{type:"html",id:"dicInfo",html:'<div id="dic_info_editor1" style="margin:5px auto; width:95%;white-space:normal;">'+g.getLocal("text_descriptionDic")+"</div>"}]}]},{id:"about",label:g.getLocal("tab_about"),elements:[{type:"html",id:"about",style:"margin: 5px 5px;",html:'<div><div id="scayt_about_">'+k+"</div></div>"}]}];f.on("scaytUserDictionaryAction",function(a){var e=a.data.dialog,b=e.getContentElement("dictionaries","dictionaryNote").getElement(),d=a.editor.scayt,c;void 0===a.data.error?(c=d.getLocal("message_success_"+
+a.data.command+"Dic"),c=c.replace("%s",a.data.name),b.setText(c),SCAYT.$(b.$).css({color:"blue"})):(""===a.data.name?b.setText(d.getLocal("message_info_emptyDic")):(c=d.getLocal("message_error_"+a.data.command+"Dic"),c=c.replace("%s",a.data.name),b.setText(c)),SCAYT.$(b.$).css({color:"red"}),null!=d.getUserDictionaryName()&&""!=d.getUserDictionaryName()?e.getContentElement("dictionaries","dictionaryName").setValue(d.getUserDictionaryName()):e.getContentElement("dictionaries","dictionaryName").setValue(""))});
+f.on("scaytUserDictionaryActionError",function(a){var e=a.data.dialog,b=e.getContentElement("dictionaries","dictionaryNote").getElement(),d=a.editor.scayt,c;""===a.data.name?b.setText(d.getLocal("message_info_emptyDic")):(c=d.getLocal("message_error_"+a.data.command+"Dic"),c=c.replace("%s",a.data.name),b.setText(c));SCAYT.$(b.$).css({color:"red"});null!=d.getUserDictionaryName()&&""!=d.getUserDictionaryName()?e.getContentElement("dictionaries","dictionaryName").setValue(d.getUserDictionaryName()):
+e.getContentElement("dictionaries","dictionaryName").setValue("")});var j={title:g.getLocal("text_title"),resizable:CKEDITOR.DIALOG_RESIZE_BOTH,minWidth:340,minHeight:260,onLoad:function(){if(0!=f.config.scayt_uiTabs[1]){var a=j,e=a.getLangBoxes.call(this);e.getParent().setStyle("white-space","normal");a.renderLangList(e);this.definition.minWidth=this.getSize().width;this.resize(this.definition.minWidth,this.definition.minHeight)}},onCancel:function(){i.reset()},onHide:function(){f.unlockSelection()},
+onShow:function(){f.fire("scaytDialogShown",this);if(0!=f.config.scayt_uiTabs[2]){var a=f.scayt,e=this.getContentElement("dictionaries","dictionaryName"),b=this.getContentElement("dictionaries","existDic").getElement().getParent(),d=this.getContentElement("dictionaries","notExistDic").getElement().getParent();b.hide();d.hide();null!=a.getUserDictionaryName()&&""!=a.getUserDictionaryName()?(this.getContentElement("dictionaries","dictionaryName").setValue(a.getUserDictionaryName()),b.show()):(e.setValue(""),
+d.show())}},onOk:function(){var a=j,e=f.scayt;this.getContentElement("options","scaytOptions");a=a.getChangedOption.call(this);e.commitOption({changedOptions:a})},toggleDictionaryButtons:function(a){var e=this.getContentElement("dictionaries","existDic").getElement().getParent(),b=this.getContentElement("dictionaries","notExistDic").getElement().getParent();a?(e.show(),b.hide()):(e.hide(),b.show())},getChangedOption:function(){var a={};if(1==f.config.scayt_uiTabs[0])for(var e=this.getContentElement("options",
+"scaytOptions").getChild(),b=0;b<e.length;b++)e[b].isChanged()&&(a[e[b].id]=e[b].getValue());i.isChanged()&&(a[i.id]=f.config.scayt_sLang=i.currentLang=i.newLang);return a},buildRadioInputs:function(a,e){var b=new CKEDITOR.dom.element("div");CKEDITOR.document.createElement("div");var d="scaytLang_"+e,c=CKEDITOR.dom.element.createFromHtml('<input id="'+d+'" type="radio"  value="'+e+'" name="scayt_lang" />'),g=new CKEDITOR.dom.element("label"),h=f.scayt;b.setStyles({"white-space":"normal",position:"relative"});
+c.on("click",function(a){i.newLang=a.sender.getValue()});g.appendText(a);g.setAttribute("for",d);b.append(c);b.append(g);e===h.getLang()&&(c.setAttribute("checked",!0),c.setAttribute("defaultChecked","defaultChecked"));return b},renderLangList:function(a){var e=a.find("#left-col-"+f.name).getItem(0),a=a.find("#right-col-"+f.name).getItem(0),b=g.getLangList(),d={},c=[],i=0,h;for(h in b.ltr)d[h]=b.ltr[h];for(h in b.rtl)d[h]=b.rtl[h];for(h in d)c.push([h,d[h]]);c.sort(function(a,b){var c=0;a[1]>b[1]?
+c=1:a[1]<b[1]&&(c=-1);return c});d={};for(b=0;b<c.length;b++)d[c[b][0]]=c[b][1];c=Math.round(c.length/2);for(h in d)i++,this.buildRadioInputs(d[h],h).appendTo(i<=c?e:a)},getLangBoxes:function(){return this.getContentElement("langs","langBox").getElement()},contents:function(a,e){var b=[],d=e.config.scayt_uiTabs;if(d){for(var c in d)1==d[c]&&b.push(a[c]);b.push(a[a.length-1])}else return a;return b}(k,f)};return j});
\ No newline at end of file