From e34ca695e3505069d399fdc5e4a29e213c319de7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 12 Aug 2020 20:30:25 +0300 Subject: [PATCH] [PE][SSE] Refactoring --- .../main/app/controller/Main.js | 41 +++++++++++-------- .../main/app/controller/Main.js | 41 +++++++++++-------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 49ed377b8..85b4a6210 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -782,24 +782,7 @@ define([ Common.Utils.InternalSettings.set("pe-settings-paste-button", parseInt(value)); me.api.asc_setVisiblePasteButton(!!parseInt(value)); - // autocorrection - value = Common.localStorage.getItem("pe-settings-math-correct-add"); - Common.Utils.InternalSettings.set("pe-settings-math-correct-add", value); - var arrAdd = value ? JSON.parse(value) : []; - value = Common.localStorage.getItem("pe-settings-math-correct-rem"); - Common.Utils.InternalSettings.set("pe-settings-math-correct-rem", value); - var arrRem = value ? JSON.parse(value) : []; - value = Common.localStorage.getBool("pe-settings-math-correct-replace-type", true); // replace on type - Common.Utils.InternalSettings.set("pe-settings-math-correct-replace-type", value); - me.api.asc_refreshOnStartAutoCorrectMathSymbols(arrRem, arrAdd, value); - - value = Common.localStorage.getItem("pe-settings-rec-functions-add"); - Common.Utils.InternalSettings.set("pe-settings-rec-functions-add", value); - arrAdd = value ? JSON.parse(value) : []; - value = Common.localStorage.getItem("pe-settings-rec-functions-rem"); - Common.Utils.InternalSettings.set("pe-settings-rec-functions-rem", value); - arrRem = value ? JSON.parse(value) : []; - me.api.asc_refreshOnStartAutoCorrectMathFunctions(arrRem, arrAdd); + me.loadAutoCorrectSettings(); if (me.needToUpdateVersion) Common.NotificationCenter.trigger('api:disconnect'); @@ -1955,6 +1938,28 @@ define([ } }, + loadAutoCorrectSettings: function() { + // autocorrection + var me = this; + var value = Common.localStorage.getItem("pe-settings-math-correct-add"); + Common.Utils.InternalSettings.set("pe-settings-math-correct-add", value); + var arrAdd = value ? JSON.parse(value) : []; + value = Common.localStorage.getItem("pe-settings-math-correct-rem"); + Common.Utils.InternalSettings.set("pe-settings-math-correct-rem", value); + var arrRem = value ? JSON.parse(value) : []; + value = Common.localStorage.getBool("pe-settings-math-correct-replace-type", true); // replace on type + Common.Utils.InternalSettings.set("pe-settings-math-correct-replace-type", value); + me.api.asc_refreshOnStartAutoCorrectMathSymbols(arrRem, arrAdd, value); + + value = Common.localStorage.getItem("pe-settings-rec-functions-add"); + Common.Utils.InternalSettings.set("pe-settings-rec-functions-add", value); + arrAdd = value ? JSON.parse(value) : []; + value = Common.localStorage.getItem("pe-settings-rec-functions-rem"); + Common.Utils.InternalSettings.set("pe-settings-rec-functions-rem", value); + arrRem = value ? JSON.parse(value) : []; + me.api.asc_refreshOnStartAutoCorrectMathFunctions(arrRem, arrAdd); + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a4a50d41c..7638d4a8b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -820,24 +820,7 @@ define([ Common.Utils.InternalSettings.set("sse-settings-paste-button", parseInt(value)); me.api.asc_setVisiblePasteButton(!!parseInt(value)); - // autocorrection - value = Common.localStorage.getItem("sse-settings-math-correct-add"); - Common.Utils.InternalSettings.set("sse-settings-math-correct-add", value); - var arrAdd = value ? JSON.parse(value) : []; - value = Common.localStorage.getItem("sse-settings-math-correct-rem"); - Common.Utils.InternalSettings.set("sse-settings-math-correct-rem", value); - var arrRem = value ? JSON.parse(value) : []; - value = Common.localStorage.getBool("sse-settings-math-correct-replace-type", true); // replace on type - Common.Utils.InternalSettings.set("sse-settings-math-correct-replace-type", value); - me.api.asc_refreshOnStartAutoCorrectMathSymbols(arrRem, arrAdd, value); - - value = Common.localStorage.getItem("sse-settings-rec-functions-add"); - Common.Utils.InternalSettings.set("sse-settings-rec-functions-add", value); - arrAdd = value ? JSON.parse(value) : []; - value = Common.localStorage.getItem("sse-settings-rec-functions-rem"); - Common.Utils.InternalSettings.set("sse-settings-rec-functions-rem", value); - arrRem = value ? JSON.parse(value) : []; - me.api.asc_refreshOnStartAutoCorrectMathFunctions(arrRem, arrAdd); + me.loadAutoCorrectSettings(); if (me.needToUpdateVersion) { Common.NotificationCenter.trigger('api:disconnect'); @@ -2262,6 +2245,28 @@ define([ } }, + loadAutoCorrectSettings: function() { + // autocorrection + var me = this; + var value = Common.localStorage.getItem("sse-settings-math-correct-add"); + Common.Utils.InternalSettings.set("sse-settings-math-correct-add", value); + var arrAdd = value ? JSON.parse(value) : []; + value = Common.localStorage.getItem("sse-settings-math-correct-rem"); + Common.Utils.InternalSettings.set("sse-settings-math-correct-rem", value); + var arrRem = value ? JSON.parse(value) : []; + value = Common.localStorage.getBool("sse-settings-math-correct-replace-type", true); // replace on type + Common.Utils.InternalSettings.set("sse-settings-math-correct-replace-type", value); + me.api.asc_refreshOnStartAutoCorrectMathSymbols(arrRem, arrAdd, value); + + value = Common.localStorage.getItem("sse-settings-rec-functions-add"); + Common.Utils.InternalSettings.set("sse-settings-rec-functions-add", value); + arrAdd = value ? JSON.parse(value) : []; + value = Common.localStorage.getItem("sse-settings-rec-functions-rem"); + Common.Utils.InternalSettings.set("sse-settings-rec-functions-rem", value); + arrRem = value ? JSON.parse(value) : []; + me.api.asc_refreshOnStartAutoCorrectMathFunctions(arrRem, arrAdd); + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning',