From 8705842152618c9498733eb2d3ab00ceff704f49 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 15 Jun 2017 16:33:04 +0300 Subject: [PATCH] [Common] LocalStorage: use default value in getBool function. --- apps/common/main/lib/util/LocalStorage.js | 5 +++-- apps/documenteditor/main/app/controller/LeftMenu.js | 3 +-- apps/documenteditor/main/app/view/FileMenuPanels.js | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/common/main/lib/util/LocalStorage.js b/apps/common/main/lib/util/LocalStorage.js index 1a9507d67..8b3b1daa8 100644 --- a/apps/common/main/lib/util/LocalStorage.js +++ b/apps/common/main/lib/util/LocalStorage.js @@ -94,9 +94,10 @@ define(['gateway'], function () { return _store[name]===undefined ? null : _store[name]; }; - var _getItemAsBool = function (name) { + var _getItemAsBool = function (name, defValue) { var value = _getItem(name); - return (value !== null && parseInt(value) != 0); + defValue = defValue || false; + return (value!==null) ? (parseInt(value) != 0) : defValue; } var _getItemExists = function (name) { diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index ce78fda3c..aec1c0f97 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -321,8 +321,7 @@ define([ value = Common.localStorage.getItem("de-settings-autosave"); this.api.asc_setAutoSaveGap(parseInt(value)); - value = Common.localStorage.getItem("de-settings-spellcheck"); - this.api.asc_setSpellCheck(value===null || parseInt(value) == 1); + this.api.asc_setSpellCheck(Common.localStorage.getBool("de-settings-spellcheck", true)); value = Common.localStorage.getItem("de-settings-showsnaplines"); this.api.put_ShowSnapLines(value===null || parseInt(value) == 1); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 4040f6f39..ef058c37f 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -393,8 +393,7 @@ define([ this.chForcesave.setValue(value); } - value = Common.localStorage.getItem("de-settings-spellcheck"); - this.chSpell.setValue(value===null || parseInt(value) == 1); + this.chSpell.setValue(Common.localStorage.getBool("de-settings-spellcheck", true)); value = Common.localStorage.getItem("de-settings-showsnaplines"); this.chAlignGuides.setValue(value===null || parseInt(value) == 1);