[DE] Fix Bug 35406.

This commit is contained in:
Julia Radzhabova 2017-10-03 14:22:33 +03:00
parent 837e507381
commit b4029143fa
5 changed files with 93 additions and 45 deletions

View file

@ -499,6 +499,7 @@ define([
Common.localStorage.setItem("de-settings-spellcheck", state ? 1 : 0);
this.api.asc_setSpellCheck(state);
Common.Utils.InternalSettings.set("de-settings-spellcheck", state);
},
onReviewViewClick: function(menu, item, e) {

View file

@ -701,7 +701,7 @@ Common.Utils.createXhr = function () {
}
return xmlhttp;
}
};
Common.Utils.getConfigJson = function (url) {
if ( url ) {
@ -717,7 +717,7 @@ Common.Utils.getConfigJson = function (url) {
}
return null;
}
};
Common.Utils.asyncCall = function (callback, scope, args) {
(new Promise(function (resolve, reject) {
@ -725,7 +725,7 @@ Common.Utils.asyncCall = function (callback, scope, args) {
})).then(function () {
callback.call(scope, args);
});
}
};
// Extend javascript String type
String.prototype.strongMatch = function(regExp){
@ -735,4 +735,20 @@ String.prototype.strongMatch = function(regExp){
}
return false;
};
};
Common.Utils.InternalSettings = new(function() {
var settings = {};
var _get = function(name) {
return settings[name];
},
_set = function(name, value) {
settings[name] = value;
};
return {
get: _get,
set: _set
}
});

View file

