diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index f2027bef3..721d81d7b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -164,6 +164,7 @@ define([ this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this)); this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this)); + this.api.asc_registerCallback('asc_onSpellCheckInit', _.bind(this.loadLanguages, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this)); @@ -742,6 +743,7 @@ define([ documentHolderView.createDelayedElements(); toolbarController.createDelayedElements(); + me.setLanguages(); if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { var shapes = me.api.asc_getPropertyEditorShapes(); @@ -1817,6 +1819,15 @@ define([ } }, + loadLanguages: function(apiLangs) { + this.languages = apiLangs; + window.styles_loaded && this.setLanguages(); + }, + + setLanguages: function() { + this.getApplication().getController('Spellcheck').setLanguages(this.languages); + }, + onInternalCommand: function(data) { if (data) { switch (data.command) { diff --git a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js index 25ddf5183..bb89ad1f3 100644 --- a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js +++ b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js @@ -54,6 +54,7 @@ define([ this.addListeners({ 'Spellcheck': { 'show': function() { + me.loadLanguages(); if (me.api) { me.api.asc_startSpellCheck(); } @@ -76,18 +77,21 @@ define([ setApi: function(api) { this.api = api; - this.api.asc_registerCallback('asc_onSpellCheckInit',_.bind(this.loadLanguages, this)); return this; }, setMode: function(mode) { this.mode = mode; + if (this.panelSpellcheck) { + this.panelSpellcheck.btnToDictionary.setVisible(mode.isDesktopApp); + } return this; }, onAfterRender: function(panelSpellcheck) { panelSpellcheck.buttonPreview.on('click', _.bind(this.onClickPreview, this)); panelSpellcheck.buttonNext.on('click', _.bind(this.onClickNext, this)); + panelSpellcheck.btnToDictionary.on('click', _.bind(this.onDictionary, this)); panelSpellcheck.cmbDictionaryLanguage.on('selected', _.bind(this.onSelectLanguage, this)); }, @@ -103,29 +107,42 @@ define([ } }, + onDictionary: function() { + if (this.api) { + var rec = this.panelSpellcheck.suggestionList.getSelectedRec(); + rec && this.api.asc_AddToDictionary(rec.get('value')); + } + }, + SetDisabled: function(state) { this._isDisabled = state; }, - loadLanguages: function (apiLangs) { - var langs = [], info, - allLangs = Common.util.LanguageInfo.getLanguages(); - apiLangs.forEach(function (code) { - if (allLangs.hasOwnProperty(parseInt(code))) { - info = allLangs[parseInt(code)]; - langs.push({ - displayValue: info[1], - value: info[0], - code: parseInt(code), - }); - } - }); - this.languages = langs; - this.panelSpellcheck.cmbDictionaryLanguage.setData(this.languages); - /*var codeCurLang = this.api.asc_getDefaultLanguage();*/ - var codeCurLang = 1036; - var curLang = allLangs[codeCurLang][0]; - this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang); + setLanguages: function (array) { + this.languages = array; + }, + + loadLanguages: function () { + if (this.languages && this.languages.length>0) { + var langs = [], info, + allLangs = Common.util.LanguageInfo.getLanguages(); + this.languages.forEach(function (code) { + if (allLangs.hasOwnProperty(parseInt(code))) { + info = allLangs[parseInt(code)]; + langs.push({ + displayValue: info[1], + value: info[0], + code: parseInt(code) + }); + } + }); + this.panelSpellcheck.cmbDictionaryLanguage.setData(langs); + /*var codeCurLang = this.api.asc_getDefaultLanguage();*/ + var codeCurLang = 1036; + var curLang = allLangs[codeCurLang][0]; + this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang); + } else + this.panelSpellcheck.cmbDictionaryLanguage.setDisabled(true); }, onSelectLanguage: function (combo, record) { diff --git a/apps/spreadsheeteditor/main/app/view/Spellcheck.js b/apps/spreadsheeteditor/main/app/view/Spellcheck.js index 4118e6689..ade22bd54 100644 --- a/apps/spreadsheeteditor/main/app/view/Spellcheck.js +++ b/apps/spreadsheeteditor/main/app/view/Spellcheck.js @@ -56,7 +56,7 @@ define([ '
', '
', '
', - '
', + '', '
', '
<%= scope.txtComplete %>
', '' @@ -151,11 +151,14 @@ define([ this.cmbDictionaryLanguage = new Common.UI.ComboBox({ el : $('#spellcheck-dictionary-language'), style : 'width: 230px', - menuStyle : 'min-width: 230px;max-height: 300px;', + menuStyle : 'min-width: 230px;max-height: 200px;', editable : false, cls : 'input-group-nr' }); + this.btnToDictionary = new Common.UI.Button({ + el: $('#spellcheck-add-to-dictionary') + }); this.trigger('render:after', this); return this;