[PE] localStorage.getItem -> getBool.

This commit is contained in:
Julia Radzhabova 2017-08-08 14:14:14 +03:00
parent 5a4204b18a
commit 8c1c09e437
5 changed files with 21 additions and 36 deletions

View file

@ -229,22 +229,19 @@ define([
}, },
applySettings: function(menu) { applySettings: function(menu) {
var value = Common.localStorage.getItem("pe-settings-inputmode"); this.api.SetTextBoxInputMode(Common.localStorage.getBool("pe-settings-inputmode"));
this.api.SetTextBoxInputMode(parseInt(value) == 1);
/** coauthoring begin **/ /** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
value = Common.localStorage.getItem("pe-settings-coauthmode"); this.api.asc_SetFastCollaborative(Common.localStorage.getBool("pe-settings-coauthmode", true));
this.api.asc_SetFastCollaborative(value===null || parseInt(value) == 1);
} }
/** coauthoring end **/ /** coauthoring end **/
if (this.mode.isEdit) { 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)); this.api.asc_setAutoSaveGap(parseInt(value));
value = Common.localStorage.getItem("pe-settings-spellcheck"); this.api.asc_setSpellCheck(Common.localStorage.getBool("pe-settings-spellcheck", true));
this.api.asc_setSpellCheck(parseInt(value) == 1);
} }
this.api.put_ShowSnapLines( Common.localStorage.getBool("pe-settings-showsnaplines") ); this.api.put_ShowSnapLines( Common.localStorage.getBool("pe-settings-showsnaplines") );

View file

@ -565,8 +565,7 @@ define([
var zf = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom) : -1); 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)); (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(Common.localStorage.getBool("pe-settings-spellcheck", true));
me.api.asc_setSpellCheck(value===null || parseInt(value) == 1);
function checkWarns() { function checkWarns() {
if (!window['AscDesktopEditor']) { if (!window['AscDesktopEditor']) {
@ -595,7 +594,7 @@ define([
/** coauthoring begin **/ /** coauthoring begin **/
if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) { if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) {
value = Common.localStorage.getItem("pe-settings-coauthmode"); 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) { me.appOptions.customization && me.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when pe-settings-coauthmode and pe-settings-autosave are null 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); me.api.asc_SetFastCollaborative(me._state.fastCoauth);
/** coauthoring end **/ /** 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 application = me.getApplication();
var toolbarController = application.getController('Toolbar'), var toolbarController = application.getController('Toolbar'),
@ -651,8 +650,7 @@ define([
me.api.asc_setAutoSaveGap(value); me.api.asc_setAutoSaveGap(value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
value = Common.localStorage.getItem("pe-settings-forcesave"); me.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", me.appOptions.canForcesave);
me.appOptions.forcesave = (value===null) ? me.appOptions.canForcesave : (parseInt(value)==1);
me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave);
} }
@ -706,7 +704,7 @@ define([
$(document).on('contextmenu', _.bind(me.onContextMenu, me)); $(document).on('contextmenu', _.bind(me.onContextMenu, me));
if (this._state.licenseWarning) { if (this._state.licenseWarning) {
value = Common.localStorage.getItem("de-license-warning"); value = Common.localStorage.getItem("pe-license-warning");
value = (value!==null) ? parseInt(value) : 0; value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime(); var now = (new Date).getTime();
if (now - value > 86400000) { if (now - value > 86400000) {
@ -1500,8 +1498,7 @@ define([
}, },
onTryUndoInFastCollaborative: function() { onTryUndoInFastCollaborative: function() {
var val = window.localStorage.getItem("pe-hide-try-undoredo"); if (!window.localStorage.getBool("pe-hide-try-undoredo"))
if (!(val && parseInt(val) == 1))
Common.UI.info({ Common.UI.info({
width: 500, width: 500,
msg: this.textTryUndoRedo, msg: this.textTryUndoRedo,
@ -1533,15 +1530,13 @@ define([
applySettings: function() { applySettings: function() {
if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) {
var value = Common.localStorage.getItem("pe-settings-coauthmode"), var oldval = this._state.fastCoauth;
oldval = this._state.fastCoauth; this._state.fastCoauth = Common.localStorage.getBool("pe-settings-coauthmode", true);
this._state.fastCoauth = (value===null || parseInt(value) == 1);
if (this._state.fastCoauth && !oldval) if (this._state.fastCoauth && !oldval)
this.synchronizeChanges(); this.synchronizeChanges();
} }
if (this.appOptions.canForcesave) { if (this.appOptions.canForcesave) {
value = Common.localStorage.getItem("pe-settings-forcesave"); this.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", this.appOptions.canForcesave);
this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1);
this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave);
} }
}, },

View file

@ -176,9 +176,7 @@ define([
}, },
createDelayedElements: function() { createDelayedElements: function() {
var value = Common.localStorage.getItem("pe-settings-spellcheck"); this.statusbar.btnSetSpelling.toggle(Common.localStorage.getBool("pe-settings-spellcheck", true), true);
this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true);
this.statusbar.$el.css('z-index', ''); this.statusbar.$el.css('z-index', '');
}, },
@ -215,8 +213,7 @@ define([
}, },
applySettings: function(menu) { applySettings: function(menu) {
var value = Common.localStorage.getItem("pe-settings-spellcheck"); this.statusbar.btnSetSpelling.toggle(Common.localStorage.getBool("pe-settings-spellcheck", true), true);
this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true);
}, },
zoomText : 'Zoom {0}%' zoomText : 'Zoom {0}%'

View file

@ -1551,7 +1551,7 @@ define([
var headerView = this.getApplication().getController('Statusbar').getView('Statusbar'); var headerView = this.getApplication().getController('Statusbar').getView('Statusbar');
headerView && headerView.setVisible(!checked); 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('layout:changed', 'status');
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);

View file

@ -285,19 +285,18 @@ define([
}, },
updateSettings: function() { updateSettings: function() {
var value = Common.localStorage.getItem("pe-settings-spellcheck"); this.chSpell.setValue(Common.localStorage.getBool("pe-settings-spellcheck", true));
this.chSpell.setValue(value===null || parseInt(value) == 1);
this.chInputMode.setValue(Common.localStorage.getBool("pe-settings-inputmode")); 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); 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}); var item = this.cmbZoom.store.findWhere({value: value});
this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100)); this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100));
/** coauthoring begin **/ /** coauthoring begin **/
value = Common.localStorage.getItem("pe-settings-coauthmode"); 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) this.mode.customization && this.mode.customization.autosave===false)
value = 0; // use customization.autosave only when pe-settings-coauthmode and pe-settings-autosave are null 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; 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)); this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1));
if (this.mode.canForcesave) { if (this.mode.canForcesave) {
value = Common.localStorage.getItem("pe-settings-forcesave"); this.chForcesave.setValue(Common.localStorage.getBool("pe-settings-forcesave", this.mode.canForcesave));
value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1);
this.chForcesave.setValue(value);
} }
value = Common.localStorage.getItem("pe-settings-showsnaplines"); this.chAlignGuides.setValue(Common.localStorage.getBool("pe-settings-showsnaplines", true));
this.chAlignGuides.setValue(value===null || parseInt(value) == 1);
}, },
applySettings: function() { applySettings: function() {