Fix hint manager, add hint visible checks to close panels in left menu

This commit is contained in:
JuliaSvinareva 2021-07-08 20:20:34 +03:00
parent 87413ce121
commit 8bf91f4847
7 changed files with 41 additions and 27 deletions

View file

@ -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
}
})();

View file

@ -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();
}
},

View file

@ -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;

View file

@ -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');
}
}
};

View file

@ -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;

View file

@ -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');
}
}
};

View file

@ -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) {