JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.0.2_full
[ckeditor.git] / plugins / scayt / dialogs / options.js
index b10337e..82bf80b 100644 (file)
@@ -1,8 +1,20 @@
-/*\r
-Copyright (c) 2003-2010, 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=0,i=['dic_create,dic_restore','dic_rename,dic_delete'],j=['mixedCase','mixedWithDigits','allCaps','ignoreDomainNames'];function k(){return document.forms.optionsbar.options;};function l(){return document.forms.languagesbar.scayt_lang;};function m(y,z){if(!y)return;var A=y.length;if(A==undefined){y.checked=y.value==z.toString();return;}for(var B=0;B<A;B++){y[B].checked=false;if(y[B].value==z.toString())y[B].checked=true;}};var n=a.lang.scayt,o=[{id:'options',label:n.optionsTab,elements:[{type:'html',id:'options',html:'<form name="optionsbar"><div class="inner_options">\t<div class="messagebox"></div>\t<div style="display:none;">\t\t<input type="checkbox" name="options"  id="allCaps" />\t\t<label for="allCaps" id="label_allCaps"></label>\t</div>\t<div style="display:none;">\t\t<input name="options" type="checkbox"  id="ignoreDomainNames" />\t\t<label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>\t</div>\t<div style="display:none;">\t<input name="options" type="checkbox"  id="mixedCase" />\t\t<label for="mixedCase" id="label_mixedCase"></label>\t</div>\t<div style="display:none;">\t\t<input name="options" type="checkbox"  id="mixedWithDigits" />\t\t<label for="mixedWithDigits" id="label_mixedWithDigits"></label>\t</div></div></form>'}]},{id:'langs',label:n.languagesTab,elements:[{type:'html',id:'langs',html:'<form name="languagesbar"><div class="inner_langs">\t<div class="messagebox"></div>\t   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol" ></div>   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol"></div></div></form>'}]},{id:'dictionaries',label:n.dictionariesTab,elements:[{type:'html',style:'',id:'dictionaries',html:'<form name="dictionarybar"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">\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></form>'}]},{id:'about',label:n.aboutTab,elements:[{type:'html',id:'about',style:'margin: 5px 5px;',html:'<div id="scayt_about"></div>'}]}],p={title:n.title,minWidth:360,minHeight:220,onShow:function(){var y=this;\r
-y.data=a.fire('scaytDialog',{});y.options=y.data.scayt_control.option();y.sLang=y.data.scayt_control.sLang;if(!y.data||!y.data.scayt||!y.data.scayt_control){alert('Error loading application service');y.hide();return;}var z=0;if(b)y.data.scayt.getCaption(a.langCode||'en',function(A){if(z++>0)return;c=A;r.apply(y);s.apply(y);b=false;});else s.apply(y);y.selectPage(y.data.tab);},onOk:function(){var y=this.data.scayt_control;y.option(this.options);var z=this.chosed_lang;y.setLang(z);y.refresh();},onCancel:function(){var y=k();for(var z in y)y[z].checked=false;m(l(),'');},contents:g},q=CKEDITOR.plugins.scayt.getScayt(a);e=CKEDITOR.plugins.scayt.uiTabs;for(var f in e){if(e[f]==1)g[g.length]=o[f];}if(e[2]==1)h=1;var r=function(){var y=this,z=y.data.scayt.getLangList(),A=['dic_create','dic_delete','dic_rename','dic_restore'],B=j,C;if(h){for(C=0;C<A.length;C++){var D=A[C];d.getById(D).setHtml('<span class="cke_dialog_ui_button">'+c['button_'+D]+'</span>');}d.getById('dic_info').setHtml(c.dic_info);}if(e[0]==1)for(C in B){var E='label_'+B[C],F=d.getById(E);if('undefined'!=typeof F&&'undefined'!=typeof c[E]&&'undefined'!=typeof y.options[B[C]]){F.setHtml(c[E]);var G=F.getParent();G.$.style.display='block';}}var H='<p><img src="'+window.scayt.getAboutInfo().logoURL+'" /></p>'+'<p>'+c.version+window.scayt.getAboutInfo().version.toString()+'</p>'+'<p>'+c.about_throwt_copy+'</p>';d.getById('scayt_about').setHtml(H);var I=function(S,T){var U=d.createElement('label');U.setAttribute('for','cke_option'+S);U.setHtml(T[S]);if(y.sLang==S)y.chosed_lang=S;var V=d.createElement('div'),W=CKEDITOR.dom.element.createFromHtml('<input id="cke_option'+S+'" type="radio" '+(y.sLang==S?'checked="checked"':'')+' value="'+S+'" name="scayt_lang" />');W.on('click',function(){this.$.checked=true;y.chosed_lang=S;});V.append(W);V.append(U);return{lang:T[S],code:S,radio:V};},J=[];if(e[1]==1){for(var C in z.rtl)J[J.length]=I(C,z.ltr);for(C in z.ltr)J[J.length]=I(C,z.ltr);J.sort(function(S,T){return T.lang>S.lang?-1:1;});var K=d.getById('scayt_lcol'),L=d.getById('scayt_rcol');for(C=0;C<J.length;C++){var M=C<J.length/2?K:L;M.append(J[C].radio);}}var N={};N.dic_create=function(S,T,U){var V=U[0]+','+U[1],W=c.err_dic_create,X=c.succ_dic_create;window.scayt.createUserDictionary(T,function(Y){w(V);v(U[1]);X=X.replace('%s',Y.dname);u(X);},function(Y){W=W.replace('%s',Y.dname);t(W+'( '+(Y.message||'')+')');});};N.dic_rename=function(S,T){var U=c.err_dic_rename||'',V=c.succ_dic_rename||'';window.scayt.renameUserDictionary(T,function(W){V=V.replace('%s',W.dname);\r
-x(T);u(V);},function(W){U=U.replace('%s',W.dname);x(T);t(U+'( '+(W.message||'')+' )');});};N.dic_delete=function(S,T,U){var V=U[0]+','+U[1],W=c.err_dic_delete,X=c.succ_dic_delete;window.scayt.deleteUserDictionary(function(Y){X=X.replace('%s',Y.dname);w(V);v(U[0]);x('');u(X);},function(Y){W=W.replace('%s',Y.dname);t(W);});};N.dic_restore=y.dic_restore||(function(S,T,U){var V=U[0]+','+U[1],W=c.err_dic_restore,X=c.succ_dic_restore;window.scayt.restoreUserDictionary(T,function(Y){X=X.replace('%s',Y.dname);w(V);v(U[1]);u(X);},function(Y){W=W.replace('%s',Y.dname);t(W);});});function O(S){var T=d.getById('dic_name').getValue();if(!T){t(' Dictionary name should not be empty. ');return false;}try{var U=id=S.data.getTarget().getParent(),V=U.getId();N[V].apply(null,[U,T,i]);}catch(W){t(' Dictionary error. ');}return true;};var P=(i[0]+','+i[1]).split(','),Q;for(C=0,Q=P.length;C<Q;C+=1){var R=d.getById(P[C]);if(R)R.on('click',O,this);}},s=function(){var y=this;if(e[0]==1){var z=k();for(var A=0,B=z.length;A<B;A++){var C=z[A].id,D=d.getById(C);if(D){z[A].checked=false;if(y.options[C]==1)z[A].checked=true;if(b)D.on('click',function(){y.options[this.getId()]=this.$.checked?1:0;});}}}if(e[1]==1){var E=d.getById('cke_option'+y.sLang);m(E.$,y.sLang);}if(h){window.scayt.getNameUserDictionary(function(F){var G=F.dname;w(i[0]+','+i[1]);if(G){d.getById('dic_name').setValue(G);v(i[1]);}else v(i[0]);},function(){d.getById('dic_name').setValue('');});u('');}};function t(y){d.getById('dic_message').setHtml('<span style="color:red;">'+y+'</span>');};function u(y){d.getById('dic_message').setHtml('<span style="color:blue;">'+y+'</span>');};function v(y){y=String(y);var z=y.split(',');for(var A=0,B=z.length;A<B;A+=1)d.getById(z[A]).$.style.display='inline';};function w(y){y=String(y);var z=y.split(',');for(var A=0,B=z.length;A<B;A+=1)d.getById(z[A]).$.style.display='none';};function x(y){d.getById('dic_name').$.value=y;};return p;});\r
+/*
+ Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
+ For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+CKEDITOR.dialog.add("scaytcheck",function(j){function w(){return"undefined"!=typeof document.forms["optionsbar_"+a]?document.forms["optionsbar_"+a].options:[]}function x(b,a){if(b){var e=b.length;if(void 0==e)b.checked=b.value==a.toString();else for(var d=0;d<e;d++)b[d].checked=!1,b[d].value==a.toString()&&(b[d].checked=!0)}}function n(b){f.getById("dic_message_"+a).setHtml('<span style="color:red;">'+b+"</span>")}function o(b){f.getById("dic_message_"+a).setHtml('<span style="color:blue;">'+b+"</span>")}
+function p(b){for(var b=(""+b).split(","),a=0,e=b.length;a<e;a+=1)f.getById(b[a]).$.style.display="inline"}function q(b){for(var b=(""+b).split(","),a=0,e=b.length;a<e;a+=1)f.getById(b[a]).$.style.display="none"}function r(b){f.getById("dic_name_"+a).$.value=b}var s=!0,h,f=CKEDITOR.document,a=j.name,l=CKEDITOR.plugins.scayt.getUiTabs(j),g,t=[],u=0,m=["dic_create_"+a+",dic_restore_"+a,"dic_rename_"+a+",dic_delete_"+a],v=["mixedCase","mixedWithDigits","allCaps","ignoreDomainNames"];g=j.lang.scayt;var z=
+[{id:"options",label:g.optionsTab,elements:[{type:"html",id:"options",html:'<form name="optionsbar_'+a+'"><div class="inner_options">\t<div class="messagebox"></div>\t<div style="display:none;">\t\t<input type="checkbox" name="options"  id="allCaps_'+a+'" />\t\t<label style = "display: inline" for="allCaps" id="label_allCaps_'+a+'"></label>\t</div>\t<div style="display:none;">\t\t<input name="options" type="checkbox"  id="ignoreDomainNames_'+a+'" />\t\t<label style = "display: inline" for="ignoreDomainNames" id="label_ignoreDomainNames_'+
+a+'"></label>\t</div>\t<div style="display:none;">\t<input name="options" type="checkbox"  id="mixedCase_'+a+'" />\t\t<label style = "display: inline" for="mixedCase" id="label_mixedCase_'+a+'"></label>\t</div>\t<div style="display:none;">\t\t<input name="options" type="checkbox"  id="mixedWithDigits_'+a+'" />\t\t<label style = "display: inline" for="mixedWithDigits" id="label_mixedWithDigits_'+a+'"></label>\t</div></div></form>'}]},{id:"langs",label:g.languagesTab,elements:[{type:"html",id:"langs",
+html:'<form name="languagesbar_'+a+'"><div class="inner_langs">\t<div class="messagebox"></div>\t   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol_'+a+'" ></div>   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol_'+a+'"></div></div></form>'}]},{id:"dictionaries",label:g.dictionariesTab,elements:[{type:"html",style:"",id:"dictionaries",html:'<form name="dictionarybar_'+a+'"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">\t<div style="margin:5px auto; width:95%;white-space:normal; overflow:hidden;" id="dic_message_'+
+a+'"> </div>\t<div style="margin:5px auto; width:95%;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_'+a+'" type="text" class="cke_dialog_ui_input_text" style = "height: 25px; background: none; padding: 0;"/>\t\t</div></span></div>\t\t<div style="margin:5px auto; width:95%;white-space:normal;">\t\t\t<a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create_'+
+a+'">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete_'+a+'">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename_'+a+'">\t\t\t\t</a>\t\t\t<a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore_'+a+'">\t\t\t\t</a>\t\t</div>\t<div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info_'+a+'"></div></div></form>'}]},{id:"about",
+label:g.aboutTab,elements:[{type:"html",id:"about",style:"margin: 5px 5px;",html:'<div id="scayt_about_'+a+'"></div>'}]}],B={title:g.title,minWidth:360,minHeight:220,onShow:function(){var b=this;b.data=j.fire("scaytDialog",{});b.options=b.data.scayt_control.option();b.chosed_lang=b.sLang=b.data.scayt_control.sLang;if(!b.data||!b.data.scayt||!b.data.scayt_control)alert("Error loading application service"),b.hide();else{var a=0;s?b.data.scayt.getCaption(j.langCode||"en",function(e){0<a++||(h=e,A.apply(b),
+y.apply(b),s=!1)}):y.apply(b);b.selectPage(b.data.tab)}},onOk:function(){var a=this.data.scayt_control;a.option(this.options);a.setLang(this.chosed_lang);a.refresh()},onCancel:function(){var b=w(),f;for(f in b)b[f].checked=!1;b="undefined"!=typeof document.forms["languagesbar_"+a]?document.forms["languagesbar_"+a].scayt_lang:[];x(b,"")},contents:t};CKEDITOR.plugins.scayt.getScayt(j);for(g=0;g<l.length;g++)1==l[g]&&(t[t.length]=z[g]);1==l[2]&&(u=1);var A=function(){function b(b){var c=f.getById("dic_name_"+
+a).getValue();if(!c)return n(" Dictionary name should not be empty. "),!1;try{var d=b.data.getTarget().getParent(),e=/(dic_\w+)_[\w\d]+/.exec(d.getId())[1];j[e].apply(null,[d,c,m])}catch(C){n(" Dictionary error. ")}return!0}var k=this,e=k.data.scayt.getLangList(),d=["dic_create","dic_delete","dic_rename","dic_restore"],g=[],i=[],c;if(u){for(c=0;c<d.length;c++)g[c]=d[c]+"_"+a,f.getById(g[c]).setHtml('<span class="cke_dialog_ui_button">'+h["button_"+d[c]]+"</span>");f.getById("dic_info_"+a).setHtml(h.dic_info)}if(1==
+l[0])for(c in v)d="label_"+v[c],g=f.getById(d+"_"+a),"undefined"!=typeof g&&("undefined"!=typeof h[d]&&"undefined"!=typeof k.options[v[c]])&&(g.setHtml(h[d]),g.getParent().$.style.display="block");d='<p><img src="'+window.scayt.getAboutInfo().logoURL+'" /></p><p>'+h.version+window.scayt.getAboutInfo().version.toString()+"</p><p>"+h.about_throwt_copy+"</p>";f.getById("scayt_about_"+a).setHtml(d);d=function(a,b){var c=f.createElement("label");c.setAttribute("for","cke_option"+a);c.setStyle("display",
+"inline");c.setHtml(b[a]);k.sLang==a&&(k.chosed_lang=a);var d=f.createElement("div"),e=CKEDITOR.dom.element.createFromHtml('<input class = "cke_dialog_ui_radio_input" id="cke_option'+a+'" type="radio" '+(k.sLang==a?'checked="checked"':"")+' value="'+a+'" name="scayt_lang" />');e.on("click",function(){this.$.checked=true;k.chosed_lang=a});d.append(e);d.append(c);return{lang:b[a],code:a,radio:d}};if(1==l[1]){for(c in e.rtl)i[i.length]=d(c,e.ltr);for(c in e.ltr)i[i.length]=d(c,e.ltr);i.sort(function(a,
+b){return b.lang>a.lang?-1:1});e=f.getById("scayt_lcol_"+a);d=f.getById("scayt_rcol_"+a);for(c=0;c<i.length;c++)(c<i.length/2?e:d).append(i[c].radio)}var j={dic_create:function(a,b,c){var d=c[0]+","+c[1],e=h.err_dic_create,f=h.succ_dic_create;window.scayt.createUserDictionary(b,function(a){q(d);p(c[1]);f=f.replace("%s",a.dname);o(f)},function(a){e=e.replace("%s",a.dname);n(e+"( "+(a.message||"")+")")})},dic_rename:function(a,b){var c=h.err_dic_rename||"",d=h.succ_dic_rename||"";window.scayt.renameUserDictionary(b,
+function(a){d=d.replace("%s",a.dname);r(b);o(d)},function(a){c=c.replace("%s",a.dname);r(b);n(c+"( "+(a.message||"")+" )")})},dic_delete:function(a,b,c){var d=c[0]+","+c[1],e=h.err_dic_delete,f=h.succ_dic_delete;window.scayt.deleteUserDictionary(function(a){f=f.replace("%s",a.dname);q(d);p(c[0]);r("");o(f)},function(a){e=e.replace("%s",a.dname);n(e)})}};j.dic_restore=k.dic_restore||function(a,b,c){var d=c[0]+","+c[1],e=h.err_dic_restore,f=h.succ_dic_restore;window.scayt.restoreUserDictionary(b,function(a){f=
+f.replace("%s",a.dname);q(d);p(c[1]);o(f)},function(a){e=e.replace("%s",a.dname);n(e)})};i=(m[0]+","+m[1]).split(",");c=0;for(e=i.length;c<e;c+=1)if(d=f.getById(i[c]))d.on("click",b,this)},y=function(){var b=this;if(1==l[0])for(var g=w(),e=0,d=g.length;e<d;e++){var h=g[e].id,i=f.getById(h);if(i&&(g[e].checked=!1,1==b.options[h.split("_")[0]]&&(g[e].checked=!0),s))i.on("click",function(){b.options[this.getId().split("_")[0]]=this.$.checked?1:0})}1==l[1]&&(g=f.getById("cke_option"+b.sLang),x(g.$,b.sLang));
+u&&(window.scayt.getNameUserDictionary(function(b){b=b.dname;q(m[0]+","+m[1]);if(b){f.getById("dic_name_"+a).setValue(b);p(m[1])}else p(m[0])},function(){f.getById("dic_name_"+a).setValue("")}),o(""))};return B});
\ No newline at end of file