From 0c543de506139603a4aa2e9c02dd1db44e1acd7e Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 9 Jun 2022 23:39:37 +0300 Subject: [PATCH 1/5] [DE PE SSE] Add data-hint-desktop attr --- apps/common/main/lib/component/Mixtbar.js | 2 +- .../common/main/lib/controller/HintManager.js | 42 ++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/component/Mixtbar.js b/apps/common/main/lib/component/Mixtbar.js index 9b452c354..bedd1c898 100644 --- a/apps/common/main/lib/component/Mixtbar.js +++ b/apps/common/main/lib/component/Mixtbar.js @@ -107,7 +107,7 @@ define([ '<% } %>' + '<% } %>' + '' + - '' + + '' + ''; this.$layout = $(options.template({ diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index 548d6e048..adcb807a8 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -44,6 +44,8 @@ * * * + * data-hint-desktop // true/false + * * Example usage with components: * * new Common.UI.Button({ @@ -231,15 +233,19 @@ Common.UI.HintManager = new(function() { _currentControls = []; _usedTitles = []; var arr = [], - arrItemsWithTitle = []; + arrItemsWithTitle = [], + arrItemsDesktop = []; + if (_.isArray(_currentSection)) { _currentSection.forEach(function (section) { arr = arr.concat($(section).find('[data-hint=' + (_currentLevel) + ']').toArray()); arrItemsWithTitle = arrItemsWithTitle.concat($(section).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray()); + arrItemsDesktop = arrItemsWithTitle.concat($(section).find('[data-hint-title][data-hint-desktop="true"][data-hint=' + (_currentLevel) + ']').toArray()); }); } else { arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray(); arrItemsWithTitle = $(_currentSection).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray(); + arrItemsDesktop = $(_currentSection).find('[data-hint-title][data-hint-desktop="true"][data-hint=' + (_currentLevel) + ']').toArray(); } var visibleItems = arr.filter(function (item) { return $(item).is(':visible'); @@ -268,21 +274,34 @@ Common.UI.HintManager = new(function() { }); return; } - var _arrLetters = []; + var getLetterInUILanguage = function (letter) { + var l = letter; + if (_arrAlphabet.indexOf(l) === -1) { + var ind = _arrEnAlphabet.indexOf(l); + l = _arrAlphabet[ind]; + } + return l; + }; + var _arrLetters = [], + _usedLetters = []; + if (arrItemsDesktop.length > 0) { + arrItemsDesktop.forEach(function (item) { + var t = $(item).data('hint-title').toLowerCase(); + t = getLetterInUILanguage(t); + _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 + arrItemsDesktop.length); } else { _arrLetters = _arrAlphabet.slice(); } - var usedLetters = []; if (arrItemsWithTitle.length > 0) { visibleItems.forEach(function (item) { var el = $(item); @@ -290,9 +309,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()); } @@ -300,10 +319,11 @@ Common.UI.HintManager = new(function() { } }); } + Common.NotificationCenter.trigger('hints:used-titles', _currentLevel, arrItemsDesktop.concat(visibleItemsWithTitle), _usedLetters, _arrLetters); 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'); From fe0ab8706bf5b369181c0b4dd934f48b9efa7370 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 20 Jun 2022 18:40:26 +0300 Subject: [PATCH 2/5] [DE PE SSE] Add getStaticHint method instead of data-hint-desktop attr --- apps/common/main/lib/component/Mixtbar.js | 2 +- .../common/main/lib/controller/HintManager.js | 61 +++++++++++-------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/apps/common/main/lib/component/Mixtbar.js b/apps/common/main/lib/component/Mixtbar.js index bedd1c898..9b452c354 100644 --- a/apps/common/main/lib/component/Mixtbar.js +++ b/apps/common/main/lib/component/Mixtbar.js @@ -107,7 +107,7 @@ define([ '<% } %>' + '<% } %>' + '' + - '' + + '' + ''; this.$layout = $(options.template({ diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index adcb807a8..fffee7e21 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -44,7 +44,6 @@ * * * - * data-hint-desktop // true/false * * Example usage with components: * @@ -120,7 +119,10 @@ Common.UI.HintManager = new(function() { _isDocReady = false, _isEditDiagram = false, _usedTitles = [], - _appPrefix; + _appPrefix, + _staticHints = { // for desktop buttons + "btnhome": 'K' + }; var _api; @@ -225,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')); }; @@ -233,19 +244,15 @@ Common.UI.HintManager = new(function() { _currentControls = []; _usedTitles = []; var arr = [], - arrItemsWithTitle = [], - arrItemsDesktop = []; - + arrItemsWithTitle = []; if (_.isArray(_currentSection)) { _currentSection.forEach(function (section) { arr = arr.concat($(section).find('[data-hint=' + (_currentLevel) + ']').toArray()); arrItemsWithTitle = arrItemsWithTitle.concat($(section).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray()); - arrItemsDesktop = arrItemsWithTitle.concat($(section).find('[data-hint-title][data-hint-desktop="true"][data-hint=' + (_currentLevel) + ']').toArray()); }); } else { arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray(); arrItemsWithTitle = $(_currentSection).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray(); - arrItemsDesktop = $(_currentSection).find('[data-hint-title][data-hint-desktop="true"][data-hint=' + (_currentLevel) + ']').toArray(); } var visibleItems = arr.filter(function (item) { return $(item).is(':visible'); @@ -274,31 +281,22 @@ Common.UI.HintManager = new(function() { }); return; } - var getLetterInUILanguage = function (letter) { - var l = letter; - if (_arrAlphabet.indexOf(l) === -1) { - var ind = _arrEnAlphabet.indexOf(l); - l = _arrAlphabet[ind]; - } - return l; - }; var _arrLetters = [], _usedLetters = []; - if (arrItemsDesktop.length > 0) { - arrItemsDesktop.forEach(function (item) { - var t = $(item).data('hint-title').toLowerCase(); - t = getLetterInUILanguage(t); + 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(); - t = getLetterInUILanguage(t); + t = _getLetterInUILanguage(t); _usedTitles.push(t); }); - _arrLetters = _getLetters(visibleItems.length + arrItemsDesktop.length); + _arrLetters = _getLetters(visibleItems.length + (_currentLevel === 0 ? _.size(_staticHints) : 0)); } else { _arrLetters = _arrAlphabet.slice(); } @@ -319,7 +317,6 @@ Common.UI.HintManager = new(function() { } }); } - Common.NotificationCenter.trigger('hints:used-titles', _currentLevel, arrItemsDesktop.concat(visibleItemsWithTitle), _usedLetters, _arrLetters); var index = 0; visibleItems.forEach(function (item) { var el = $(item); @@ -638,7 +635,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]; @@ -679,11 +685,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 From d20b16190966a1d1f8ae812e4427c3809161427a Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 11 Aug 2022 10:44:16 +0300 Subject: [PATCH 3/5] Fix position of alt hints for desktop app --- apps/common/main/lib/view/Header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 7f7fcc26a..f1753db57 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -494,7 +494,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); } From 39f5ce85390979d17c4c0c99683e500193ca8616 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 17 Aug 2022 21:06:56 +0300 Subject: [PATCH 4/5] [DE PE SSE] Fix tip position for desktop app --- apps/common/main/lib/util/Tip.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/common/main/lib/util/Tip.js b/apps/common/main/lib/util/Tip.js index 4a9574c24..f360ea948 100644 --- a/apps/common/main/lib/util/Tip.js +++ b/apps/common/main/lib/util/Tip.js @@ -112,10 +112,15 @@ if (!me.options.keepvisible && !me.options.hideonclick && me.tip().is(':visible')) me.hide(); }}); + Common.NotificationCenter.on('app:ready', function (mode) { + me.isDesktopApp = mode.isDesktopApp; + }); }, 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) { From db97a50ca56d935c3f1504f11254801070d1d731 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 23 Aug 2022 12:57:19 +0300 Subject: [PATCH 5/5] [DE PE SSE] Fix getting of isDesktopApp --- apps/common/main/lib/util/Tip.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/common/main/lib/util/Tip.js b/apps/common/main/lib/util/Tip.js index f360ea948..4d9c496be 100644 --- a/apps/common/main/lib/util/Tip.js +++ b/apps/common/main/lib/util/Tip.js @@ -112,9 +112,7 @@ if (!me.options.keepvisible && !me.options.hideonclick && me.tip().is(':visible')) me.hide(); }}); - Common.NotificationCenter.on('app:ready', function (mode) { - me.isDesktopApp = mode.isDesktopApp; - }); + this.isDesktopApp = Common.Controllers.Desktop.isActive(); }, mousemove: function (e) {