From ba281570801be55a3ad52bf9a4335befd2b26ce1 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Mon, 5 Aug 2019 11:55:24 +0300 Subject: [PATCH] [SSE] Add onClickNext, onClickPreview, show, loadLanguages in Spellcheck --- .../main/app/controller/Main.js | 4 ++- .../main/app/controller/Spellcheck.js | 36 ++++++++++++++++++- .../main/app/view/Spellcheck.js | 5 ++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 94d25fb03..f2027bef3 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -683,7 +683,8 @@ define([ leftMenuView = leftmenuController.getView('LeftMenu'), documentHolderView = documentHolderController.getView('DocumentHolder'), chatController = application.getController('Common.Controllers.Chat'), - pluginsController = application.getController('Common.Controllers.Plugins'); + pluginsController = application.getController('Common.Controllers.Plugins'), + spellcheckController = application.getController('Spellcheck'); leftMenuView.getMenu('file').loadDocument({doc:me.appOptions.spreadsheet}); leftmenuController.setMode(me.appOptions).createDelayedElements().setApi(me.api); @@ -700,6 +701,7 @@ define([ documentHolderController.setApi(me.api).loadConfig({config:me.editorConfig}); chatController.setApi(this.api).setMode(this.appOptions); + spellcheckController.setApi(this.api).setMode(this.appOptions); statusbarController.createDelayedElements(); statusbarController.setApi(me.api); diff --git a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js index 1c22005f2..d8a63c993 100644 --- a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js +++ b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js @@ -54,6 +54,9 @@ define([ this.addListeners({ 'Spellcheck': { 'show': function() { + if (me.api) { + me.api.asc_startSpellCheck(); + } }, 'hide': function() { } @@ -73,7 +76,7 @@ define([ setApi: function(api) { this.api = api; - // this.api.asc_registerCallback('asc_onDocumentOutlineUpdate', _.bind(this.updateSpellcheck, this)); + this.api.asc_registerCallback('asc_onSpellCheckInit',_.bind(this.loadLanguages, this)); return this; }, @@ -83,10 +86,41 @@ define([ }, onAfterRender: function(panelSpellcheck) { + panelSpellcheck.buttonPreview.on('click', _.bind(this.onClickPreview, this)); + panelSpellcheck.buttonNext.on('click', _.bind(this.onClickNext, this)); + }, + + onClickPreview: function() { + if (this.api) { + this.api.asc_previousWord(); + } + }, + + onClickNext: function() { + if (this.api) { + this.api.asc_nextWord(); + } }, 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); } }, SSE.Controllers.Spellcheck || {})); diff --git a/apps/spreadsheeteditor/main/app/view/Spellcheck.js b/apps/spreadsheeteditor/main/app/view/Spellcheck.js index 1de5b2acc..b686eec6b 100644 --- a/apps/spreadsheeteditor/main/app/view/Spellcheck.js +++ b/apps/spreadsheeteditor/main/app/view/Spellcheck.js @@ -153,10 +153,9 @@ define([ this.cmbDictionaryLanguage = new Common.UI.ComboBox({ el : $('#spellcheck-dictionary-language'), style : 'width: 230px', - menuStyle : 'min-width: 230px;', + menuStyle : 'width: 230px;', editable : false, - cls : 'input-group-nr', - data : [] + cls : 'input-group-nr' });