From 8bf91f4847504cbdc4849e507c8fd5265db5826f Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 8 Jul 2021 20:20:34 +0300 Subject: [PATCH] Fix hint manager, add hint visible checks to close panels in left menu --- apps/common/main/lib/component/HintManager.js | 36 +++++++++++-------- apps/common/main/lib/view/Chat.js | 2 +- .../main/app/controller/LeftMenu.js | 8 +++-- .../main/app/view/DocumentHolder.js | 3 +- .../main/app/controller/LeftMenu.js | 8 +++-- .../main/app/view/DocumentHolder.js | 3 +- .../main/app/controller/LeftMenu.js | 8 +++-- 7 files changed, 41 insertions(+), 27 deletions(-) diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index aa787b76b..aa2e5de4e 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -58,7 +58,8 @@ Common.UI.HintManager = new(function() { _currentSection = document, _currentControls = [], _currentHints = [], - _inputLetters = ''; + _inputLetters = '', + _isClear = false; var _setCurrentSection = function (btn) { if (btn === 'esc') { @@ -324,11 +325,11 @@ Common.UI.HintManager = new(function() { var tag = curr.prop("tagName").toLowerCase(); if (window.SSE && curr.parent().prop('id') === 'statusbar_bottom') { curr.contextmenu(); - _hideHints(); + _clearHints(); } else if (tag === 'input' || tag === 'textarea') { curr.trigger(jQuery.Event('click', {which: 1})); curr.focus(); - _hideHints(); + _clearHints(); } else { if (!curr.attr('content-target') || (curr.attr('content-target') && !$(`#${curr.attr('content-target')}`).is(':visible'))) { // need to open panel if (!($('#file-menu-panel').is(':visible') && (curr.parent().prop('id') === 'fm-btn-info' && $('#panel-info').is(':visible') || @@ -341,23 +342,22 @@ Common.UI.HintManager = new(function() { } } if (curr.prop('id') === 'btn-goback' || curr.closest('.btn-slot').prop('id') === 'slot-btn-options' || curr.prop('id') === 'left-btn-thumbs') { - _hideHints(); - _resetToDefault(); - return; + _clearHints(); } if (curr.prop('id') === 'add-comment-doc') { _removeHints(); _currentHints.length = 0; _currentControls.length = 0; - } else { - _nextLevel(); + _showHints(); + return; + } + if (!_isClear) { + _nextLevel(); + _setCurrentSection(curr); + _showHints(); } - _setCurrentSection(curr); - _showHints(); - } - if (!_hintVisible) { // if there isn't new level, reset settings to start - _resetToDefault(); } + _isClear = false; } } e.preventDefault(); @@ -380,7 +380,7 @@ Common.UI.HintManager = new(function() { }); }; - var _needCloseMenu = function () { + var _needCloseFileMenu = function () { return !(_hintVisible && _currentLevel > 1); }; @@ -388,12 +388,18 @@ Common.UI.HintManager = new(function() { if (_hintVisible) { _hideHints(); _resetToDefault(); + _isClear = true; } }; + var _isHintVisible = function () { + return _hintVisible; + }; + return { init: _init, clearHints: _clearHints, - needCloseMenu: _needCloseMenu + needCloseFileMenu: _needCloseFileMenu, + isHintVisible: _isHintVisible } })(); \ No newline at end of file diff --git a/apps/common/main/lib/view/Chat.js b/apps/common/main/lib/view/Chat.js index 50ef40b0f..9017293c4 100644 --- a/apps/common/main/lib/view/Chat.js +++ b/apps/common/main/lib/view/Chat.js @@ -156,7 +156,7 @@ define([ this._onBtnAddMessage(event); } } else - if (event.keyCode == Common.UI.Keys.ESC) { + if (event.keyCode == Common.UI.Keys.ESC && !Common.UI.HintManager.isHintVisible()) { this.hide(); } }, diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 1bc19e377..7874fc5ae 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -808,7 +808,7 @@ define([ case 'escape': // if (!this.leftMenu.isOpened()) return true; if ( this.leftMenu.menuFile.isVisible() ) { - if (Common.UI.HintManager.needCloseMenu()) + if (Common.UI.HintManager.needCloseFileMenu()) this.leftMenu.menuFile.hide(); return false; } @@ -828,8 +828,10 @@ define([ } if (this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || $(e.target).parents('#left-menu').length ) { - this.leftMenu.close(); - Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + if (!Common.UI.HintManager.isHintVisible()) { + this.leftMenu.close(); + Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + } return false; } break; diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index d087ec28f..869f58f4f 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -301,7 +301,8 @@ define([ if (key == Common.UI.Keys.ESC) { Common.UI.Menu.Manager.hideAll(); - Common.NotificationCenter.trigger('leftmenu:change', 'hide'); + if (!Common.UI.HintManager.isHintVisible()) + Common.NotificationCenter.trigger('leftmenu:change', 'hide'); } } }; diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index ba82023fe..ed69d3f0a 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -673,7 +673,7 @@ define([ // if (!this.leftMenu.isOpened()) return true; // TODO: if ( this.leftMenu.menuFile.isVisible() ) { - if (Common.UI.HintManager.needCloseMenu()) + if (Common.UI.HintManager.needCloseFileMenu()) this.leftMenu.menuFile.hide(); return false; } @@ -694,8 +694,10 @@ define([ if ( this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || $(e.target).parents('#left-menu').length ) { - this.leftMenu.close(); - Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + if (!Common.UI.HintManager.isHintVisible()) { + this.leftMenu.close(); + Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + } return false; } break; diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 9285ce0ee..6b1901ddd 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -303,7 +303,8 @@ define([ } if (key == Common.UI.Keys.ESC) { Common.UI.Menu.Manager.hideAll(); - Common.NotificationCenter.trigger('leftmenu:change', 'hide'); + if (!Common.UI.HintManager.isHintVisible()) + Common.NotificationCenter.trigger('leftmenu:change', 'hide'); } } }; diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 599cfeec3..8d36b592d 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -847,7 +847,7 @@ define([ return false; case 'escape': if ( this.leftMenu.menuFile.isVisible() ) { - if (Common.UI.HintManager.needCloseMenu()) + if (Common.UI.HintManager.needCloseFileMenu()) this.leftMenu.menuFile.hide(); return false; } @@ -867,8 +867,10 @@ define([ } if ( this.leftMenu.btnAbout.pressed || ($(e.target).parents('#left-menu').length || this.leftMenu.btnPlugins.pressed || this.leftMenu.btnComments.pressed) && this.api.isCellEdited!==true) { - this.leftMenu.close(); - Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + if (!Common.UI.HintManager.isHintVisible()) { + this.leftMenu.close(); + Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); + } return false; } if (this.mode.isEditDiagram || this.mode.isEditMailMerge) {