Fix hint manager

This commit is contained in:
JuliaSvinareva 2021-07-06 18:42:13 +03:00
parent 40933fc590
commit 91433816bf
4 changed files with 32 additions and 7 deletions

View file

@ -118,6 +118,10 @@ Common.UI.HintManager = new(function() {
return arr; return arr;
}; };
var _isItemDisabled = function (item) {
return (item.hasClass('disabled') || item.parent().hasClass('disabled') || item.attr('disabled'));
};
var _getControls = function() { var _getControls = function() {
_currentControls = []; _currentControls = [];
var arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray(); var arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray();
@ -177,7 +181,10 @@ Common.UI.HintManager = new(function() {
if (_currentControls.length === 0) if (_currentControls.length === 0)
_getControls(); _getControls();
_currentControls.forEach(function(item, index) { _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') { if (window.SSE && item.parent().prop('id') === 'statusbar_bottom') {
var $statusbar = item.parent(); var $statusbar = item.parent();
if (item.offset().left > $statusbar.offset().left + $statusbar.width()) { if (item.offset().left > $statusbar.offset().left + $statusbar.width()) {
@ -264,10 +271,13 @@ Common.UI.HintManager = new(function() {
}; };
var _init = function() { var _init = function() {
Common.NotificationCenter.on('app:ready', function (mode) { Common.NotificationCenter.on({
_lang = mode.lang; 'app:ready': function (mode) {
_getAlphabetLetters(); _lang = mode.lang;
}.bind(this)); _getAlphabetLetters();
},
'hints:clear': _clearHints
});
$(document).on('keyup', function(e) { $(document).on('keyup', function(e) {
if (e.keyCode == Common.UI.Keys.ALT && _isAlt) { if (e.keyCode == Common.UI.Keys.ALT && _isAlt) {
e.preventDefault(); e.preventDefault();
@ -305,7 +315,7 @@ Common.UI.HintManager = new(function() {
_inputLetters = _inputLetters + curLetter.toUpperCase(); _inputLetters = _inputLetters + curLetter.toUpperCase();
for (var i = 0; i < _currentControls.length; i++) { for (var i = 0; i < _currentControls.length; i++) {
var item = _currentControls[i]; var item = _currentControls[i];
if (item.attr('data-hint-title') === _inputLetters) { if (!_isItemDisabled(item) && item.attr('data-hint-title') === _inputLetters) {
curr = item; curr = item;
break; break;
} }
@ -374,8 +384,16 @@ Common.UI.HintManager = new(function() {
return !(_hintVisible && _currentLevel > 1); return !(_hintVisible && _currentLevel > 1);
}; };
var _clearHints = function () {
if (_hintVisible) {
_hideHints();
_resetToDefault();
}
};
return { return {
init: _init, init: _init,
clearHints: _clearHints,
needCloseMenu: _needCloseMenu needCloseMenu: _needCloseMenu
} }
})(); })();

View file

@ -105,6 +105,8 @@
for(k in _mods) for(k in _mods)
if((!_mods[k] && index(handler.mods, +k) > -1) || if((!_mods[k] && index(handler.mods, +k) > -1) ||
(_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false; (_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 // call the handler and stop the event if neccessary
if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){ if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
if(locked===true || handler.locked || handler.method(event, handler)===false){ if(locked===true || handler.locked || handler.method(event, handler)===false){

View file

@ -442,7 +442,10 @@ define([
me.btnFavorite = new Common.UI.Button({ me.btnFavorite = new Common.UI.Button({
id: 'btn-favorite', id: 'btn-favorite',
cls: 'btn-header', 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({ Common.NotificationCenter.on({

View file

@ -802,6 +802,8 @@ define([
isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
toolbarView.btnSave.setDisabled(isDisabled); toolbarView.btnSave.setDisabled(isDisabled);
} }
Common.UI.HintManager.clearHints();
}, },
onLongActionBegin: function(type, id) { onLongActionBegin: function(type, id) {