diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 00c9fc3a1..589bfc2fc 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -229,22 +229,19 @@ define([ }, applySettings: function(menu) { - var value = Common.localStorage.getItem("pe-settings-inputmode"); - this.api.SetTextBoxInputMode(parseInt(value) == 1); + this.api.SetTextBoxInputMode(Common.localStorage.getBool("pe-settings-inputmode")); /** coauthoring begin **/ if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { - value = Common.localStorage.getItem("pe-settings-coauthmode"); - this.api.asc_SetFastCollaborative(value===null || parseInt(value) == 1); + this.api.asc_SetFastCollaborative(Common.localStorage.getBool("pe-settings-coauthmode", true)); } /** coauthoring end **/ if (this.mode.isEdit) { - value = Common.localStorage.getItem("pe-settings-autosave"); + var value = Common.localStorage.getItem("pe-settings-autosave"); this.api.asc_setAutoSaveGap(parseInt(value)); - value = Common.localStorage.getItem("pe-settings-spellcheck"); - this.api.asc_setSpellCheck(parseInt(value) == 1); + this.api.asc_setSpellCheck(Common.localStorage.getBool("pe-settings-spellcheck", true)); } this.api.put_ShowSnapLines( Common.localStorage.getBool("pe-settings-showsnaplines") ); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 206abb901..cd421a19f 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -565,8 +565,7 @@ define([ 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)); - value = Common.localStorage.getItem("pe-settings-spellcheck"); - me.api.asc_setSpellCheck(value===null || parseInt(value) == 1); + me.api.asc_setSpellCheck(Common.localStorage.getBool("pe-settings-spellcheck", true)); function checkWarns() { if (!window['AscDesktopEditor']) { @@ -595,7 +594,7 @@ define([ /** coauthoring begin **/ if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) { value = Common.localStorage.getItem("pe-settings-coauthmode"); - if (value===null && Common.localStorage.getItem("pe-settings-autosave")===null && + if (value===null && !Common.localStorage.itemExists("pe-settings-autosave") && me.appOptions.customization && me.appOptions.customization.autosave===false) { value = 0; // use customization.autosave only when pe-settings-coauthmode and pe-settings-autosave are null } @@ -607,7 +606,7 @@ define([ me.api.asc_SetFastCollaborative(me._state.fastCoauth); /** coauthoring end **/ - Common.localStorage.setItem("pe-settings-showsnaplines", me.api.get_ShowSnapLines() ? 1 : 0); + Common.localStorage.setBool("pe-settings-showsnaplines", me.api.get_ShowSnapLines()); var application = me.getApplication(); var toolbarController = application.getController('Toolbar'), @@ -651,8 +650,7 @@ define([ me.api.asc_setAutoSaveGap(value); if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true - value = Common.localStorage.getItem("pe-settings-forcesave"); - me.appOptions.forcesave = (value===null) ? me.appOptions.canForcesave : (parseInt(value)==1); + me.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", me.appOptions.canForcesave); me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); } @@ -706,7 +704,7 @@ define([ $(document).on('contextmenu', _.bind(me.onContextMenu, me)); if (this._state.licenseWarning) { - value = Common.localStorage.getItem("de-license-warning"); + value = Common.localStorage.getItem("pe-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { @@ -1500,8 +1498,7 @@ define([ }, onTryUndoInFastCollaborative: function() { - var val = window.localStorage.getItem("pe-hide-try-undoredo"); - if (!(val && parseInt(val) == 1)) + if (!window.localStorage.getBool("pe-hide-try-undoredo")) Common.UI.info({ width: 500, msg: this.textTryUndoRedo, @@ -1533,15 +1530,13 @@ define([ applySettings: function() { if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { - var value = Common.localStorage.getItem("pe-settings-coauthmode"), - oldval = this._state.fastCoauth; - this._state.fastCoauth = (value===null || parseInt(value) == 1); + var oldval = this._state.fastCoauth; + this._state.fastCoauth = Common.localStorage.getBool("pe-settings-coauthmode", true); if (this._state.fastCoauth && !oldval) this.synchronizeChanges(); } if (this.appOptions.canForcesave) { - value = Common.localStorage.getItem("pe-settings-forcesave"); - this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1); + this.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", this.appOptions.canForcesave); 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 65d8f2816..1a7146282 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -176,9 +176,7 @@ define([ }, createDelayedElements: function() { - var value = Common.localStorage.getItem("pe-settings-spellcheck"); - this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true); - + this.statusbar.btnSetSpelling.toggle(Common.localStorage.getBool("pe-settings-spellcheck", true), true); this.statusbar.$el.css('z-index', ''); }, @@ -215,8 +213,7 @@ define([ }, applySettings: function(menu) { - var value = Common.localStorage.getItem("pe-settings-spellcheck"); - this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true); + this.statusbar.btnSetSpelling.toggle(Common.localStorage.getBool("pe-settings-spellcheck", true), true); }, zoomText : 'Zoom {0}%' diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 150bb7d96..7b20a65b3 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -1551,7 +1551,7 @@ define([ var headerView = this.getApplication().getController('Statusbar').getView('Statusbar'); headerView && headerView.setVisible(!checked); - Common.localStorage.setItem('pe-hidden-status', checked ? 1 : 0); + Common.localStorage.setBool('pe-hidden-status', checked); Common.NotificationCenter.trigger('layout:changed', 'status'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 08ca0161c..75547a46d 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -285,19 +285,18 @@ define([ }, updateSettings: function() { - var value = Common.localStorage.getItem("pe-settings-spellcheck"); - this.chSpell.setValue(value===null || parseInt(value) == 1); + this.chSpell.setValue(Common.localStorage.getBool("pe-settings-spellcheck", true)); this.chInputMode.setValue(Common.localStorage.getBool("pe-settings-inputmode")); - value = Common.localStorage.getItem("pe-settings-zoom"); + var value = Common.localStorage.getItem("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.getItem("pe-settings-autosave")===null && + 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; @@ -318,13 +317,10 @@ define([ this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); if (this.mode.canForcesave) { - value = Common.localStorage.getItem("pe-settings-forcesave"); - value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1); - this.chForcesave.setValue(value); + this.chForcesave.setValue(Common.localStorage.getBool("pe-settings-forcesave", this.mode.canForcesave)); } - value = Common.localStorage.getItem("pe-settings-showsnaplines"); - this.chAlignGuides.setValue(value===null || parseInt(value) == 1); + this.chAlignGuides.setValue(Common.localStorage.getBool("pe-settings-showsnaplines", true)); }, applySettings: function() {