[SSE] Add settings for hiding left/right panels to view tab

This commit is contained in:
Julia Radzhabova 2022-10-20 01:01:36 +03:00
parent ab7da2fbcc
commit 3f1a44c390
7 changed files with 115 additions and 10 deletions

View file

@ -93,6 +93,9 @@ define([
},
'SearchBar': {
'search:show': _.bind(this.onShowHideSearch, this)
},
'ViewTab': {
'leftmenu:hide': _.bind(this.onLeftMenuHide, this)
}
});
Common.NotificationCenter.on('app:comment:add', _.bind(this.onAppAddComment, this));
@ -826,6 +829,7 @@ define([
onPluginOpen: function(panel, type, action) {
if (type == 'onboard') {
if (action == 'open') {
this.tryToShowLeftMenu();
this.leftMenu.close();
this.leftMenu.panelPlugins.show();
this.leftMenu.onBtnMenuClick({pressed: true, options: {action: 'plugins'}});
@ -841,6 +845,7 @@ define([
if (this.mode.canCoAuthoring && this.mode.canChat && !this.mode.isLightVersion) {
if (state) {
Common.UI.Menu.Manager.hideAll();
this.tryToShowLeftMenu();
this.leftMenu.showMenu('chat');
} else {
this.leftMenu.btnChat.toggle(false, true);
@ -904,6 +909,24 @@ define([
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
onLeftMenuHide: function (view, status) {
if (this.leftMenu) {
!status && this.leftMenu.close();
status ? this.leftMenu.show() : this.leftMenu.hide();
Common.localStorage.setBool('sse-hidden-leftmenu', !status);
!view && this.leftMenu.fireEvent('view:hide', [this, !status]);
}
Common.NotificationCenter.trigger('layout:changed', 'main');
Common.NotificationCenter.trigger('edit:complete', this.leftMenu);
},
tryToShowLeftMenu: function() {
if ((!this.mode.canBrandingExt || !this.mode.customization || this.mode.customization.leftMenu !== false) && Common.UI.LayoutManager.isElementVisible('leftMenu'))
this.onLeftMenuHide(null, true);
},
textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document',
textItemEntireCell : 'Entire cell contents',

View file

@ -1412,6 +1412,8 @@ define([
app.getController('Toolbar').setMode(this.appOptions);
app.getController('DocumentHolder').setMode(this.appOptions);
viewport && viewport.applyCommonMode();
if (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram) {
statusbarView.hide();
}

View file

@ -69,6 +69,9 @@ define([
},
'PivotTable': {
'insertpivot': this.onInsertPivot
},
'ViewTab': {
'rightmenu:hide': this.onRightMenuHide.bind(this)
}
});
@ -466,6 +469,17 @@ define([
this._state.wsLock = props.wsLock;
}
this.onSelectionChanged(this.api.asc_getCellInfo());
},
onRightMenuHide: function (view, status) {
if (this.rightmenu) {
!status && this.rightmenu.clearSelection();
status ? this.rightmenu.show() : this.rightmenu.hide();
Common.localStorage.setBool('sse-hidden-rightmenu', !status);
}
Common.NotificationCenter.trigger('layout:changed', 'main');
Common.NotificationCenter.trigger('edit:complete', this.rightmenu);
}
});
});

View file

@ -111,6 +111,11 @@ define([
'view:compact': _.bind(function (toolbar, state) {
this.view.chToolbar.setValue(!state, true);
}, this)
},
'LeftMenu': {
'view:hide': _.bind(function (leftmenu, state) {
this.view.chLeftMenu.setValue(!state, true);
}, this)
}
});
Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this));

View file

@ -179,7 +179,8 @@ define([
this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART);
}
} else if (!this._state.pluginIsRunning){
this.isVisible() && Common.localStorage.setItem('sse-mainmenu-width',this.$el.width());
var width = this.$el.width();
this.isVisible() && (width>SCALE_MIN) && Common.localStorage.setItem('sse-mainmenu-width',width);
this.$el.width(SCALE_MIN);
}
this.onCoauthOptions();

View file

@ -101,6 +101,14 @@ define([
'<span class="btn-slot text" id="slot-chk-statusbar"></span>' +
'</div>' +
'</div>' +
'<div class="group small">' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-leftmenu"></span>' +
'</div>' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-rightmenu"></span>' +
'</div>' +
'</div>' +
'</section>';
function setEvents() {
@ -149,6 +157,12 @@ define([
me.fireEvent('editcomplete', me);
}).on('combo:focusin', _.bind(this.onComboOpen, this, false))
.on('show:after', _.bind(this.onComboOpen, this, true));
me.chLeftMenu.on('change', _.bind(function (checkbox, state) {
me.fireEvent('leftmenu:hide', [me.chLeftMenu, state === 'checked']);
}, me));
me.chRightMenu.on('change', _.bind(function (checkbox, state) {
me.fireEvent('rightmenu:hide', [me.chRightMenu, state === 'checked']);
}, me));
}
return {
@ -307,6 +321,27 @@ define([
dataHintOffset: 'small'
});
this.lockedControls.push(this.chToolbar);
this.chRightMenu = new Common.UI.CheckBox({
lock: [_set.lostConnect],
labelText: this.textRightMenu,
value: !Common.localStorage.getBool("sse-hidden-rightmenu"),
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.lockedControls.push(this.chRightMenu);
this.chLeftMenu = new Common.UI.CheckBox({
lock: [_set.lostConnect],
labelText: this.textLeftMenu,
value: !Common.localStorage.getBool("sse-hidden-leftmenu"),
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.lockedControls.push(this.chLeftMenu);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -334,6 +369,8 @@ define([
this.chHeadings && this.chHeadings.render($host.find('#slot-chk-heading'));
this.chGridlines && this.chGridlines.render($host.find('#slot-chk-gridlines'));
this.chZeros && this.chZeros.render($host.find('#slot-chk-zeros'));
this.chLeftMenu.render($host.find('#slot-chk-leftmenu'));
this.chRightMenu.render($host.find('#slot-chk-rightmenu'));
return this.$el;
},
@ -391,17 +428,31 @@ define([
me.$el.find('.separator-theme').remove();
}
var emptyGroup = [];
if (config.canBrandingExt && config.customization && config.customization.statusBar === false || !Common.UI.LayoutManager.isElementVisible('statusBar')) {
emptyGroup.push(me.chStatusbar.$el.closest('.elset'));
me.chStatusbar.$el.remove();
if (!config.isEdit) {
var slotChkFormula = me.chFormula.$el,
groupFormula = slotChkFormula.closest('.group'),
groupToolbar = me.chToolbar.$el.closest('.group');
groupToolbar.find('.elset')[1].append(slotChkFormula[0]);
groupFormula.remove();
me.$el.find('.separator-formula').remove();
}
}
if (config.canBrandingExt && config.customization && config.customization.leftMenu === false || !Common.UI.LayoutManager.isElementVisible('leftMenu')) {
emptyGroup.push(me.chLeftMenu.$el.closest('.elset'));
me.chLeftMenu.$el.remove();
} else if (emptyGroup.length>0) {
emptyGroup.push(me.chLeftMenu.$el.closest('.elset'));
emptyGroup.shift().append(me.chLeftMenu.$el[0]);
}
if (!config.isEdit || config.canBrandingExt && config.customization && config.customization.rightMenu === false || !Common.UI.LayoutManager.isElementVisible('rightMenu')) {
emptyGroup.push(me.chRightMenu.$el.closest('.elset'));
me.chRightMenu.$el.remove();
} else if (emptyGroup.length>0) {
emptyGroup.push(me.chRightMenu.$el.closest('.elset'));
emptyGroup.shift().append(me.chRightMenu.$el[0]);
}
if (emptyGroup.length>1) { // remove empty group
emptyGroup[emptyGroup.length-1].closest('.group').remove();
}
if (Common.UI.Themes.available()) {
function _fill_themes() {
var btn = this.btnInterfaceTheme;
@ -531,7 +582,9 @@ define([
textAlwaysShowToolbar: 'Always show toolbar',
textInterfaceTheme: 'Interface theme',
textShowFrozenPanesShadow: 'Show frozen panes shadow',
tipInterfaceTheme: 'Interface theme'
tipInterfaceTheme: 'Interface theme',
textLeftMenu: 'Left panel',
textRightMenu: 'Right panel'
}
}()), SSE.Views.ViewTab || {}));
});

View file

@ -162,6 +162,13 @@ define([
rightMenuView = SSE.getController('RightMenu').getView('RightMenu');
me._rightMenu = rightMenuView.render(this.mode);
if ( Common.localStorage.getBool('sse-hidden-rightmenu') )
me._rightMenu.hide();
},
applyCommonMode: function() {
if ( Common.localStorage.getBool('sse-hidden-leftmenu') )
SSE.getController('LeftMenu').getView('LeftMenu').hide();
},
setMode: function(mode, delay) {