diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index f3cf9f169..92c8112f2 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -51,36 +51,43 @@ Common.UI.HintManager = new(function() { _arrLetters = [], _isAlt = false, _hintVisible = false, - _currentLevel = -1, + _currentLevel = 0, _controls = [], _currentControls = [], - _currentHints = []; + _currentHints = [], + _inputLetters = ''; - var _showHints = function() { - _hintVisible = !_hintVisible; - if (_hintVisible) { + var _showHints = function(type) { + if (type === 'next') { + _removeHints(); _currentLevel++; _getHints(); - } else { + } else if (type === 'prev') { _removeHints(); _currentLevel--; + _getHints(); + if (_currentLevel === -1) + _hintVisible = false; + } else { + _hintVisible = !_hintVisible; + _getHints(); } }; var _getControls = function() { - if (!_controls[_currentLevel + 1]) { - _controls[_currentLevel + 1] = $('[data-hint=' + (_currentLevel + 1) + ']').toArray(); - if (_currentLevel==0 && !_controls[_currentLevel]) + if (!_controls[_currentLevel]) { + _controls[_currentLevel] = $('[data-hint=' + (_currentLevel) + ']').toArray(); + if (_currentLevel === 0 && !_controls[_currentLevel]) _controls[_currentLevel] = $('[data-hint=0]').toArray(); } _currentControls = []; var arr = []; - if (_currentLevel==0) { + if (_currentLevel === 0) { arr = arr.concat(_controls[_currentLevel]); !$('.toolbar-fullview-panel').is(':visible') && (arr = arr.concat(_controls[_currentLevel+1])); } else - arr = _controls[_currentLevel+1]; + arr = _controls[_currentLevel]; var visibleItems = arr.filter(function (item) { return $(item).is(':visible'); }); @@ -97,7 +104,7 @@ Common.UI.HintManager = new(function() { } } } - console.log(_arrLetters); + console.log(visibleItems); visibleItems.forEach(function (item, index) { var el = $(item); el.attr('data-hint-title', _arrLetters[index].toUpperCase()); @@ -122,13 +129,14 @@ Common.UI.HintManager = new(function() { else if (direction === 'left') hint.css({left: offset.left - 18, top: offset.top + (item.outerHeight()-20)/2}); else if (direction === 'left-bottom') - hint.css({left: offset.left - 8, top: offset.top + item.outerHeight() - 12}); + hint.css({left: offset.left - 8, top: offset.top - item.outerHeight()}); else hint.css({left: offset.left + (item.outerWidth() - 20)/2, top: offset.top + item.outerHeight() - 3}); $(document.body).append(hint); _currentHints.push(hint); }); + console.log(_currentHints); }; var _removeHints = function() { @@ -145,32 +153,38 @@ Common.UI.HintManager = new(function() { $(document).on('keyup', function(e) { if (e.keyCode == Common.UI.Keys.ALT &&_isAlt) { e.preventDefault(); - _showHints(); + _showHints('current'); } _isAlt = false; }); $(document).on('keydown', function(e) { if (_hintVisible) { if (e.keyCode == Common.UI.Keys.ESC ) { - _showHints(); + _showHints('prev'); } else if ((e.keyCode > 47 && e.keyCode < 58 || e.keyCode > 64 && e.keyCode < 91) && e.key) { var curr; + _inputLetters = _inputLetters + String.fromCharCode(e.keyCode).toUpperCase(); for (var i = 0; i < _currentControls.length; i++) { var item = _currentControls[i]; - if (item.attr('data-hint-title').charCodeAt(0) == e.keyCode) { // for latin chars + if (item.attr('data-hint-title') === _inputLetters) { curr = item; break; } } if (curr) { - _showHints(); + console.log(curr); curr && curr.trigger(jQuery.Event('click', {which: 1})); + _showHints('next'); } } e.preventDefault(); } _isAlt = (e.keyCode == Common.UI.Keys.ALT); + if (_isAlt) { + _inputLetters = ''; + } + console.log(_currentLevel); }); }; diff --git a/apps/common/main/lib/component/MenuItem.js b/apps/common/main/lib/component/MenuItem.js index ab04de056..9c2617f70 100644 --- a/apps/common/main/lib/component/MenuItem.js +++ b/apps/common/main/lib/component/MenuItem.js @@ -102,13 +102,15 @@ define([ toggleGroup : null, iconCls : '', menu : null, - canFocused : true + canFocused : true, + dataHint : '', + dataHintDirection: '' }, tagName : 'li', template: _.template([ - ' tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; %> >', + ' tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; if(!_.isUndefined(options.dataHint)) { %> data-hint="<%= options.dataHint %>" <% }; if(!_.isUndefined(options.dataHintDirection)) { %> data-hint-direction="<%= options.dataHintDirection %>" <% }; %> >', '<% if (!_.isEmpty(iconCls)) { %>', '', '<% } %>', diff --git a/apps/documenteditor/main/app/template/LeftMenu.template b/apps/documenteditor/main/app/template/LeftMenu.template index 18e31b081..322e64dc8 100644 --- a/apps/documenteditor/main/app/template/LeftMenu.template +++ b/apps/documenteditor/main/app/template/LeftMenu.template @@ -1,14 +1,14 @@
- + - - + + - - - - + + + +
diff --git a/apps/documenteditor/main/app/template/RightMenu.template b/apps/documenteditor/main/app/template/RightMenu.template index 1089ab517..8add4429c 100644 --- a/apps/documenteditor/main/app/template/RightMenu.template +++ b/apps/documenteditor/main/app/template/RightMenu.template @@ -23,15 +23,15 @@
- - - - - - - - - - + + + + + + + + + +
\ No newline at end of file diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index ffdd1b0fa..9b0448988 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -88,7 +88,9 @@ define([ el : $markup.elementById('#fm-btn-save'), action : 'save', caption : this.btnSaveCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); if ( !!this.options.miSave ) { @@ -100,42 +102,54 @@ define([ el : $markup.elementById('#fm-btn-edit'), action : 'edit', caption : this.btnToEditCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miDownload = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-download'), action : 'saveas', caption : this.btnDownloadCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miSaveCopyAs = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-save-copy'), action : 'save-copy', caption : this.btnSaveCopyAsCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miSaveAs = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-save-desktop'), action : 'save-desktop', caption : this.btnSaveAsCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miPrint = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-print'), action : 'print', caption : this.btnPrintCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miRename = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-rename'), action : 'rename', caption : this.btnRenameCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); if ( !!this.options.miRename ) { @@ -147,7 +161,9 @@ define([ el : $markup.elementById('#fm-btn-protect'), action : 'protect', caption : this.btnProtectCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); if ( !!this.options.miProtect ) { @@ -159,35 +175,45 @@ define([ el : $markup.elementById('#fm-btn-recent'), action : 'recent', caption : this.btnRecentFilesCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miNew = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-create'), action : 'new', caption : this.btnCreateNewCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miAccess = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-rights'), action : 'rights', caption : this.btnRightsCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miHistory = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-history'), action : 'history', caption : this.btnHistoryCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.miHelp = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-help'), action : 'help', caption : this.btnHelpCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }); this.items = []; @@ -196,7 +222,9 @@ define([ el : $markup.elementById('#fm-btn-return'), action : 'back', caption : this.btnCloseMenuCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }), this.miSave, this.miEdit, @@ -212,7 +240,9 @@ define([ el : $markup.elementById('#fm-btn-info'), action : 'info', caption : this.btnInfoCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }), this.miAccess, this.miHistory, @@ -220,7 +250,9 @@ define([ el : $markup.elementById('#fm-btn-settings'), action : 'opts', caption : this.btnSettingsCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }), this.miHelp, new Common.UI.MenuItem({ @@ -228,7 +260,9 @@ define([ // el : _get_el('fm-btn-back'), action : 'exit', caption : this.btnBackCaption, - canFocused: false + canFocused: false, + dataHint: 1, + dataHintDirection: 'right' }) );