From db54743eca96e9e21a61bceb414d0bb8a515b976 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 23 Jun 2021 18:41:38 +0300 Subject: [PATCH] Hint Manager: add direction exceptions for filter buttons, add ability to add specific hints to buttons --- apps/common/main/lib/component/Button.js | 15 ++++--- apps/common/main/lib/component/HintManager.js | 45 +++++++++++++++++-- apps/documenteditor/main/app/view/Toolbar.js | 6 ++- .../main/app/view/Toolbar.js | 6 ++- .../main/app/template/StatusBar.template | 8 ++-- .../main/app/view/Toolbar.js | 6 ++- 6 files changed, 65 insertions(+), 21 deletions(-) diff --git a/apps/common/main/lib/component/Button.js b/apps/common/main/lib/component/Button.js index 400d5554f..64d1d2067 100644 --- a/apps/common/main/lib/component/Button.js +++ b/apps/common/main/lib/component/Button.js @@ -194,7 +194,7 @@ define([ '<% } %>'; var templateHugeCaption = - '' + - '', '<% } else if (split == false) {%>', '
', - '', - '', @@ -356,7 +356,8 @@ define([ style : me.style, dataHint : me.options.dataHint, dataHintDirection: me.options.dataHintDirection, - dataHintOffset: me.options.dataHintOffset + dataHintOffset: me.options.dataHintOffset, + dataHintTitle: me.options.dataHintTitle })); if (me.menu && _.isObject(me.menu) && _.isFunction(me.menu.render)) diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index 41dbfebad..029cd6601 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -49,6 +49,7 @@ if (Common.UI === undefined) { Common.UI.HintManager = new(function() { var _lang = 'en', _arrAlphabet = [], + _arrEnAlphabet = [], _isAlt = false, _hintVisible = false, _currentLevel = 0, @@ -132,9 +133,33 @@ Common.UI.HintManager = new(function() { } else { _arrLetters = [..._arrAlphabet]; } - visibleItems.forEach(function (item, index) { + var usedLetters = []; + if ((_currentSection.nodeType === 9 && $(['data-hint-title']).length > 0) || + (_currentSection.nodeType !== 9 && _currentSection.find('[data-hint-title]').length > 0)) { + visibleItems.forEach(function (item) { + var el = $(item); + var title = el.attr('data-hint-title'); + if (title) { + var ind = _arrEnAlphabet.indexOf(title.toLowerCase()); + usedLetters.push(ind); + if (_lang !== 'en') { + console.log(_arrLetters[ind]); + el.attr('data-hint-title', _arrLetters[ind].toUpperCase()); + } + } + }); + } + var index = 0; + visibleItems.forEach(function (item) { var el = $(item); - el.attr('data-hint-title', _arrLetters[index].toUpperCase()); + if (usedLetters.indexOf(index) !== -1) { + index++; + } + var title = el.attr('data-hint-title'); + if (!title) { + el.attr('data-hint-title', _arrLetters[index].toUpperCase()); + index++; + } _currentControls.push(el); }); }; @@ -143,9 +168,20 @@ Common.UI.HintManager = new(function() { if (_currentControls.length === 0) _getControls(); _currentControls.forEach(function(item, index) { - if (!item.hasClass('disabled')) { + if (!item.hasClass('disabled') && !item.parent().hasClass('disabled')) { var hint = $('
' + item.attr('data-hint-title') + '
'); var direction = item.attr('data-hint-direction'); + // exceptions + if (window.SSE && _currentSection.nodeType !== 9 && + _currentSection.prop('id') === 'toolbar' && item.closest('.panel').attr('data-tab') === 'data') { + if (item.parent().hasClass('slot-sortdesc') || item.parent().hasClass('slot-btn-setfilter')) { + direction = 'top'; + item.attr('data-hint-direction', 'top'); + } else if (item.parent().hasClass('slot-btn-clear-filter') || item.parent().hasClass('slot-sortasc')) { + direction = 'bottom'; + item.attr('data-hint-direction', 'bottom'); + } + } var offsets = item.attr('data-hint-offset'); var applyOffset = offsets === 'big' ? 6 : (offsets === 'medium' ? 4 : (offsets === 'small' ? 2 : 0)); if (applyOffset) { @@ -242,7 +278,7 @@ Common.UI.HintManager = new(function() { _setCurrentSection('esc'); _showHints(); } - } else if ((e.keyCode > 47 && e.keyCode < 58 || e.keyCode > 64 && e.keyCode < 91) && e.key) { + } else { var curr; _inputLetters = _inputLetters + String.fromCharCode(e.keyCode).toUpperCase(); for (var i = 0; i < _currentControls.length; i++) { @@ -299,6 +335,7 @@ Common.UI.HintManager = new(function() { var _getAlphabetLetters = function () { Common.Utils.loadConfig('../../common/main/resources/alphabetletters/alphabetletters.json', function (langsJson) { _arrAlphabet = langsJson[_lang]; + _arrEnAlphabet = langsJson['en']; }); }; diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 75878ea11..d82779d9a 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -159,7 +159,8 @@ define([ cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-copy', dataHint: '1', - dataHintDirection: 'top' + dataHintDirection: 'top', + dataHintTitle: 'C' }); this.toolbarControls.push(this.btnCopy); @@ -168,7 +169,8 @@ define([ cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-paste', dataHint: '1', - dataHintDirection: 'bottom' + dataHintDirection: 'bottom', + dataHintTitle: 'P' }); this.paragraphControls.push(this.btnPaste); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index e43aae094..9bbbe3464 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -221,7 +221,8 @@ define([ iconCls: 'toolbar__icon btn-copy', lock: [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], dataHint: '1', - dataHintDirection: 'top' + dataHintDirection: 'top', + dataHintTitle: 'C' }); me.slideOnlyControls.push(me.btnCopy); @@ -231,7 +232,8 @@ define([ iconCls: 'toolbar__icon btn-paste', lock: [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides], dataHint: '1', - dataHintDirection: 'bottom' + dataHintDirection: 'bottom', + dataHintTitle: 'P' }); me.paragraphControls.push(me.btnPaste); diff --git a/apps/spreadsheeteditor/main/app/template/StatusBar.template b/apps/spreadsheeteditor/main/app/template/StatusBar.template index 001aa7bdb..7f21845bd 100644 --- a/apps/spreadsheeteditor/main/app/template/StatusBar.template +++ b/apps/spreadsheeteditor/main/app/template/StatusBar.template @@ -1,10 +1,10 @@
- - - - + + + +
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 961615ec4..23963af8e 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -181,7 +181,8 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-copy', dataHint: '1', - dataHintDirection: 'top' + dataHintDirection: 'top', + dataHintTitle: 'C' }); me.btnPaste = new Common.UI.Button({ @@ -190,7 +191,8 @@ define([ iconCls : 'toolbar__icon btn-paste', lock : [/*_set.editCell,*/ _set.coAuth, _set.lostConnect], dataHint: '1', - dataHintDirection: 'bottom' + dataHintDirection: 'bottom', + dataHintTitle: 'P' }); me.btnUndo = new Common.UI.Button({