Alt-key hints: don't show hints that go beyond the boundaries of the document

This commit is contained in:
JuliaSvinareva 2021-08-12 15:39:47 +03:00
parent 5a3eaa2700
commit 903e7862cb
4 changed files with 34 additions and 27 deletions

View file

@ -251,6 +251,8 @@ Common.UI.HintManager = new(function() {
}; };
var _getHints = function() { var _getHints = function() {
var docH = Common.Utils.innerHeight() - 20,
docW = Common.Utils.innerWidth() - 20;
if (_currentControls.length === 0) if (_currentControls.length === 0)
_getControls(); _getControls();
_currentControls.forEach(function(item, index) { _currentControls.forEach(function(item, index) {
@ -277,6 +279,12 @@ Common.UI.HintManager = new(function() {
item.attr('data-hint-direction', 'bottom'); item.attr('data-hint-direction', 'bottom');
} }
} }
var maxHeight = docH;
if ($('#file-menu-panel').is(':visible') && _currentLevel > 1 &&
($('.fms-flex-apply').is(':visible') || $('#fms-flex-apply').is(':visible')) &&
item.closest('.fms-flex-apply').length < 1 && item.closest('#fms-flex-apply').length < 1) {
maxHeight = docH - $('.fms-flex-apply').height();
}
var offsets = item.attr('data-hint-offset'); var offsets = item.attr('data-hint-offset');
var applyOffset = offsets === 'big' ? 6 : (offsets === 'medium' ? 4 : (offsets === 'small' ? 2 : 0)); var applyOffset = offsets === 'big' ? 6 : (offsets === 'medium' ? 4 : (offsets === 'small' ? 2 : 0));
if (applyOffset) { if (applyOffset) {
@ -298,32 +306,31 @@ Common.UI.HintManager = new(function() {
offsets = offsets ? item.attr('data-hint-offset').split(',').map(function (item) { return parseInt(item); }) : [0, 0]; offsets = offsets ? item.attr('data-hint-offset').split(',').map(function (item) { return parseInt(item); }) : [0, 0];
} }
var offset = item.offset(); var offset = item.offset();
if (direction === 'left-top') var top, left;
if (direction === 'left-top') {
top = offset.top - 10 + offsets[0];
left = offset.left - 10 + offsets[1];
} else if (direction === 'top') {
top = offset.top - 18 + offsets[0];
left = offset.left + (item.outerWidth() - 18) / 2 + offsets[1];
} else if (direction === 'right') {
top = offset.top + (item.outerHeight() - 18) / 2 + offsets[0];
left = offset.left + item.outerWidth() + offsets[1];
} else if (direction === 'left') {
top = offset.top + (item.outerHeight() - 18) / 2 + offsets[0];
left = offset.left - 18 + offsets[1];
} else {
top = offset.top + item.outerHeight() + offsets[0];
left = offset.left + (item.outerWidth() - 18) / 2 + offsets[1];
}
if (top < maxHeight && left < docW) {
hint.css({ hint.css({
top: offset.top - 10 + offsets[0], top: top,
left: offset.left - 10 + offsets[1] left: left
});
else if (direction === 'top')
hint.css({
top: offset.top - 18 + offsets[0],
left: offset.left + (item.outerWidth() - 18) / 2 + offsets[1]
});
else if (direction === 'right')
hint.css({
top: offset.top + (item.outerHeight() - 18) / 2 + offsets[0],
left: offset.left + item.outerWidth() + offsets[1]
});
else if (direction === 'left')
hint.css({
top: offset.top + (item.outerHeight() - 18) / 2 + offsets[0],
left: offset.left - 18 + offsets[1]
});
else
hint.css({
top: offset.top + item.outerHeight() + offsets[0],
left: offset.left + (item.outerWidth() - 18) / 2 + offsets[1]
}); });
$(document.body).append(hint); $(document.body).append(hint);
}
_currentHints.push(hint); _currentHints.push(hint);
} }

View file

@ -288,7 +288,7 @@ define([
'<table style="margin: 10px 0;"><tbody>', '<table style="margin: 10px 0;"><tbody>',
'<tr>', '<tr>',
'<td class="left"></td>', '<td class="left"></td>',
'<td class="right"><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.okButtonText %></button></td>', '<td class="right"><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button></td>',
'</tr>', '</tr>',
'</tbody></table>', '</tbody></table>',
'</div>' '</div>'

View file

@ -264,7 +264,7 @@ define([
'<table style="margin: 10px 0;"><tbody>', '<table style="margin: 10px 0;"><tbody>',
'<tr>', '<tr>',
'<td class="left"></td>', '<td class="left"></td>',
'<td class="right"><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.okButtonText %></button></td>', '<td class="right"><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button></td>',
'</tr>', '</tr>',
'</tbody></table>', '</tbody></table>',
'</div>' '</div>'

View file

@ -805,7 +805,7 @@ define([
'<table class="main" style="margin: 10px 0;"><tbody>', '<table class="main" style="margin: 10px 0;"><tbody>',
'<tr>', '<tr>',
'<td class="left"></td>', '<td class="left"></td>',
'<td class="right"><button class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>', '<td class="right"><button class="btn normal dlg-btn primary" data-hint="3" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button></td>',
'</tr>', '</tr>',
'</tbody></table>', '</tbody></table>',
'</div>', '</div>',