From 83fb5c21a30dba2ce968dc707ecf281bff3f00c4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Jun 2022 17:36:18 +0300 Subject: [PATCH 1/6] [DE] Refactoring left menu (show/hide) --- .../main/app/controller/LeftMenu.js | 5 +-- apps/documenteditor/main/app/view/LeftMenu.js | 33 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 7fe92b685..157c97cd6 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -688,7 +688,6 @@ define([ if (this.leftMenu.btnComments.isActive()) { this.leftMenu.btnComments.toggle(false); this.leftMenu.onBtnMenuClick(this.leftMenu.btnComments); - // focus to sdk this.api.asc_enableKeyEvents(true); } else if (this.leftMenu.btnThumbnails.isActive()) { @@ -768,7 +767,6 @@ define([ // if (!this.leftMenu.isOpened()) return true; var btnSearch = this.getApplication().getController('Viewport').header.btnSearch; btnSearch.pressed && btnSearch.toggle(false); - this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false); if ( this.leftMenu.menuFile.isVisible() ) { if (Common.UI.HintManager.needCloseFileMenu()) @@ -879,11 +877,10 @@ define([ var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace'; this.leftMenu.panelSearch.setSearchMode(mode); } - this.leftMenu._state.isSearchOpen = show; }, isSearchPanelVisible: function () { - return this.leftMenu._state.isSearchOpen; + return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible(); }, isCommentsVisible: function() { diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index 9a36dff49..37c94ac6a 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -69,17 +69,6 @@ define([ // Delegated events for creating new items, and clearing completed ones. events: function() { 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() { var config = this.mode.customization; config && !!config.feedback && !!config.feedback.url ? @@ -105,6 +94,7 @@ define([ enableToggle: true, toggleGroup: 'leftMenuGroup' }); + this.btnSearchBar.on('click', this.onBtnMenuClick.bind(this)); this.btnAbout = new Common.UI.Button({ action: 'about', @@ -114,6 +104,7 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnAbout.on('toggle', this.onBtnMenuToggle.bind(this)); this.btnSupport = new Common.UI.Button({ action: 'support', @@ -130,6 +121,8 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnComments.on('click', this.onBtnMenuClick.bind(this)); + this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this)); this.btnChat = new Common.UI.Button({ el: $markup.elementById('#left-btn-chat'), @@ -138,13 +131,11 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnChat.on('click', this.onBtnMenuClick.bind(this)); this.btnComments.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 **/ this.btnPlugins = new Common.UI.Button({ @@ -166,9 +157,6 @@ define([ }); 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.btnAbout.panel = new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor}); @@ -180,7 +168,6 @@ define([ toggleGroup: 'leftMenuGroup' }); this.btnThumbnails.hide(); - this.btnThumbnails.on('click', this.onBtnMenuClick.bind(this)); this.$el.html($markup); @@ -210,8 +197,7 @@ define([ this.supressEvents = true; this.btnAbout.toggle(false); - if (btn.options.action == 'search') { - } else { + if (btn.options.action !== 'search') { if (btn.pressed) { if (!(this.$el.width() > SCALE_MIN)) { this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART); @@ -223,6 +209,9 @@ define([ } this.supressEvents = false; + + this.onCoauthOptions(); + (btn.options.action == 'search') && this.fireEvent('search:aftershow', this.leftMenu); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, @@ -388,7 +377,6 @@ define([ !this.btnChat.isDisabled() && !this.btnChat.pressed) { this.btnChat.toggle(true); this.onBtnMenuClick(this.btnChat); - this.onCoauthOptions(); this.panelChat.focus(); } } else @@ -397,21 +385,18 @@ define([ !this.btnComments.isDisabled() && !this.btnComments.pressed) { this.btnComments.toggle(true); this.onBtnMenuClick(this.btnComments); - this.onCoauthOptions(); } } else if (menu == 'navigation') { if (this.btnNavigation.isVisible() && !this.btnNavigation.isDisabled() && !this.btnNavigation.pressed) { this.btnNavigation.toggle(true); this.onBtnMenuClick(this.btnNavigation); - this.onCoauthOptions(); } } else if (menu == 'advancedsearch') { if (this.btnSearchBar.isVisible() && !this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) { this.btnSearchBar.toggle(true); this.onBtnMenuClick(this.btnSearchBar); - this.onCoauthOptions(); this.panelSearch.focus(); !suspendAfter && this.fireEvent('search:aftershow', this); } From ad77c488416be27fdb9442f0cc2e559b21f97ccf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Jun 2022 20:59:14 +0300 Subject: [PATCH 2/6] [DE][PE] Refactoring left menu (show/hide) --- apps/documenteditor/main/app/view/LeftMenu.js | 16 +++++----- .../main/app/controller/LeftMenu.js | 4 +-- .../main/app/view/LeftMenu.js | 31 +++++-------------- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index 37c94ac6a..8b1852cf1 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -197,21 +197,19 @@ define([ this.supressEvents = true; this.btnAbout.toggle(false); - if (btn.options.action !== 'search') { - if (btn.pressed) { - if (!(this.$el.width() > SCALE_MIN)) { - this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART); - } - } else if (!this._state.pluginIsRunning) { - Common.localStorage.setItem('de-mainmenu-width',this.$el.width()); - this.$el.width(SCALE_MIN); + if (btn.pressed) { + if (!(this.$el.width() > SCALE_MIN)) { + this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART); } + } else if (!this._state.pluginIsRunning) { + Common.localStorage.setItem('de-mainmenu-width',this.$el.width()); + this.$el.width(SCALE_MIN); } this.supressEvents = false; this.onCoauthOptions(); - (btn.options.action == 'search') && this.fireEvent('search:aftershow', this.leftMenu); + (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index f824d2197..6c679b346 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -614,7 +614,6 @@ define([ // if (!this.leftMenu.isOpened()) return true; var btnSearch = this.getApplication().getController('Viewport').header.btnSearch; btnSearch.pressed && btnSearch.toggle(false); - this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false); // TODO: if ( this.leftMenu.menuFile.isVisible() ) { @@ -724,11 +723,10 @@ define([ var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace'; this.leftMenu.panelSearch.setSearchMode(mode); } - this.leftMenu._state.isSearchOpen = show; }, isSearchPanelVisible: function () { - return this.leftMenu._state.isSearchOpen; + return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible(); }, showHistory: function() { diff --git a/apps/presentationeditor/main/app/view/LeftMenu.js b/apps/presentationeditor/main/app/view/LeftMenu.js index 7ebf6542f..b0c3dcef2 100644 --- a/apps/presentationeditor/main/app/view/LeftMenu.js +++ b/apps/presentationeditor/main/app/view/LeftMenu.js @@ -67,15 +67,6 @@ define([ // Delegated events for creating new items, and clearing completed ones. events: function() { return { - /** coauthoring begin **/ - 'click #left-btn-comments': _.bind(this.onCoauthOptions, this), - 'click #left-btn-chat': _.bind(this.onCoauthOptions, this), - 'click #left-btn-plugins': _.bind(this.onCoauthOptions, this), - /** coauthoring end **/ - 'click #left-btn-searchbar': _.bind(function () { - this.onCoauthOptions(); - this.fireEvent('search:aftershow', this.leftMenu); - }, this), 'click #left-btn-support': function() { var config = this.mode.customization; config && !!config.feedback && !!config.feedback.url ? @@ -101,6 +92,7 @@ define([ enableToggle: true, toggleGroup: 'leftMenuGroup' }); + this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this)); this.btnThumbs = new Common.UI.Button({ action: 'thumbs', @@ -110,6 +102,7 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnThumbs.on('click', _.bind(this.onBtnMenuClick, this)); this.btnAbout = new Common.UI.Button({ action: 'about', @@ -119,6 +112,8 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); + this.btnAbout.on('click', _.bind(this.onFullMenuClick, this)); this.btnSupport = new Common.UI.Button({ action: 'support', @@ -135,6 +130,7 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnComments.on('click', this.onBtnMenuClick.bind(this)); this.btnChat = new Common.UI.Button({ el: $markup.elementById('#left-btn-chat'), @@ -143,12 +139,11 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnChat.on('click', this.onBtnMenuClick.bind(this)); this.btnComments.hide(); this.btnChat.hide(); - this.btnComments.on('click', this.onBtnMenuClick.bind(this)); - this.btnChat.on('click', this.onBtnMenuClick.bind(this)); /** coauthoring end **/ this.btnPlugins = new Common.UI.Button({ @@ -160,10 +155,6 @@ define([ }); this.btnPlugins.hide(); this.btnPlugins.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnThumbs.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); - this.btnAbout.on('click', _.bind(this.onFullMenuClick, this)); this.menuFile = new PE.Views.FileMenu({}); this.btnAbout.panel = (new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor})); @@ -185,13 +176,8 @@ define([ }, onBtnMenuClick: function(btn, e) { - var full_menu_pressed = this.btnAbout.pressed; if (this.btnAbout.pressed) this.btnAbout.toggle(false); - if (btn.options.action == 'search') { - full_menu_pressed && this.fireEvent('panel:show', [this.btnAbout, 'files', false]); - return; - } else if (btn.options.action == 'thumbs') { if (!btn.pressed && this._state.pluginIsRunning) { this.$el.width(Common.localStorage.getItem('pe-mainmenu-width') || MENU_SCALE_PART); @@ -212,9 +198,11 @@ define([ Common.localStorage.setItem('pe-mainmenu-width',this.$el.width()); this.$el.width(SCALE_MIN); } + this.onCoauthOptions(); } this.fireEvent('panel:show', [this, btn.options.action, btn.pressed]); + (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, @@ -348,7 +336,6 @@ define([ !this.btnChat.isDisabled() && !this.btnChat.pressed) { this.btnChat.toggle(true); this.onBtnMenuClick(this.btnChat); - this.onCoauthOptions(); this.panelChat.focus(); } } else @@ -357,14 +344,12 @@ define([ !this.btnComments.isDisabled() && !this.btnComments.pressed) { this.btnComments.toggle(true); this.onBtnMenuClick(this.btnComments); - this.onCoauthOptions(); } } else if (menu == 'advancedsearch') { if (this.btnSearchBar.isVisible() && !this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) { this.btnSearchBar.toggle(true); this.onBtnMenuClick(this.btnSearchBar); - this.onCoauthOptions(); !suspendAfter && this.fireEvent('search:aftershow', this); } } From ee6448c8c573bbba9945b4316b6979ff6b3a6671 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Jun 2022 23:10:28 +0300 Subject: [PATCH 3/6] [SSE] Refactoring left menu (show/hide) --- apps/documenteditor/main/app/view/LeftMenu.js | 2 +- .../main/app/view/LeftMenu.js | 2 +- .../main/app/controller/LeftMenu.js | 4 +- .../main/app/view/LeftMenu.js | 42 ++++++------------- 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index 8b1852cf1..b0efb77f3 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -209,7 +209,7 @@ define([ this.supressEvents = false; this.onCoauthOptions(); - (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu); + (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, diff --git a/apps/presentationeditor/main/app/view/LeftMenu.js b/apps/presentationeditor/main/app/view/LeftMenu.js index b0c3dcef2..02d0ea6f8 100644 --- a/apps/presentationeditor/main/app/view/LeftMenu.js +++ b/apps/presentationeditor/main/app/view/LeftMenu.js @@ -202,7 +202,7 @@ define([ } this.fireEvent('panel:show', [this, btn.options.action, btn.pressed]); - (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu); + (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index e5e61ac04..8a9389bd5 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -740,7 +740,6 @@ define([ case 'escape': var btnSearch = this.getApplication().getController('Viewport').header.btnSearch; btnSearch.pressed && btnSearch.toggle(false); - this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false); if ( this.leftMenu.menuFile.isVisible() ) { if (Common.UI.HintManager.needCloseFileMenu()) @@ -865,11 +864,10 @@ define([ var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace'; this.leftMenu.panelSearch.setSearchMode(mode); } - this.leftMenu._state.isSearchOpen = show; }, isSearchPanelVisible: function () { - return this.leftMenu._state.isSearchOpen; + return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible(); }, onMenuChange: function (value) { diff --git a/apps/spreadsheeteditor/main/app/view/LeftMenu.js b/apps/spreadsheeteditor/main/app/view/LeftMenu.js index a8312d83c..eb88e6eea 100644 --- a/apps/spreadsheeteditor/main/app/view/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/view/LeftMenu.js @@ -59,13 +59,6 @@ define([ // Delegated events for creating new items, and clearing completed ones. events: function() { 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-spellcheck': _.bind(this.onCoauthOptions, this), - 'click #left-btn-searchbar': _.bind(this.onCoauthOptions, this), 'click #left-btn-support': function() { var config = this.mode.customization; config && !!config.feedback && !!config.feedback.url ? @@ -91,6 +84,7 @@ define([ enableToggle: true, toggleGroup: 'leftMenuGroup' }); + this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this)); this.btnAbout = new Common.UI.Button({ action: 'about', @@ -100,6 +94,7 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); this.btnSupport = new Common.UI.Button({ action: 'support', @@ -116,6 +111,8 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this)); + this.btnComments.on('click', this.onBtnMenuClick.bind(this)); this.btnChat = new Common.UI.Button({ el: $markup.elementById('#left-btn-chat'), @@ -124,13 +121,10 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); + this.btnChat.on('click', this.onBtnMenuClick.bind(this)); this.btnComments.hide(); this.btnChat.hide(); - - this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this)); - this.btnComments.on('click', this.onBtnMenuClick.bind(this)); - this.btnChat.on('click', this.onBtnMenuClick.bind(this)); /** coauthoring end **/ this.btnPlugins = new Common.UI.Button({ @@ -153,9 +147,6 @@ define([ this.btnSpellcheck.hide(); this.btnSpellcheck.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); - this.menuFile = new SSE.Views.FileMenu({}); this.btnAbout.panel = (new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor})); this.$el.html($markup); @@ -183,19 +174,16 @@ define([ onBtnMenuClick: function(btn, e) { this.btnAbout.toggle(false); - if (btn.options.action == 'search') { - } else { - if (btn.pressed) { - if (!(this.$el.width() > SCALE_MIN)) { - this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART); - } - } else if (!this._state.pluginIsRunning){ - Common.localStorage.setItem('sse-mainmenu-width',this.$el.width()); - this.$el.width(SCALE_MIN); + if (btn.pressed) { + if (!(this.$el.width() > SCALE_MIN)) { + this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART); } + } else if (!this._state.pluginIsRunning){ + Common.localStorage.setItem('sse-mainmenu-width',this.$el.width()); + this.$el.width(SCALE_MIN); } - -// this.btnChat.id == btn.id && !this.btnChat.pressed && this.fireEvent('chat:hide', this); + this.onCoauthOptions(); + (btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); }, @@ -228,7 +216,6 @@ define([ if (this.panelSearch) { if (this.btnSearchBar.pressed) { this.panelSearch.show(); - this.fireEvent('search:aftershow', this); } else { this.panelSearch.hide(); } @@ -335,7 +322,6 @@ define([ !this.btnChat.isDisabled() && !this.btnChat.pressed) { this.btnChat.toggle(true); this.onBtnMenuClick(this.btnChat); - this.onCoauthOptions(); this.panelChat.focus(); } } else @@ -344,7 +330,6 @@ define([ !this.btnComments.isDisabled() && !this.btnComments.pressed) { this.btnComments.toggle(true); this.onBtnMenuClick(this.btnComments); - this.onCoauthOptions(); this.btnComments.$el.focus(); } } else if (menu == 'advancedsearch') { @@ -352,7 +337,6 @@ define([ !this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) { this.btnSearchBar.toggle(true); this.onBtnMenuClick(this.btnSearchBar); - this.onCoauthOptions(); } } /** coauthoring end **/ From 14442d55d8e87b596b8a985415b474d58234c6e9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Jun 2022 23:31:46 +0300 Subject: [PATCH 4/6] Fix search panel when leftMenu is hidden --- apps/documenteditor/main/app/controller/Viewport.js | 6 +++++- apps/presentationeditor/main/app/controller/Viewport.js | 6 +++++- apps/spreadsheeteditor/main/app/controller/Viewport.js | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index e2d83c757..d649a62d0 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -283,7 +283,11 @@ define([ return; } if (!this.searchBar) { - this.searchBar = new Common.UI.SearchBar({}); + var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); + this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + showOpenPanel: false, + width: 303 + } : {}); this.searchBar.on('hide', _.bind(function () { this.header.btnSearch.toggle(false, true); }, this)); diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index de46818e5..7d63da241 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -345,7 +345,11 @@ define([ return; } if (!this.searchBar) { - this.searchBar = new Common.UI.SearchBar({}); + var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); + this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + showOpenPanel: false, + width: 303 + } : {}); this.searchBar.on('hide', _.bind(function () { this.header.btnSearch.toggle(false, true); }, this)); diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index b1555bff0..6c89b2d69 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -311,7 +311,11 @@ define([ return; } if (!this.searchBar) { - this.searchBar = new Common.UI.SearchBar({}); + var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); + this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + showOpenPanel: false, + width: 303 + } : {}); this.searchBar.on('hide', _.bind(function () { this.header.btnSearch.toggle(false, true); }, this)); From 79428de692c5cf04516d105047d41b8ae445e6da Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 9 Jun 2022 00:09:42 +0300 Subject: [PATCH 5/6] Fix click on buttons when left menu is hidden --- apps/common/main/lib/view/History.js | 5 ++++- apps/documenteditor/main/app/view/LeftMenu.js | 7 ++++++- apps/presentationeditor/main/app/view/LeftMenu.js | 6 +++++- apps/spreadsheeteditor/main/app/view/LeftMenu.js | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/common/main/lib/view/History.js b/apps/common/main/lib/view/History.js index 5c79d22b9..b8ec54273 100644 --- a/apps/common/main/lib/view/History.js +++ b/apps/common/main/lib/view/History.js @@ -68,11 +68,14 @@ define([ initialize: function(options) { _.extend(this, options); Common.UI.BaseView.prototype.initialize.call(this, arguments); + + var filter = Common.localStorage.getKeysFilter(); + this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; }, render: function(el) { el = el || this.el; - $(el).html(this.template({scope: this})).width( (parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART) - SCALE_MIN); + $(el).html(this.template({scope: this})).width( (parseInt(Common.localStorage.getItem(this.appPrefix + 'mainmenu-width')) || MENU_SCALE_PART) - SCALE_MIN); this.viewHistoryList = new Common.UI.DataView({ el: $('#history-list'), diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index b0efb77f3..d6b13128c 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -202,7 +202,7 @@ define([ this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART); } } else if (!this._state.pluginIsRunning) { - Common.localStorage.setItem('de-mainmenu-width',this.$el.width()); + this.isVisible() && Common.localStorage.setItem('de-mainmenu-width',this.$el.width()); this.$el.width(SCALE_MIN); } @@ -497,6 +497,11 @@ define([ } this.limitHint && this.limitHint.css('top', top); }, + + isVisible: function () { + return this.$el && this.$el.is(':visible'); + }, + /** coauthoring begin **/ tipComments : 'Comments', tipChat : 'Chat', diff --git a/apps/presentationeditor/main/app/view/LeftMenu.js b/apps/presentationeditor/main/app/view/LeftMenu.js index 02d0ea6f8..0095d4959 100644 --- a/apps/presentationeditor/main/app/view/LeftMenu.js +++ b/apps/presentationeditor/main/app/view/LeftMenu.js @@ -195,7 +195,7 @@ define([ this.$el.width(Common.localStorage.getItem('pe-mainmenu-width') || MENU_SCALE_PART); } } else if (!this._state.pluginIsRunning){ - Common.localStorage.setItem('pe-mainmenu-width',this.$el.width()); + this.isVisible() && Common.localStorage.setItem('pe-mainmenu-width',this.$el.width()); this.$el.width(SCALE_MIN); } this.onCoauthOptions(); @@ -453,6 +453,10 @@ define([ Common.NotificationCenter.trigger('layout:changed', 'history'); }, + isVisible: function () { + return this.$el && this.$el.is(':visible'); + }, + /** coauthoring begin **/ tipComments : 'Comments', tipChat : 'Chat', diff --git a/apps/spreadsheeteditor/main/app/view/LeftMenu.js b/apps/spreadsheeteditor/main/app/view/LeftMenu.js index eb88e6eea..b9540ad44 100644 --- a/apps/spreadsheeteditor/main/app/view/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/view/LeftMenu.js @@ -179,7 +179,7 @@ define([ this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART); } } else if (!this._state.pluginIsRunning){ - Common.localStorage.setItem('sse-mainmenu-width',this.$el.width()); + this.isVisible() && Common.localStorage.setItem('sse-mainmenu-width',this.$el.width()); this.$el.width(SCALE_MIN); } this.onCoauthOptions(); @@ -439,6 +439,10 @@ define([ Common.NotificationCenter.trigger('layout:changed', 'history'); }, + isVisible: function () { + return this.$el && this.$el.is(':visible'); + }, + /** coauthoring begin **/ tipComments : 'Comments', tipChat : 'Chat', From 568a2d300be5e9618ab02bdb8f9dc2af296a8006 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 9 Jun 2022 00:31:42 +0300 Subject: [PATCH 6/6] Refactoring --- apps/documenteditor/main/app/controller/Viewport.js | 4 ++-- apps/presentationeditor/main/app/controller/Viewport.js | 4 ++-- apps/spreadsheeteditor/main/app/controller/Viewport.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index d649a62d0..eb3209d5d 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -283,8 +283,8 @@ define([ return; } if (!this.searchBar) { - var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); - this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + var isVisible = leftMenu && leftMenu.leftMenu && leftMenu.leftMenu.isVisible(); + this.searchBar = new Common.UI.SearchBar( !isVisible ? { showOpenPanel: false, width: 303 } : {}); diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 7d63da241..0b080326c 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -345,8 +345,8 @@ define([ return; } if (!this.searchBar) { - var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); - this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + var isVisible = leftMenu && leftMenu.leftMenu && leftMenu.leftMenu.isVisible(); + this.searchBar = new Common.UI.SearchBar( !isVisible ? { showOpenPanel: false, width: 303 } : {}); diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index 6c89b2d69..1bf0adc1f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -311,8 +311,8 @@ define([ return; } if (!this.searchBar) { - var hideLeftPanel = this.appConfig.canBrandingExt && (!Common.UI.LayoutManager.isElementVisible('leftMenu') || this.appConfig.customization && this.appConfig.customization.leftMenu===false); - this.searchBar = new Common.UI.SearchBar( hideLeftPanel ? { + var isVisible = leftMenu && leftMenu.leftMenu && leftMenu.leftMenu.isVisible(); + this.searchBar = new Common.UI.SearchBar( !isVisible ? { showOpenPanel: false, width: 303 } : {});