@ -301,11 +301,15 @@ define([
applySettings: function(menu) {
var value;
this.api.SetTextBoxInputMode(Common.localStorage.getBool("de-settings-inputmode"));
value = Common.localStorage.getBool("de-settings-inputmode");
Common.Utils.InternalSettings.set("de-settings-inputmode", value);
this.api.SetTextBoxInputMode(value);
/** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
var fast_coauth = Common.localStorage.getBool("de-settings-coauthmode", true);
Common.Utils.InternalSettings.set("de-settings-coauthmode", fast_coauth);
this.api.asc_SetFastCollaborative(fast_coauth);
value = Common.localStorage.getItem((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
@ -315,13 +319,21 @@ define([
case 'last': value = Asc.c_oAscCollaborativeMarksShowType.LastChanges; break;
default: value = (fast_coauth) ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges;
}
Common.Utils.InternalSettings.set((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value);
this.api.SetCollaborativeMarksShowType(value);
}
(Common.localStorage.getBool("de-settings-livecomment", true)) ? this.api.asc_showComments(Common.localStorage.getBool("de-settings-resolvedcomment", true)) : this.api.asc_hideComments();
value = Common.localStorage.getBool("de-settings-livecomment", true);
Common.Utils.InternalSettings.set("de-settings-livecomment", value);
var resolved = Common.localStorage.getBool("de-settings-resolvedcomment", true);
Common.Utils.InternalSettings.set("de-settings-resolvedcomment", resolved);
if (this.mode.canComments && this.leftMenu.panelComments.isVisible())
value = resolved = true;
(value) ? this.api.asc_showComments(resolved) : this.api.asc_hideComments();
/** coauthoring end **/
value = Common.localStorage.getItem("de-settings-fontrender");
Common.Utils.InternalSettings.set("de-settings-fontrender", value);
switch (value) {
case '1': this.api.SetFontRenderingMode(1); break;
case '2': this.api.SetFontRenderingMode(2); break;
@ -329,13 +341,18 @@ define([
}
if (this.mode.isEdit) {
value = Common.localStorage.getItem("de-settings-autosave");
this.api.asc_setAutoSaveGap(parseInt(value));
value = parseInt(Common.localStorage.getItem("de-settings-autosave"));
Common.Utils.InternalSettings.set("de-settings-autosave", value);
this.api.asc_setAutoSaveGap(value);
this.api.asc_setSpellCheck(Common.localStorage.getBool("de-settings-spellcheck", true));
value = Common.localStorage.getBool("de-settings-spellcheck", true);
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
this.api.asc_setSpellCheck(value);
}
this.api.put_ShowSnapLines(Common.localStorage.getBool("de-settings-showsnaplines", true));
value = Common.localStorage.getBool("de-settings-showsnaplines", true);
Common.Utils.InternalSettings.set("de-settings-showsnaplines", value);
this.api.put_ShowSnapLines(value);
menu.hide();
},
@ -526,8 +543,9 @@ define([
},
commentsShowHide: function(mode) {
var value = Common.localStorage.getBool("de-settings-livecomment", true),
resolved = Common.localStorage.getBool("de-settings-resolvedcomment", true);
var value = Common.Utils.InternalSettings.get("de-settings-livecomment"),
resolved = Common.Utils.InternalSettings.get("de-settings-resolvedcomment");
if (!value || !resolved) {
(mode === 'show') ? this.api.asc_showComments(true) : ((value) ? this.api.asc_showComments(resolved) : this.api.asc_hideComments());
}

View file

@ -119,6 +119,7 @@ define([
var value = Common.localStorage.getItem("de-settings-fontrender");
if (value === null)
window.devicePixelRatio > 1 ? value = '1' : '0';
Common.Utils.InternalSettings.set("de-settings-fontrender", value);
// Initialize api
@ -755,10 +756,14 @@ define([
/** coauthoring begin **/
this.isLiveCommenting = Common.localStorage.getBool("de-settings-livecomment", true);
this.isLiveCommenting ? this.api.asc_showComments(Common.localStorage.getBool("de-settings-resolvedcomment", true)) : this.api.asc_hideComments();
Common.Utils.InternalSettings.set("de-settings-livecomment", this.isLiveCommenting);
value = Common.localStorage.getBool("de-settings-resolvedcomment", true);
Common.Utils.InternalSettings.set("de-settings-resolvedcomment", value);
this.isLiveCommenting ? this.api.asc_showComments(value) : this.api.asc_hideComments();
/** coauthoring end **/
value = Common.localStorage.getItem("de-settings-zoom");
Common.Utils.InternalSettings.set("de-settings-zoom", value);
var zf = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom) : 100);
(zf == -1) ? this.api.zoomFitToPage() : ((zf == -2) ? this.api.zoomFitToWidth() : this.api.zoom(zf>0 ? zf : 100));
@ -768,9 +773,13 @@ define([
value = Common.localStorage.getItem("de-show-tableline");
me.api.put_ShowTableEmptyLine((value!==null) ? eval(value) : true);
me.api.asc_setSpellCheck(Common.localStorage.getBool("de-settings-spellcheck", true));
value = Common.localStorage.getBool("de-settings-spellcheck", true);
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
me.api.asc_setSpellCheck(value);
Common.localStorage.setBool("de-settings-showsnaplines", me.api.get_ShowSnapLines());
value = me.api.get_ShowSnapLines();
Common.Utils.InternalSettings.set("de-settings-showsnaplines", value);
Common.localStorage.setBool("de-settings-showsnaplines", value);
function checkWarns() {
if (!window['AscDesktopEditor']) {
@ -794,7 +803,9 @@ define([
appHeader.setDocumentCaption(me.api.asc_getDocumentName());
me.updateWindowTitle(true);
me.api.SetTextBoxInputMode(Common.localStorage.getBool("de-settings-inputmode"));
value = Common.localStorage.getBool("de-settings-inputmode");
Common.Utils.InternalSettings.set("de-settings-inputmode", value);
me.api.SetTextBoxInputMode(value);
/** coauthoring begin **/
if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) {
@ -807,21 +818,23 @@ define([
me.api.asc_SetFastCollaborative(me._state.fastCoauth);
value = Common.localStorage.getItem((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
if (value !== null)
me.api.SetCollaborativeMarksShowType(value == 'all' ? Asc.c_oAscCollaborativeMarksShowType.All :
value == 'none' ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges);
else
me.api.SetCollaborativeMarksShowType(me._state.fastCoauth ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges);
if (value == null) value = me._state.fastCoauth ? 'none' : 'last';
me.api.SetCollaborativeMarksShowType(value == 'all' ? Asc.c_oAscCollaborativeMarksShowType.All :
(value == 'none' ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges));
Common.Utils.InternalSettings.set((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value);
} else if (!me.appOptions.isEdit && me.appOptions.canComments) {
me._state.fastCoauth = true;
me.api.asc_SetFastCollaborative(me._state.fastCoauth);
me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None);
me.api.asc_setAutoSaveGap(1);
Common.Utils.InternalSettings.set("de-settings-autosave", 1);
} else {
me._state.fastCoauth = false;
me.api.asc_SetFastCollaborative(me._state.fastCoauth);
me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None);
}
Common.Utils.InternalSettings.set("de-settings-coauthmode", me._state.fastCoauth);
/** coauthoring end **/
var application = me.getApplication();
@ -864,11 +877,12 @@ define([
if (value===null && me.appOptions.customization && me.appOptions.customization.autosave===false)
value = 0;
value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0);
Common.Utils.InternalSettings.set("de-settings-autosave", value);
me.api.asc_setAutoSaveGap(value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
me.appOptions.forcesave = Common.localStorage.getBool("de-settings-forcesave", me.appOptions.canForcesave);
Common.Utils.InternalSettings.set("de-settings-forcesave", me.appOptions.forcesave);
me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave);
}
@ -1123,6 +1137,7 @@ define([
var value = Common.localStorage.getItem('de-settings-unit');
value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric();
Common.Utils.Metric.setCurrentMetric(value);
Common.Utils.InternalSettings.set("de-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));
me.api.asc_SetViewRulers(!Common.localStorage.getBool('de-hidden-rulers'));
@ -1736,6 +1751,7 @@ define([
var value = Common.localStorage.getItem("de-settings-unit");
value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric();
Common.Utils.Metric.setCurrentMetric(value);
Common.Utils.InternalSettings.set("de-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();
this.getApplication().getController('Toolbar').getView().updateMetricUnit();
@ -1797,6 +1813,7 @@ define([
if (dontshow) window.localStorage.setItem("de-hide-try-undoredo", 1);
if (btn == 'custom') {
Common.localStorage.setItem("de-settings-coauthmode", 0);
Common.Utils.InternalSettings.set("de-settings-coauthmode", false);
this.api.asc_SetFastCollaborative(false);
this._state.fastCoauth = false;
Common.localStorage.setItem("de-settings-showchanges-strict", 'last');
@ -1825,6 +1842,7 @@ define([
}
if (this.appOptions.canForcesave) {
this.appOptions.forcesave = Common.localStorage.getBool("de-settings-forcesave", this.appOptions.canForcesave);
Common.Utils.InternalSettings.set("de-settings-forcesave", this.appOptions.forcesave);
this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave);
}
},

View file

@ -342,58 +342,53 @@ define([
},
updateSettings: function() {
this.chInputMode.setValue(Common.localStorage.getBool("de-settings-inputmode"));
this.chInputMode.setValue(Common.Utils.InternalSettings.get("de-settings-inputmode"));
var value = Common.localStorage.getItem("de-settings-zoom");
var value = Common.Utils.InternalSettings.get("de-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 **/
this.chLiveComment.setValue(Common.localStorage.getBool("de-settings-livecomment", true));
this.chResolvedComment.setValue(Common.localStorage.getBool("de-settings-resolvedcomment", true));
this.chLiveComment.setValue(Common.Utils.InternalSettings.get("de-settings-livecomment"));
this.chResolvedComment.setValue(Common.Utils.InternalSettings.get("de-settings-resolvedcomment"));
value = Common.localStorage.getItem("de-settings-coauthmode");
if (value===null && !Common.localStorage.itemExists("de-settings-autosave") &&
this.mode.customization && this.mode.customization.autosave===false)
value = 0; // use customization.autosave only when de-settings-coauthmode and de-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("de-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);
this.fillShowChanges(fast_coauth);
value = Common.localStorage.getItem((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
value = Common.Utils.InternalSettings.get((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
item = this.cmbShowChanges.store.findWhere({value: value});
this.cmbShowChanges.setValue(item ? item.get('value') : (fast_coauth) ? 'none' : 'last');
/** coauthoring end **/
value = Common.localStorage.getItem("de-settings-fontrender");
item = this.cmbFontRender.store.findWhere({value: parseInt(value)});
value = Common.Utils.InternalSettings.get("de-settings-fontrender");
item = this.cmbFontRender.store.findWhere({value: value});
this.cmbFontRender.setValue(item ? item.get('value') : (window.devicePixelRatio > 1 ? 1 : 0));
value = Common.localStorage.getItem("de-settings-unit");
item = this.cmbUnit.store.findWhere({value: parseInt(value)});
value = Common.Utils.InternalSettings.get("de-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("de-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("de-settings-autosave");
this.chAutosave.setValue(value == 1);
if (this.mode.canForcesave)
this.chForcesave.setValue(Common.localStorage.getBool("de-settings-forcesave", this.mode.canForcesave));
this.chForcesave.setValue(Common.Utils.InternalSettings.get("de-settings-forcesave"));
this.chSpell.setValue(Common.localStorage.getBool("de-settings-spellcheck", true));
this.chAlignGuides.setValue(Common.localStorage.getBool("de-settings-showsnaplines", true));
this.chSpell.setValue(Common.Utils.InternalSettings.get("de-settings-spellcheck"));
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("de-settings-showsnaplines"));
},
applySettings: function() {
Common.localStorage.setItem("de-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-zoom", this.cmbZoom.getValue());
Common.Utils.InternalSettings.set("de-settings-zoom", Common.localStorage.getItem("de-settings-zoom"));
/** coauthoring begin **/
Common.localStorage.setItem("de-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-resolvedcomment", this.chResolvedComment.isChecked() ? 1 : 0);