From 8c193881d10a2208cfa27641dc8a38d8fafdb77d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 Oct 2017 18:44:01 +0300 Subject: [PATCH] [PE][SSE] Bug 35406. --- .../main/app/controller/LeftMenu.js | 4 +- .../main/app/controller/Main.js | 4 +- .../main/app/view/FileMenuPanels.js | 4 +- .../main/app/controller/LeftMenu.js | 19 ++++++--- .../main/app/controller/Main.js | 23 +++++++++-- .../main/app/controller/Statusbar.js | 1 + .../main/app/view/FileMenuPanels.js | 33 +++++++-------- .../main/app/controller/FormulaDialog.js | 5 +-- .../main/app/controller/LeftMenu.js | 38 +++++++++++------- .../main/app/controller/Main.js | 40 +++++++++++++------ .../main/app/controller/Statusbar.js | 4 +- .../main/app/view/FileMenuPanels.js | 39 ++++++------------ .../main/app/view/FormulaDialog.js | 2 +- .../main/app/view/NamedRangeEditDlg.js | 5 +-- 14 files changed, 121 insertions(+), 100 deletions(-) diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 1c0cd7b68..e8f7d583c 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -350,9 +350,7 @@ define([ this.api.asc_setSpellCheck(value); } - value = Common.localStorage.getBool("de-settings-showsnaplines", true); - Common.Utils.InternalSettings.set("de-settings-showsnaplines", value); - this.api.put_ShowSnapLines(value); + this.api.put_ShowSnapLines(Common.Utils.InternalSettings.get("de-settings-showsnaplines")); menu.hide(); }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 1489ece86..3b530a4e9 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -777,9 +777,7 @@ define([ Common.Utils.InternalSettings.set("de-settings-spellcheck", value); me.api.asc_setSpellCheck(value); - value = me.api.get_ShowSnapLines(); - Common.Utils.InternalSettings.set("de-settings-showsnaplines", value); - Common.localStorage.setBool("de-settings-showsnaplines", value); + Common.Utils.InternalSettings.set("de-settings-showsnaplines", me.api.get_ShowSnapLines()); function checkWarns() { if (!window['AscDesktopEditor']) { diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 847715c35..371181e90 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -366,7 +366,7 @@ define([ /** coauthoring end **/ value = Common.Utils.InternalSettings.get("de-settings-fontrender"); - item = this.cmbFontRender.store.findWhere({value: value}); + item = this.cmbFontRender.store.findWhere({value: parseInt(value)}); this.cmbFontRender.setValue(item ? item.get('value') : (window.devicePixelRatio > 1 ? 1 : 0)); value = Common.Utils.InternalSettings.get("de-settings-unit"); @@ -403,7 +403,7 @@ define([ if (this.mode.canForcesave) Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0); Common.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0); - Common.localStorage.setItem("de-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0); + Common.Utils.InternalSettings.set("de-settings-showsnaplines", this.chAlignGuides.isChecked()); Common.localStorage.save(); if (this.menu) { diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index c21a70bc4..311c07de2 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -240,22 +240,29 @@ define([ }, applySettings: function(menu) { - this.api.SetTextBoxInputMode(Common.localStorage.getBool("pe-settings-inputmode")); + var value = Common.localStorage.getBool("pe-settings-inputmode"); + Common.Utils.InternalSettings.set("pe-settings-inputmode", value); + this.api.SetTextBoxInputMode(value); /** coauthoring begin **/ if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { - this.api.asc_SetFastCollaborative(Common.localStorage.getBool("pe-settings-coauthmode", true)); + value = Common.localStorage.getBool("pe-settings-coauthmode", true); + Common.Utils.InternalSettings.set("pe-settings-coauthmode", value); + this.api.asc_SetFastCollaborative(value); } /** coauthoring end **/ if (this.mode.isEdit) { - var value = Common.localStorage.getItem("pe-settings-autosave"); - this.api.asc_setAutoSaveGap(parseInt(value)); + value = parseInt(Common.localStorage.getItem("pe-settings-autosave")); + Common.Utils.InternalSettings.set("pe-settings-autosave", value); + this.api.asc_setAutoSaveGap(value); - this.api.asc_setSpellCheck(Common.localStorage.getBool("pe-settings-spellcheck", true)); + value = Common.localStorage.getBool("pe-settings-spellcheck", true); + Common.Utils.InternalSettings.set("pe-settings-spellcheck", value); + this.api.asc_setSpellCheck(value); } - this.api.put_ShowSnapLines( Common.localStorage.getBool("pe-settings-showsnaplines") ); + this.api.put_ShowSnapLines(Common.Utils.InternalSettings.get("pe-settings-showsnaplines")); menu.hide(); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index b07686675..89a73fe4c 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -567,10 +567,13 @@ define([ me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); value = Common.localStorage.getItem("pe-settings-zoom"); + Common.Utils.InternalSettings.set("pe-settings-zoom", value); var zf = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom) : -1); (zf == -1) ? this.api.zoomFitToPage() : ((zf == -2) ? this.api.zoomFitToWidth() : this.api.zoom(zf>0 ? zf : 100)); - me.api.asc_setSpellCheck(Common.localStorage.getBool("pe-settings-spellcheck", true)); + value = Common.localStorage.getBool("pe-settings-spellcheck", true); + Common.Utils.InternalSettings.set("pe-settings-spellcheck", value); + me.api.asc_setSpellCheck(value); function checkWarns() { if (!window['AscDesktopEditor']) { @@ -594,7 +597,9 @@ define([ appHeader.setDocumentCaption( me.api.asc_getDocumentName() ); me.updateWindowTitle(true); - me.api.SetTextBoxInputMode(Common.localStorage.getBool("pe-settings-inputmode")); + value = Common.localStorage.getBool("pe-settings-inputmode"); + Common.Utils.InternalSettings.set("pe-settings-inputmode", value); + me.api.SetTextBoxInputMode(value); /** coauthoring begin **/ if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) { @@ -606,12 +611,16 @@ define([ me._state.fastCoauth = (value===null || parseInt(value) == 1); } else { me._state.fastCoauth = (!me.appOptions.isEdit && me.appOptions.canComments); - me._state.fastCoauth && me.api.asc_setAutoSaveGap(1); + if (me._state.fastCoauth) { + me.api.asc_setAutoSaveGap(1); + Common.Utils.InternalSettings.set("pe-settings-autosave", 1); + } } me.api.asc_SetFastCollaborative(me._state.fastCoauth); + Common.Utils.InternalSettings.set("pe-settings-coauthmode", me._state.fastCoauth); /** coauthoring end **/ - Common.localStorage.setBool("pe-settings-showsnaplines", me.api.get_ShowSnapLines()); + Common.Utils.InternalSettings.set("pe-settings-showsnaplines", me.api.get_ShowSnapLines()); var application = me.getApplication(); var toolbarController = application.getController('Toolbar'), @@ -655,9 +664,11 @@ define([ value = 0; value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0); me.api.asc_setAutoSaveGap(value); + Common.Utils.InternalSettings.set("pe-settings-autosave", value); if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true me.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", me.appOptions.canForcesave); + Common.Utils.InternalSettings.set("pe-settings-forcesave", me.appOptions.forcesave); me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); } @@ -884,6 +895,7 @@ define([ var value = Common.localStorage.getItem('pe-settings-unit'); value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); + Common.Utils.InternalSettings.set("pe-settings-unit", value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); if (me.api.asc_SetViewRulers) me.api.asc_SetViewRulers(!Common.localStorage.getBool('pe-hidden-rulers', true)); @@ -1375,6 +1387,7 @@ define([ var value = Common.localStorage.getItem("pe-settings-unit"); value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); + Common.Utils.InternalSettings.set("pe-settings-unit", value); this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); this.getApplication().getController('RightMenu').updateMetricUnit(); }, @@ -1542,6 +1555,7 @@ define([ if (btn == 'custom') { Common.localStorage.setItem("pe-settings-coauthmode", 0); this.api.asc_SetFastCollaborative(false); + Common.Utils.InternalSettings.set("pe-settings-coauthmode", false); this._state.fastCoauth = false; } this.onEditComplete(); @@ -1567,6 +1581,7 @@ define([ } if (this.appOptions.canForcesave) { this.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", this.appOptions.canForcesave); + Common.Utils.InternalSettings.set("pe-settings-forcesave", this.appOptions.forcesave); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); } }, diff --git a/apps/presentationeditor/main/app/controller/Statusbar.js b/apps/presentationeditor/main/app/controller/Statusbar.js index 1a7146282..3f6f86329 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -208,6 +208,7 @@ define([ onBtnSpelling: function(d, b, e) { Common.localStorage.setItem("pe-settings-spellcheck", d.pressed ? 1 : 0); + Common.Utils.InternalSettings.set("pe-settings-spellcheck", d.pressed); this.api.asc_setSpellCheck(d.pressed); Common.NotificationCenter.trigger('edit:complete', this.statusbar); }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 0d2867e6f..aa2e80de4 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -285,48 +285,42 @@ define([ }, updateSettings: function() { - this.chSpell.setValue(Common.localStorage.getBool("pe-settings-spellcheck", true)); + this.chSpell.setValue(Common.Utils.InternalSettings.get("pe-settings-spellcheck")); - this.chInputMode.setValue(Common.localStorage.getBool("pe-settings-inputmode")); + this.chInputMode.setValue(Common.Utils.InternalSettings.get("pe-settings-inputmode")); - var value = Common.localStorage.getItem("pe-settings-zoom"); + var value = Common.Utils.InternalSettings.get("pe-settings-zoom"); value = (value!==null) ? parseInt(value) : (this.mode.customization && this.mode.customization.zoom ? parseInt(this.mode.customization.zoom) : -1); var item = this.cmbZoom.store.findWhere({value: value}); this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100)); /** coauthoring begin **/ - value = Common.localStorage.getItem("pe-settings-coauthmode"); - if (value===null && !Common.localStorage.itemExists("pe-settings-autosave") && - this.mode.customization && this.mode.customization.autosave===false) - value = 0; // use customization.autosave only when pe-settings-coauthmode and pe-settings-autosave are null - var fast_coauth = (value===null || parseInt(value) == 1) && !(this.mode.isDesktopApp && this.mode.isOffline) && this.mode.canCoAuthoring; - - item = this.cmbCoAuthMode.store.findWhere({value: parseInt(value)}); + var fast_coauth = Common.Utils.InternalSettings.get("pe-settings-coauthmode"); + item = this.cmbCoAuthMode.store.findWhere({value: fast_coauth ? 1 : 0}); this.cmbCoAuthMode.setValue(item ? item.get('value') : 1); this.lblCoAuthMode.text(item ? item.get('descValue') : this.strCoAuthModeDescFast); /** coauthoring end **/ - value = Common.localStorage.getItem("pe-settings-unit"); - item = this.cmbUnit.store.findWhere({value: parseInt(value)}); + value = Common.Utils.InternalSettings.get("pe-settings-unit"); + item = this.cmbUnit.store.findWhere({value: value}); this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); this._oldUnits = this.cmbUnit.getValue(); - value = Common.localStorage.getItem("pe-settings-autosave"); - if (value===null && this.mode.customization && this.mode.customization.autosave===false) - value = 0; - this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); + value = Common.Utils.InternalSettings.get("pe-settings-autosave"); + this.chAutosave.setValue(value == 1); if (this.mode.canForcesave) { - this.chForcesave.setValue(Common.localStorage.getBool("pe-settings-forcesave", this.mode.canForcesave)); + this.chForcesave.setValue(Common.Utils.InternalSettings.get("pe-settings-forcesave")); } - this.chAlignGuides.setValue(Common.localStorage.getBool("pe-settings-showsnaplines", true)); + this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("pe-settings-showsnaplines")); }, applySettings: function() { Common.localStorage.setItem("pe-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0); Common.localStorage.setItem("pe-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0); Common.localStorage.setItem("pe-settings-zoom", this.cmbZoom.getValue()); + Common.Utils.InternalSettings.set("pe-settings-zoom", Common.localStorage.getItem("pe-settings-zoom")); /** coauthoring begin **/ if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { Common.localStorage.setItem("pe-settings-coauthmode", this.cmbCoAuthMode.getValue()); @@ -336,7 +330,8 @@ define([ Common.localStorage.setItem("pe-settings-autosave", this.chAutosave.isChecked() ? 1 : 0); if (this.mode.canForcesave) Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0); - Common.localStorage.setItem("pe-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0); + Common.Utils.InternalSettings.set("pe-settings-showsnaplines", this.chAlignGuides.isChecked()); + Common.localStorage.save(); if (this.menu) { diff --git a/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js b/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js index 98425604b..1215f5d81 100644 --- a/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js +++ b/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js @@ -137,10 +137,7 @@ define([ allFunctionsGroup = null; if (store) { - var value = Common.localStorage.getItem("sse-settings-func-locale"); - if (value===null) - value = ((this.mode.lang) ? this.mode.lang : 'en').split("-")[0].toLowerCase(); - value = SSE.Views.FormulaLang.getDescription(value); + var value = SSE.Views.FormulaLang.getDescription(Common.Utils.InternalSettings.get("sse-settings-func-locale")); allFunctionsGroup = new SSE.Models.FormulaGroup ({ name : 'All', diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 9ccd36207..c86923a07 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -266,26 +266,35 @@ define([ }, applySettings: function(menu) { - this.api.asc_setFontRenderingMode(parseInt(Common.localStorage.getItem("sse-settings-fontrender"))); + var value = Common.localStorage.getItem("sse-settings-fontrender"); + Common.Utils.InternalSettings.set("sse-settings-fontrender", value); + this.api.asc_setFontRenderingMode(parseInt(value)); /** coauthoring begin **/ - var value = Common.localStorage.getItem("sse-settings-livecomment"); - var resolved = Common.localStorage.getItem("sse-settings-resolvedcomment"); - (!(value!==null && parseInt(value) == 0)) ? this.api.asc_showComments(!(resolved!==null && parseInt(resolved) == 0)) : this.api.asc_hideComments(); -// this.getApplication().getController('DocumentHolder').setLiveCommenting(!(value!==null && parseInt(value) == 0)); + value = Common.localStorage.getBool("sse-settings-livecomment", true); + Common.Utils.InternalSettings.set("sse-settings-livecomment", value); + var resolved = Common.localStorage.getBool("sse-settings-resolvedcomment", true); + Common.Utils.InternalSettings.set("sse-settings-resolvedcomment", resolved); + + if (this.mode.canComments && this.leftMenu.panelComments.isVisible()) + value = resolved = true; + (value) ? this.api.asc_showComments(resolved) : this.api.asc_hideComments(); if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { - value = Common.localStorage.getItem("sse-settings-coauthmode"); - this.api.asc_SetFastCollaborative(value===null || parseInt(value) == 1); + value = Common.localStorage.getBool("sse-settings-coauthmode", true); + Common.Utils.InternalSettings.set("sse-settings-coauthmode", value); + this.api.asc_SetFastCollaborative(value); } /** coauthoring end **/ if (this.mode.isEdit) { - value = Common.localStorage.getItem("sse-settings-autosave"); - this.api.asc_setAutoSaveGap(parseInt(value)); + value = parseInt(Common.localStorage.getItem("sse-settings-autosave")); + Common.Utils.InternalSettings.set("sse-settings-autosave", value); + this.api.asc_setAutoSaveGap(value); } value = Common.localStorage.getItem("sse-settings-func-locale"); + Common.Utils.InternalSettings.set("sse-settings-func-locale", value); if (value) value = SSE.Views.FormulaLang.get(value); if (value!==null) this.api.asc_setLocalization(value); @@ -582,12 +591,11 @@ define([ commentsShowHide: function(state) { if (this.api) { - var value = Common.localStorage.getItem("sse-settings-livecomment"), - resolved = Common.localStorage.getItem("sse-settings-resolvedcomment"); - value = (value!==null && parseInt(value) == 0); - resolved = (resolved!==null && parseInt(resolved) == 0); - if (value || resolved) { - (state) ? this.api.asc_showComments(true) : ((!value) ? this.api.asc_showComments(!resolved) : this.api.asc_hideComments()); + var value = Common.Utils.InternalSettings.get("sse-settings-livecomment"), + resolved = Common.Utils.InternalSettings.get("sse-settings-resolvedcomment"); + + if (!value || !resolved) { + (state) ? this.api.asc_showComments(true) : ((value) ? this.api.asc_showComments(resolved) : this.api.asc_hideComments()); } if (state) { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ee7806778..b2355df1f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -118,6 +118,7 @@ define([ var value = Common.localStorage.getItem("sse-settings-fontrender"); if (value===null) value = window.devicePixelRatio > 1 ? '1' : '3'; + Common.Utils.InternalSettings.set("sse-settings-fontrender", value); // Initialize api var styleNames = ['Normal', 'Neutral', 'Bad', 'Good', 'Input', 'Output', 'Calculation', 'Check Cell', 'Explanatory Text', 'Note', 'Linked Cell', 'Warning Text', @@ -309,10 +310,13 @@ define([ value = Common.localStorage.getItem("sse-settings-func-locale"); if (value===null) { var lang = ((this.editorConfig.lang) ? this.editorConfig.lang : 'en').split("-")[0].toLowerCase(); + Common.Utils.InternalSettings.set("sse-settings-func-locale", lang); if (lang !== 'en') value = SSE.Views.FormulaLang.get(lang); - } else + } else { + Common.Utils.InternalSettings.set("sse-settings-func-locale", value); value = SSE.Views.FormulaLang.get(value); + } if (value) this.api.asc_setLocalization(value); if (this.appOptions.location == 'us' || this.appOptions.location == 'ca') @@ -568,14 +572,16 @@ define([ me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); value = (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram) ? 100 : Common.localStorage.getItem("sse-settings-zoom"); + Common.Utils.InternalSettings.set("sse-settings-zoom", value); var zf = (value!==null) ? parseInt(value)/100 : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom)/100 : 1); this.api.asc_setZoom(zf>0 ? zf : 1); /** coauthoring begin **/ - value = Common.localStorage.getItem("sse-settings-livecomment"); - this.isLiveCommenting = !(value!==null && parseInt(value) == 0); - var resolved = Common.localStorage.getItem("sse-settings-resolvedcomment"); - this.isLiveCommenting ? this.api.asc_showComments(!(resolved!==null && parseInt(resolved) == 0)) : this.api.asc_hideComments(); + this.isLiveCommenting = Common.localStorage.getBool("sse-settings-livecomment", true); + Common.Utils.InternalSettings.set("sse-settings-livecomment", this.isLiveCommenting); + value = Common.localStorage.getBool("sse-settings-resolvedcomment", true); + Common.Utils.InternalSettings.set("sse-settings-resolvedcomment", value); + this.isLiveCommenting ? this.api.asc_showComments(value) : this.api.asc_hideComments(); if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { value = Common.localStorage.getItem("sse-settings-coauthmode"); @@ -586,9 +592,13 @@ define([ this._state.fastCoauth = (value===null || parseInt(value) == 1); } else { this._state.fastCoauth = (!this.appOptions.isEdit && this.appOptions.canComments); - this._state.fastCoauth && this.api.asc_setAutoSaveGap(1); + if (this._state.fastCoauth) { + this.api.asc_setAutoSaveGap(1); + Common.Utils.InternalSettings.set("sse-settings-autosave", 1); + } } this.api.asc_SetFastCollaborative(this._state.fastCoauth); + Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth); /** coauthoring end **/ me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me)); @@ -653,10 +663,11 @@ define([ value = 0; } me.api.asc_setAutoSaveGap(value); + Common.Utils.InternalSettings.set("sse-settings-autosave", value); if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true - value = Common.localStorage.getItem("sse-settings-forcesave"); - me.appOptions.forcesave = (value === null) ? me.appOptions.canForcesave : (parseInt(value) == 1); + me.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", me.appOptions.canForcesave); + Common.Utils.InternalSettings.set("sse-settings-forcesave", me.appOptions.forcesave); me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); } @@ -934,7 +945,9 @@ define([ this.toolbarView = toolbarController.getView('Toolbar'); var value = Common.localStorage.getItem('sse-settings-unit'); - Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric()); + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + Common.Utils.Metric.setCurrentMetric(value); + Common.Utils.InternalSettings.set("sse-settings-unit", value); if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { var options = {}; @@ -1697,7 +1710,9 @@ define([ unitsChanged: function(m) { var value = Common.localStorage.getItem("sse-settings-unit"); - Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric()); + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + Common.Utils.Metric.setCurrentMetric(value); + Common.Utils.InternalSettings.set("sse-settings-unit", value); this.getApplication().getController('RightMenu').updateMetricUnit(); this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); }, @@ -1753,6 +1768,7 @@ define([ if (btn == 'custom') { Common.localStorage.setItem("sse-settings-coauthmode", 0); this.api.asc_SetFastCollaborative(false); + Common.Utils.InternalSettings.set("sse-settings-coauthmode", false); this._state.fastCoauth = false; } this.onEditComplete(); @@ -1778,8 +1794,8 @@ define([ this.toolbarView.synchronizeChanges(); } if (this.appOptions.canForcesave) { - value = Common.localStorage.getItem("sse-settings-forcesave"); - this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1); + this.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", this.appOptions.canForcesave); + Common.Utils.InternalSettings.set("sse-settings-forcesave", this.appOptions.forcesave); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index aa26addaf..400abdccb 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -325,8 +325,8 @@ define([ return; } - var value = Common.localStorage.getItem("sse-settings-coauthmode"); - if (value!==null && parseInt(value) == 0) { + var value = Common.Utils.InternalSettings.get("sse-settings-coauthmode"); + if (!value) { items = []; while (wc--) { if (sindex !== wc) { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 9dbe00ff5..318f29eb6 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -686,52 +686,38 @@ define([ }, updateSettings: function() { - var value = Common.localStorage.getItem("sse-settings-zoom"); + var value = Common.Utils.InternalSettings.get("sse-settings-zoom"); value = (value!==null) ? parseInt(value) : (this.mode.customization && this.mode.customization.zoom ? parseInt(this.mode.customization.zoom) : 100); var item = this.cmbZoom.store.findWhere({value: value}); this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100)); /** coauthoring begin **/ - value = Common.localStorage.getItem("sse-settings-livecomment"); - this.chLiveComment.setValue(!(value!==null && parseInt(value) == 0)); + this.chLiveComment.setValue(Common.Utils.InternalSettings.get("sse-settings-livecomment")); + this.chResolvedComment.setValue(Common.Utils.InternalSettings.get("sse-settings-resolvedcomment")); - value = Common.localStorage.getItem("sse-settings-resolvedcomment"); - this.chResolvedComment.setValue(!(value!==null && parseInt(value) == 0)); - - value = Common.localStorage.getItem("sse-settings-coauthmode"); - if (value===null && Common.localStorage.getItem("sse-settings-autosave")===null && - this.mode.customization && this.mode.customization.autosave===false) - value = 0; // use customization.autosave only when sse-settings-coauthmode and sse-settings-autosave are null - var fast_coauth = (value===null || parseInt(value) == 1) && !(this.mode.isDesktopApp && this.mode.isOffline) && this.mode.canCoAuthoring; - - item = this.cmbCoAuthMode.store.findWhere({value: parseInt(value)}); + var fast_coauth = Common.Utils.InternalSettings.get("sse-settings-coauthmode"); + item = this.cmbCoAuthMode.store.findWhere({value: fast_coauth ? 1 : 0}); this.cmbCoAuthMode.setValue(item ? item.get('value') : 1); this.lblCoAuthMode.text(item ? item.get('descValue') : this.strCoAuthModeDescFast); /** coauthoring end **/ - value = Common.localStorage.getItem("sse-settings-fontrender"); + value = Common.Utils.InternalSettings.get("sse-settings-fontrender"); item = this.cmbFontRender.store.findWhere({value: parseInt(value)}); this.cmbFontRender.setValue(item ? item.get('value') : (window.devicePixelRatio > 1 ? Asc.c_oAscFontRenderingModeType.noHinting : Asc.c_oAscFontRenderingModeType.hintingAndSubpixeling)); - value = Common.localStorage.getItem("sse-settings-unit"); - item = this.cmbUnit.store.findWhere({value: parseInt(value)}); + value = Common.Utils.InternalSettings.get("sse-settings-unit"); + item = this.cmbUnit.store.findWhere({value: value}); this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); this._oldUnits = this.cmbUnit.getValue(); - value = Common.localStorage.getItem("sse-settings-autosave"); - if (value===null && this.mode.customization && this.mode.customization.autosave===false) - value = 0; - this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); + value = Common.Utils.InternalSettings.get("sse-settings-autosave"); + this.chAutosave.setValue(value == 1); if (this.mode.canForcesave) { - value = Common.localStorage.getItem("sse-settings-forcesave"); - value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1); - this.chForcesave.setValue(value); + this.chForcesave.setValue(Common.Utils.InternalSettings.get("sse-settings-forcesave")); } - value = Common.localStorage.getItem("sse-settings-func-locale"); - if (value===null) - value = ((this.mode.lang) ? this.mode.lang : 'en').toLowerCase(); + value = Common.Utils.InternalSettings.get("sse-settings-func-locale"); item = this.cmbFuncLocale.store.findWhere({value: value}); if (!item) item = this.cmbFuncLocale.store.findWhere({value: value.split("-")[0]}); @@ -752,6 +738,7 @@ define([ applySettings: function() { Common.localStorage.setItem("sse-settings-zoom", this.cmbZoom.getValue()); + Common.Utils.InternalSettings.set("sse-settings-zoom", Common.localStorage.getItem("sse-settings-zoom")); /** coauthoring begin **/ Common.localStorage.setItem("sse-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0); Common.localStorage.setItem("sse-settings-resolvedcomment", this.chResolvedComment.isChecked() ? 1 : 0); diff --git a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js index 9707f4923..b16393f11 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js @@ -228,7 +228,7 @@ define([ fillFormulasGroups: function () { if (this.formulasGroups) { - var lang = Common.localStorage.getItem("sse-settings-func-locale"); + var lang = Common.Utils.InternalSettings.get("sse-settings-func-locale"); if (_.isEmpty(lang)) lang = 'en'; var i, groupsListItems = [], length = this.formulasGroups.length; diff --git a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js index 270d43ad9..bce1411dc 100644 --- a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js @@ -303,9 +303,8 @@ define([ }, onRefreshDefNameList: function(name) { - var value = Common.localStorage.getItem("sse-settings-coauthmode"), - me = this; - if (this.isEdit && (value===null || parseInt(value) == 1)) { // fast co-editing + var me = this; + if (this.isEdit && Common.Utils.InternalSettings.get("sse-settings-coauthmode")) { // fast co-editing if (name && name.asc_getIsLock() && name.asc_getName().toLowerCase() == this.props.asc_getName().toLowerCase() && (name.asc_getScope() === null && this.props.asc_getScope() === null || name.asc_getScope().toLowerCase() == this.props.asc_getScope().toLowerCase()) && !this._listRefreshed) { this._listRefreshed = true;