[DE] Refactoring left menu (show/hide)

This commit is contained in:
Julia Radzhabova 2022-06-08 17:36:18 +03:00
parent f8249a4106
commit 83fb5c21a3
2 changed files with 10 additions and 28 deletions

View file

@ -688,7 +688,6 @@ define([
if (this.leftMenu.btnComments.isActive()) { if (this.leftMenu.btnComments.isActive()) {
this.leftMenu.btnComments.toggle(false); this.leftMenu.btnComments.toggle(false);
this.leftMenu.onBtnMenuClick(this.leftMenu.btnComments); this.leftMenu.onBtnMenuClick(this.leftMenu.btnComments);
// focus to sdk // focus to sdk
this.api.asc_enableKeyEvents(true); this.api.asc_enableKeyEvents(true);
} else if (this.leftMenu.btnThumbnails.isActive()) { } else if (this.leftMenu.btnThumbnails.isActive()) {
@ -768,7 +767,6 @@ define([
// if (!this.leftMenu.isOpened()) return true; // if (!this.leftMenu.isOpened()) return true;
var btnSearch = this.getApplication().getController('Viewport').header.btnSearch; var btnSearch = this.getApplication().getController('Viewport').header.btnSearch;
btnSearch.pressed && btnSearch.toggle(false); btnSearch.pressed && btnSearch.toggle(false);
this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false);
if ( this.leftMenu.menuFile.isVisible() ) { if ( this.leftMenu.menuFile.isVisible() ) {
if (Common.UI.HintManager.needCloseFileMenu()) if (Common.UI.HintManager.needCloseFileMenu())
@ -879,11 +877,10 @@ define([
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace'; var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
this.leftMenu.panelSearch.setSearchMode(mode); this.leftMenu.panelSearch.setSearchMode(mode);
} }
this.leftMenu._state.isSearchOpen = show;
}, },
isSearchPanelVisible: function () { isSearchPanelVisible: function () {
return this.leftMenu._state.isSearchOpen; return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible();
}, },
isCommentsVisible: function() { isCommentsVisible: function() {

View file

@ -69,17 +69,6 @@ define([
// Delegated events for creating new items, and clearing completed ones. // Delegated events for creating new items, and clearing completed ones.
events: function() { events: function() {
return { return {
/** coauthoring begin **/
'click #left-btn-comments': _.bind(this.onCoauthOptions, this),
'click #left-btn-chat': _.bind(this.onCoauthOptions, this),
/** coauthoring end **/
'click #left-btn-plugins': _.bind(this.onCoauthOptions, this),
'click #left-btn-navigation': _.bind(this.onCoauthOptions, this),
'click #left-btn-thumbnails': _.bind(this.onCoauthOptions, this),
'click #left-btn-searchbar': _.bind(function () {
this.onCoauthOptions();
this.fireEvent('search:aftershow', this.leftMenu);
}, this),
'click #left-btn-support': function() { 'click #left-btn-support': function() {
var config = this.mode.customization; var config = this.mode.customization;
config && !!config.feedback && !!config.feedback.url ? config && !!config.feedback && !!config.feedback.url ?
@ -105,6 +94,7 @@ define([
enableToggle: true, enableToggle: true,
toggleGroup: 'leftMenuGroup' toggleGroup: 'leftMenuGroup'
}); });
this.btnSearchBar.on('click', this.onBtnMenuClick.bind(this));
this.btnAbout = new Common.UI.Button({ this.btnAbout = new Common.UI.Button({
action: 'about', action: 'about',
@ -114,6 +104,7 @@ define([
disabled: true, disabled: true,
toggleGroup: 'leftMenuGroup' toggleGroup: 'leftMenuGroup'
}); });
this.btnAbout.on('toggle', this.onBtnMenuToggle.bind(this));
this.btnSupport = new Common.UI.Button({ this.btnSupport = new Common.UI.Button({
action: 'support', action: 'support',
@ -130,6 +121,8 @@ define([
disabled: true, disabled: true,
toggleGroup: 'leftMenuGroup' toggleGroup: 'leftMenuGroup'
}); });
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this));
this.btnChat = new Common.UI.Button({ this.btnChat = new Common.UI.Button({
el: $markup.elementById('#left-btn-chat'), el: $markup.elementById('#left-btn-chat'),
@ -138,13 +131,11 @@ define([
disabled: true, disabled: true,
toggleGroup: 'leftMenuGroup' toggleGroup: 'leftMenuGroup'
}); });
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
this.btnComments.hide(); this.btnComments.hide();
this.btnChat.hide(); this.btnChat.hide();
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this));
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
/** coauthoring end **/ /** coauthoring end **/
this.btnPlugins = new Common.UI.Button({ this.btnPlugins = new Common.UI.Button({
@ -166,9 +157,6 @@ define([
}); });
this.btnNavigation.on('click', this.onBtnMenuClick.bind(this)); this.btnNavigation.on('click', this.onBtnMenuClick.bind(this));
this.btnSearchBar.on('click', this.onBtnMenuClick.bind(this));
this.btnAbout.on('toggle', this.onBtnMenuToggle.bind(this));
this.menuFile = new DE.Views.FileMenu(); this.menuFile = new DE.Views.FileMenu();
this.btnAbout.panel = new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor}); this.btnAbout.panel = new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor});
@ -180,7 +168,6 @@ define([
toggleGroup: 'leftMenuGroup' toggleGroup: 'leftMenuGroup'
}); });
this.btnThumbnails.hide(); this.btnThumbnails.hide();
this.btnThumbnails.on('click', this.onBtnMenuClick.bind(this)); this.btnThumbnails.on('click', this.onBtnMenuClick.bind(this));
this.$el.html($markup); this.$el.html($markup);
@ -210,8 +197,7 @@ define([
this.supressEvents = true; this.supressEvents = true;
this.btnAbout.toggle(false); this.btnAbout.toggle(false);
if (btn.options.action == 'search') { if (btn.options.action !== 'search') {
} else {
if (btn.pressed) { if (btn.pressed) {
if (!(this.$el.width() > SCALE_MIN)) { if (!(this.$el.width() > SCALE_MIN)) {
this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART); this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART);
@ -223,6 +209,9 @@ define([
} }
this.supressEvents = false; this.supressEvents = false;
this.onCoauthOptions();
(btn.options.action == 'search') && this.fireEvent('search:aftershow', this.leftMenu);
Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
}, },
@ -388,7 +377,6 @@ define([
!this.btnChat.isDisabled() && !this.btnChat.pressed) { !this.btnChat.isDisabled() && !this.btnChat.pressed) {
this.btnChat.toggle(true); this.btnChat.toggle(true);
this.onBtnMenuClick(this.btnChat); this.onBtnMenuClick(this.btnChat);
this.onCoauthOptions();
this.panelChat.focus(); this.panelChat.focus();
} }
} else } else
@ -397,21 +385,18 @@ define([
!this.btnComments.isDisabled() && !this.btnComments.pressed) { !this.btnComments.isDisabled() && !this.btnComments.pressed) {
this.btnComments.toggle(true); this.btnComments.toggle(true);
this.onBtnMenuClick(this.btnComments); this.onBtnMenuClick(this.btnComments);
this.onCoauthOptions();
} }
} else if (menu == 'navigation') { } else if (menu == 'navigation') {
if (this.btnNavigation.isVisible() && if (this.btnNavigation.isVisible() &&
!this.btnNavigation.isDisabled() && !this.btnNavigation.pressed) { !this.btnNavigation.isDisabled() && !this.btnNavigation.pressed) {
this.btnNavigation.toggle(true); this.btnNavigation.toggle(true);
this.onBtnMenuClick(this.btnNavigation); this.onBtnMenuClick(this.btnNavigation);
this.onCoauthOptions();
} }
} else if (menu == 'advancedsearch') { } else if (menu == 'advancedsearch') {
if (this.btnSearchBar.isVisible() && if (this.btnSearchBar.isVisible() &&
!this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) { !this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) {
this.btnSearchBar.toggle(true); this.btnSearchBar.toggle(true);
this.onBtnMenuClick(this.btnSearchBar); this.onBtnMenuClick(this.btnSearchBar);
this.onCoauthOptions();
this.panelSearch.focus(); this.panelSearch.focus();
!suspendAfter && this.fireEvent('search:aftershow', this); !suspendAfter && this.fireEvent('search:aftershow', this);
} }