Set init value for left/right panels

This commit is contained in:
Julia Radzhabova 2022-10-24 10:28:30 +03:00
parent 3309cbf2d2
commit 72328c0955
7 changed files with 66 additions and 16 deletions

View file

@ -175,9 +175,12 @@
},
leftMenu: {
navigation: false/true,
spellcheck: false/true // spellcheck button in sse
spellcheck: false/true // spellcheck button in sse,
mode: false/true // init value for left panel, true - is visible, false - is hidden, used for option "Left panel" on the View Tab
} / false / true, // use instead of customization.leftMenu
rightMenu: false/true, // use instead of customization.rightMenu
rightMenu: {
mode: false/true // init value for right panel, true - is visible, false - is hidden, used for option "Right panel" on the View Tab
} / false/true, // use instead of customization.rightMenu
statusBar: {
textLang: false/true // text language button in de/pe
docLang: false/true // document language button in de/pe

View file

@ -47,14 +47,16 @@ if (Common.UI === undefined) {
}
Common.UI.LayoutManager = new(function() {
var _config;
var _init = function(config) {
var _config,
_licensed;
var _init = function(config, licensed) {
_config = config;
_licensed = licensed;
};
var _applyCustomization = function(config, el, prefix) {
!config && (config = _config);
if (!config) return;
if (!_licensed || !config) return;
for (var name in config) {
if(config.hasOwnProperty(name)) {
@ -71,7 +73,7 @@ Common.UI.LayoutManager = new(function() {
var _isElementVisible = function(value, config, prefix) {
!config && (config = _config);
if (!config) return true;
if (!_licensed || !config) return true;
var res = true;
for (var name in config) {
@ -89,10 +91,31 @@ Common.UI.LayoutManager = new(function() {
return res;
};
var _getInitValue = function(name) {
if (_config) {
var arr = name.split('-'),
i = 0,
obj = _config;
for (i=0; i<arr.length; i++) {
if (typeof obj[arr[i]] === 'object' && obj[arr[i]]) {
obj = obj[arr[i]];
} else
break;
}
if (i===arr.length) {
if (typeof obj === 'object' && obj)
return obj.mode;
else
return obj;
}
}
};
return {
init: _init,
applyCustomization: _applyCustomization,
isElementVisible: _isElementVisible
isElementVisible: _isElementVisible,
getInitValue: _getInitValue
}
})();

View file

@ -1570,7 +1570,7 @@ define([
this.appOptions.canRename && appHeader.setCanRename(true);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
if (this.appOptions.canComments)

View file

@ -254,7 +254,6 @@ define([
this.chRightMenu = new Common.UI.CheckBox({
lock: [_set.lostConnect, _set.disableOnStart],
labelText: this.textRightMenu,
value: !Common.localStorage.getBool("de-hidden-rightmenu"),
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -264,7 +263,6 @@ define([
this.chLeftMenu = new Common.UI.CheckBox({
lock: [_set.lostConnect, _set.disableOnStart],
labelText: this.textLeftMenu,
value: !Common.localStorage.getBool("de-hidden-leftmenu"),
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -316,6 +314,22 @@ define([
this.btnFitToWidth.updateHint(this.tipFitToWidth);
this.btnInterfaceTheme.updateHint(this.tipInterfaceTheme);
this.btnDarkDocument.updateHint(this.tipDarkDocument);
var value = Common.localStorage.getItem("de-hidden-leftmenu");
if (value===null) {
value = Common.UI.LayoutManager.getInitValue('leftMenu');
value = (value!==undefined) ? !value : false;
} else
value = (parseInt(value) == 1);
this.chLeftMenu.setValue(!value);
value = Common.localStorage.getItem("de-hidden-rightmenu");
if (value===null) {
value = Common.UI.LayoutManager.getInitValue('rightMenu');
value = (value!==undefined) ? !value : false;
} else
value = (parseInt(value) == 1);
this.chRightMenu.setValue(!value);
},
show: function () {

View file

@ -141,16 +141,26 @@ define([
rightMenuView = DE.getController('RightMenu').getView('RightMenu');
me._rightMenu = rightMenuView.render(this.mode);
if ( Common.localStorage.getBool('de-hidden-rightmenu') )
me._rightMenu.hide();
var value = Common.localStorage.getItem("de-hidden-rightmenu");
if (value===null) {
value = Common.UI.LayoutManager.getInitValue('rightMenu');
value = (value!==undefined) ? !value : false;
} else
value = (parseInt(value) == 1);
value && me._rightMenu.hide();
},
applyCommonMode: function() {
if ( Common.localStorage.getBool('de-hidden-status') )
DE.getController('Statusbar').getView('Statusbar').setVisible(false);
if ( Common.localStorage.getBool('de-hidden-leftmenu') )
DE.getController('LeftMenu').getView('LeftMenu').hide();
var value = Common.localStorage.getItem("de-hidden-leftmenu");
if (value===null) {
value = Common.UI.LayoutManager.getInitValue('leftMenu');
value = (value!==undefined) ? !value : false;
} else
value = (parseInt(value) == 1);
value && DE.getController('LeftMenu').getView('LeftMenu').hide();
},
setMode: function(mode) {

View file

@ -1227,7 +1227,7 @@ define([
this.appOptions.canRename && appHeader.setCanRename(true);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
// change = true by default in editor

View file

@ -1320,7 +1320,7 @@ define([
if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) {
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
}