diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index 89581655b..e9241a7ac 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -44,6 +44,7 @@ * * * + * * Example usage with components: * * new Common.UI.Button({ @@ -118,7 +119,10 @@ Common.UI.HintManager = new(function() { _isDocReady = false, _isEditDiagram = false, _usedTitles = [], - _appPrefix; + _appPrefix, + _staticHints = { // for desktop buttons + "btnhome": 'K' + }; var _api; @@ -223,6 +227,15 @@ Common.UI.HintManager = new(function() { return arr; }; + var _getLetterInUILanguage = function (letter) { + var l = letter; + if (_arrAlphabet.indexOf(l) === -1) { + var ind = _arrEnAlphabet.indexOf(l); + l = _arrAlphabet[ind]; + } + return l; + }; + var _isItemDisabled = function (item) { return (item.hasClass('disabled') || item.parent().hasClass('disabled') || item.attr('disabled')); }; @@ -268,21 +281,25 @@ Common.UI.HintManager = new(function() { }); return; } - var _arrLetters = []; + var _arrLetters = [], + _usedLetters = []; + if (_currentLevel === 0) { + for (var key in _staticHints) { + var t = _staticHints[key].toLowerCase(); + _usedTitles.push(t); + _usedLetters.push(_arrAlphabet.indexOf(t)); + } + } if (visibleItems.length > _arrAlphabet.length) { visibleItemsWithTitle.forEach(function (item) { var t = $(item).data('hint-title').toLowerCase(); - if (_arrAlphabet.indexOf(t) === -1) { - var ind = _arrEnAlphabet.indexOf(t); - t = _arrAlphabet[ind]; - } + t = _getLetterInUILanguage(t); _usedTitles.push(t); }); - _arrLetters = _getLetters(visibleItems.length); + _arrLetters = _getLetters(visibleItems.length + (_currentLevel === 0 ? _.size(_staticHints) : 0)); } else { _arrLetters = _arrAlphabet.slice(); } - var usedLetters = []; if (arrItemsWithTitle.length > 0) { visibleItems.forEach(function (item) { var el = $(item); @@ -290,9 +307,9 @@ Common.UI.HintManager = new(function() { if (title) { var ind = _arrEnAlphabet.indexOf(title.toLowerCase()); if (ind === -1) { // we have already changed - usedLetters.push(_arrAlphabet.indexOf(title.toLowerCase())); + _usedLetters.push(_arrAlphabet.indexOf(title.toLowerCase())); } else { - usedLetters.push(ind); + _usedLetters.push(ind); if (_lang !== 'en') { el.attr('data-hint-title', _arrLetters[ind].toUpperCase()); } @@ -303,7 +320,7 @@ Common.UI.HintManager = new(function() { var index = 0; visibleItems.forEach(function (item) { var el = $(item); - while (usedLetters.indexOf(index) !== -1) { + while (_usedLetters.indexOf(index) !== -1) { index++; } var title = el.attr('data-hint-title'); @@ -620,7 +637,16 @@ Common.UI.HintManager = new(function() { _arrAlphabet = langsJson[lang]; return _arrAlphabet; }; - return !_setAlphabet(lng) ? (!_setAlphabet(lng.split(/[\-_]/)[0]) ? _setAlphabet('en') : true) : true; + var loaded = !_setAlphabet(lng) ? (!_setAlphabet(lng.split(/[\-_]/)[0]) ? _setAlphabet('en') : true) : true; + if (loaded && _lang !== 'en') { + for (var key in _staticHints) { + var hint = _getLetterInUILanguage(_staticHints[key].toLowerCase()); + if (hint) { + _staticHints[key] = hint.toUpperCase(); + } + } + } + return loaded; }); Common.Utils.loadConfig('../../common/main/resources/alphabetletters/qwertyletters.json', function (langsJson) { _arrQwerty = langsJson[_lang]; @@ -661,11 +687,16 @@ Common.UI.HintManager = new(function() { _isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle; }; + var _getStaticHint = function (key) { + return _staticHints[key]; + }; + return { init: _init, setMode: _setMode, clearHints: _clearHints, needCloseFileMenu: _needCloseFileMenu, - isHintVisible: _isHintVisible + isHintVisible: _isHintVisible, + getStaticHint: _getStaticHint } })(); \ No newline at end of file diff --git a/apps/common/main/lib/util/Tip.js b/apps/common/main/lib/util/Tip.js index 4a9574c24..4d9c496be 100644 --- a/apps/common/main/lib/util/Tip.js +++ b/apps/common/main/lib/util/Tip.js @@ -112,10 +112,13 @@ if (!me.options.keepvisible && !me.options.hideonclick && me.tip().is(':visible')) me.hide(); }}); + this.isDesktopApp = Common.Controllers.Desktop.isActive(); }, mousemove: function (e) { - this.targetXY = [e.clientX*Common.Utils.zoom(), e.clientY*Common.Utils.zoom()]; + var x = e.clientX*Common.Utils.zoom(), + y = e.clientY*Common.Utils.zoom(); + this.targetXY = [x, this.isDesktopApp ? Math.max(y, 14) : y]; }, leave: function(obj) { diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index c1adfe8a4..2d39995ca 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -516,7 +516,7 @@ define([ disabled: disabled === true, dataHint:'0', dataHintDirection: hintDirection ? hintDirection : (config.isDesktopApp ? 'right' : 'left'), - dataHintOffset: hintOffset ? hintOffset : (config.isDesktopApp ? '10, -10' : '10, 10'), + dataHintOffset: hintOffset ? hintOffset : (config.isDesktopApp ? '10, -18' : '10, 10'), dataHintTitle: hintTitle })).render(slot); }