var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var e=c++;return{value:b(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");Ext.namespace("Zarafa.plugins.spellchecker");
Zarafa.plugins.spellchecker.SpellcheckerPlugin=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){Zarafa.plugins.spellchecker.SpellcheckerPlugin.superclass.initPlugin.apply(this,arguments);this.registerInsertionPoint("context.settings.category.mail.aftercomposesettings",this.createSettingsWidget,this);this.registerInsertionPoint("common.htmleditor.tinymceconfig",this.createTinyMCEConfig,this)},getSupportedLanguages:function(){var a={};container.populateInsertionPoint("plugins.spellchecker.supportedlanguages",
{scope:this,languages:a});return a},getDefaultLanguage:function(){var a=container.getSettingsModel().get("zarafa/v1/plugins/spellchecker/spellchecker_language"),b=this.getUserSelectedLanguages(!0);if(!Ext.isEmpty(a)&&0<=b.indexOf(a))return a;switch(container.getSettingsModel().get("zarafa/v1/main/language").substr(0,2)){case "de":a="de_DE";break;case "fr":a="fr_FR";break;case "it":a="it_IT";break;case "es":a="es_ES";break;case "nl":a="nl_NL";break;case "pt":a="pt_PT";break;case "ru":a="ru_RU";break;
default:a="en_US"}0>b.indexOf(a)&&(a=0<b.length?b[0]:"");container.getSettingsModel().set("zarafa/v1/plugins/spellchecker/spellchecker_language",a);return a},getUserSelectedLanguages:function(a){var b=this.getSupportedLanguages(),c=container.getSettingsModel().get("zarafa/v1/plugins/spellchecker/spellchecker_languages").split(", "),d=[];Ext.each(c,function(c){b.hasOwnProperty(c)&&(a?d.push(c):d.push(b[c]+"="+c))});d.sort();return d},createTinyMCEConfig:function(a,b){var c=this.getUserSelectedLanguages();
0!==c.length&&(b.config.spellchecker_rpc_url="spellchecker.php",b.config.spellchecker_language=this.getDefaultLanguage(),b.config.spellchecker_languages=c.join(", "),b.config.browser_spellcheck=!1,Ext.isDefined(b.config.external_plugins)||(b.config.external_plugins={}),b.config.external_plugins.spellchecker="../../plugins/spellchecker/tinymce-plugin/spellchecker/plugin.min.js",b.config.toolbar1+=" | spellchecker")},createSettingsWidget:function(){return{xtype:"zarafa.settingshtmleditorwidget"}}});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"spellchecker",displayName:_("Spellchecker"),pluginConstructor:Zarafa.plugins.spellchecker.SpellcheckerPlugin}))});Ext.namespace("Zarafa.plugins.spellchecker.settings");
Zarafa.plugins.spellchecker.settings.SettingsHtmlEditorWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{settingsLanguagesName:"zarafa/v1/plugins/spellchecker/spellchecker_languages",settingsDefaultLanguageName:"zarafa/v1/plugins/spellchecker/spellchecker_language",constructor:function(a){a=a||{};var b=container.getPluginByName("spellchecker"),c=b.getSupportedLanguages();Ext.applyIf(a,{title:_("HTML editor settings"),layout:"form",items:[]});if(0<Object.keys(c).length){var c=b.getUserSelectedLanguages(),
b=b.getDefaultLanguage(),d=[];Ext.each(c,function(a){a=a.split("=");d.push([a[1],a[0]])});var e=new Ext.data.ArrayStore({fields:["code","display"],data:d});a.items=[{xtype:"displayfield",hideLabel:!0,value:_("Enable the following languages for the spell checker")+':<br><span style="opacity:0.5;">('+_("Note: When no language is selected the browsers spell checking features will be enabled if available")+")</span>"},{xtype:"checkboxgroup",name:this.settingsLanguagesName,ref:"spellCheckerLanguagesGroup",
columns:1,hideLabel:!0,items:this.createSpellCheckerLanguageOptions(),listeners:{change:this.onSpellCheckerLanguagesChange,scope:this}},{xtype:"combo",name:this.settingsDefaultLanguageName,ref:"spellCheckerDefaultLanguageCombo",fieldLabel:_("Default selected language"),store:e,displayField:"display",valueField:"code",editable:!1,mode:"local",triggerAction:"all",allowBlank:!0,autoSelect:!0,typeAhead:!1,value:b,disabled:0===c.length?!0:!1,validateOnBlur:!1,invalidClass:"",listeners:{change:this.onSpellCheckerLanguageChange,
scope:this}}]}else a.items=[{xtype:"displayfield",hideLabel:!0,value:_("No language pack found. Ask your administrator to install language pack plugins to use the spellchecker in the HTML editor.")}];Zarafa.plugins.spellchecker.settings.SettingsHtmlEditorWidget.superclass.constructor.call(this,a)},createSpellCheckerLanguageOptions:function(){var a=container.getPluginByName("spellchecker"),b=a.getSupportedLanguages(),c=a.getUserSelectedLanguages(!0),d=[];Ext.iterate(b,function(a,b){d.push({xtype:"checkbox",
name:"spellCheckerLanguages",inputValue:a,boxLabel:b,checked:0<=c.indexOf(a)?!0:!1})});d.sort(function(a,b){return a.boxLabel<b.boxLabel?-1:1});return d},update:function(a){if(Ext.isDefined(this.spellCheckerLanguagesGroup)){this.model=a;var b=a.get(this.settingsName);Ext.isDefined(b)||(b="");b=b.split(", ");Ext.each(this.spellCheckerLanguagesGroup.items.items,function(a){-1<b.indexOf(a.getRawValue())&&a.setValue(!0)},this)}},onSpellCheckerLanguagesChange:function(a,b){if(this.model){var c=[];Ext.each(b,
function(a){c.push(a.getRawValue())});c.sort();c=c.join(", ");this.model.get(a.name)!==c&&this.model.set(a.name,c)}var d=this.spellCheckerDefaultLanguageCombo.getValue(),e=!1,f=[];Ext.each(b,function(a){f.push([a.getRawValue(),a.boxLabel]);a.getRawValue()===d&&(e=!0)});this.spellCheckerDefaultLanguageCombo.getStore().loadData(f);0===b.length?(this.spellCheckerDefaultLanguageCombo.setValue(""),this.spellCheckerDefaultLanguageCombo.disable()):(this.spellCheckerDefaultLanguageCombo.enable(),e||this.spellCheckerDefaultLanguageCombo.setValue(b[0].getRawValue()))},
onSpellCheckerLanguageChange:function(a,b,c){this.model&&this.model.get(a.name)!==b&&this.model.set(a.name,b)}});Ext.reg("zarafa.settingshtmleditorwidget",Zarafa.plugins.spellchecker.settings.SettingsHtmlEditorWidget);//# sourceMappingURL=spellchecker.js.map
