From 91433816bfa1ccfa1f608208d8b6b0bddc8dfaab Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 6 Jul 2021 18:42:13 +0300 Subject: [PATCH] Fix hint manager --- apps/common/main/lib/component/HintManager.js | 30 +++++++++++++++---- apps/common/main/lib/core/keymaster.js | 2 ++ apps/common/main/lib/view/Header.js | 5 +++- .../main/app/controller/Main.js | 2 ++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index 97e767faf..aa787b76b 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -118,6 +118,10 @@ Common.UI.HintManager = new(function() { return arr; }; + var _isItemDisabled = function (item) { + return (item.hasClass('disabled') || item.parent().hasClass('disabled') || item.attr('disabled')); + }; + var _getControls = function() { _currentControls = []; var arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray(); @@ -177,7 +181,10 @@ Common.UI.HintManager = new(function() { if (_currentControls.length === 0) _getControls(); _currentControls.forEach(function(item, index) { - if (!item.hasClass('disabled') && !item.parent().hasClass('disabled') && !item.attr('disabled')) { + if (!_isItemDisabled(item)) { + if ($(_currentSection).prop('id') === 'toolbar' && ($(_currentSection).find('.toolbar-mask').length > 0 || item.closest('.group').find('.toolbar-group-mask').length > 0)) { + return; + } if (window.SSE && item.parent().prop('id') === 'statusbar_bottom') { var $statusbar = item.parent(); if (item.offset().left > $statusbar.offset().left + $statusbar.width()) { @@ -264,10 +271,13 @@ Common.UI.HintManager = new(function() { }; var _init = function() { - Common.NotificationCenter.on('app:ready', function (mode) { - _lang = mode.lang; - _getAlphabetLetters(); - }.bind(this)); + Common.NotificationCenter.on({ + 'app:ready': function (mode) { + _lang = mode.lang; + _getAlphabetLetters(); + }, + 'hints:clear': _clearHints + }); $(document).on('keyup', function(e) { if (e.keyCode == Common.UI.Keys.ALT && _isAlt) { e.preventDefault(); @@ -305,7 +315,7 @@ Common.UI.HintManager = new(function() { _inputLetters = _inputLetters + curLetter.toUpperCase(); for (var i = 0; i < _currentControls.length; i++) { var item = _currentControls[i]; - if (item.attr('data-hint-title') === _inputLetters) { + if (!_isItemDisabled(item) && item.attr('data-hint-title') === _inputLetters) { curr = item; break; } @@ -374,8 +384,16 @@ Common.UI.HintManager = new(function() { return !(_hintVisible && _currentLevel > 1); }; + var _clearHints = function () { + if (_hintVisible) { + _hideHints(); + _resetToDefault(); + } + }; + return { init: _init, + clearHints: _clearHints, needCloseMenu: _needCloseMenu } })(); \ No newline at end of file diff --git a/apps/common/main/lib/core/keymaster.js b/apps/common/main/lib/core/keymaster.js index e89a8400a..f6d05de70 100644 --- a/apps/common/main/lib/core/keymaster.js +++ b/apps/common/main/lib/core/keymaster.js @@ -105,6 +105,8 @@ for(k in _mods) if((!_mods[k] && index(handler.mods, +k) > -1) || (_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false; + if (modifiersMatch) + Common.NotificationCenter.trigger('hints:clear'); // call the handler and stop the event if neccessary if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){ if(locked===true || handler.locked || handler.method(event, handler)===false){ diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index d61854e49..b68f97e01 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -442,7 +442,10 @@ define([ me.btnFavorite = new Common.UI.Button({ id: 'btn-favorite', cls: 'btn-header', - iconCls: 'toolbar__icon icon--inverse btn-favorite' + iconCls: 'toolbar__icon icon--inverse btn-favorite', + dataHint: '0', + dataHintDirection: 'bottom', + dataHintOffset: 'big' }); Common.NotificationCenter.on({ diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index aa2112df1..bd3ac2019 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -802,6 +802,8 @@ define([ isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; toolbarView.btnSave.setDisabled(isDisabled); } + + Common.UI.HintManager.clearHints(); }, onLongActionBegin: function(type, id) {