From f151aad64f690a97c6a684f686b304e099f91165 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 4 Jun 2021 21:43:40 +0300 Subject: [PATCH] Fix hint manager --- apps/common/main/lib/component/HintManager.js | 34 +++++++++++++------ .../main/lib/template/CommentsPanel.template | 8 ++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index d7efde955..a277932a1 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -68,14 +68,15 @@ Common.UI.HintManager = new(function() { if ($('#file-menu-panel').is(':visible')) { _currentSection = $('#file-menu-panel'); } else { - _currentSection = btn.closest('.hint-section') || document; + _currentSection = (btn && btn.closest('.hint-section')) || document; } }; var _showHints = function () { _inputLetters = ''; - if (_currentHints.length === 0) + if (_currentHints.length === 0 || ($('#file-menu-panel').is(':visible') && _currentLevel === 1)) { _getHints(); + } if (_currentHints.length > 0) { _hintVisible = true; _currentHints.forEach(function(item) { @@ -120,7 +121,6 @@ Common.UI.HintManager = new(function() { _controls[_currentLevel] = $('[data-hint=' + (_currentLevel) + ']').toArray(); }*/ _controls[_currentLevel] = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray(); - console.log(_controls[_currentLevel]); _currentControls = []; var arr = _controls[_currentLevel]; var visibleItems = arr.filter(function (item) { @@ -206,6 +206,13 @@ Common.UI.HintManager = new(function() { }); }; + var _resetToDefault = function() { + _currentLevel = $('.toolbar-fullview-panel').is(':visible') ? 1 : 0; + _setCurrentSection(); + _currentHints.length = 0; + _currentControls.length = 0; + }; + var _init = function() { Common.NotificationCenter.on('app:ready', function (mode) { _lang = mode.lang; @@ -215,14 +222,10 @@ Common.UI.HintManager = new(function() { if (e.keyCode == Common.UI.Keys.ALT && _isAlt) { e.preventDefault(); if (!_hintVisible) { - if ($('.toolbar-fullview-panel').is(':visible') && _currentLevel === 0) { - _nextLevel(); - } else { - _currentLevel = 0; - } _showHints(); } else { _hideHints(); + _resetToDefault(); } } _isAlt = false; @@ -254,11 +257,22 @@ Common.UI.HintManager = new(function() { curr.focus(); _hideHints(); } else { - curr.trigger(jQuery.Event('click', {which: 1})); - _nextLevel(); + if (!curr.attr('content-target') || (curr.attr('content-target') && !$(`#${curr.attr('content-target')}`).is(':visible'))) { // need to open panel + curr.trigger(jQuery.Event('click', {which: 1})); + } + if (curr.prop('id') === 'add-comment-doc') { + _removeHints(); + _currentHints.length = 0; + _currentControls.length = 0; + } else { + _nextLevel(); + } _setCurrentSection(curr); _showHints(); } + if (!_hintVisible) { // if there isn't new level, reset settings to start + _resetToDefault(); + } } } e.preventDefault(); diff --git a/apps/common/main/lib/template/CommentsPanel.template b/apps/common/main/lib/template/CommentsPanel.template index 52d4e7537..ac2b69faa 100644 --- a/apps/common/main/lib/template/CommentsPanel.template +++ b/apps/common/main/lib/template/CommentsPanel.template @@ -1,13 +1,13 @@