diff options
author | Stefan Giehl <stefan@piwik.org> | 2017-11-30 06:41:48 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-11-30 06:41:48 +0300 |
commit | af3a79c055bfe2c5778b5827ba3d165674315f4b (patch) | |
tree | a0e4432d5be6318209f968536dcaf1fa2494a86b /plugins/CoreHome/javascripts | |
parent | e80aeb9ccecc2f175176d8920d241a93de168920 (diff) |
Show shortcut help screen when pressing `?` (#12283)
* Adds help screen for shortcuts
* Dynamically create shortcut summary by using new js method piwikHelper.registerShortcut
* Update CHANGELOG.md
Diffstat (limited to 'plugins/CoreHome/javascripts')
-rw-r--r-- | plugins/CoreHome/javascripts/calendar.js | 2 | ||||
-rwxr-xr-x | plugins/CoreHome/javascripts/corehome.js | 30 | ||||
-rw-r--r-- | plugins/CoreHome/javascripts/zen-mode.js | 2 |
3 files changed, 30 insertions, 4 deletions
diff --git a/plugins/CoreHome/javascripts/calendar.js b/plugins/CoreHome/javascripts/calendar.js index a1b89ae12d..ca52056ac0 100644 --- a/plugins/CoreHome/javascripts/calendar.js +++ b/plugins/CoreHome/javascripts/calendar.js @@ -77,7 +77,7 @@ }; }; - Mousetrap.bind('d', function(event) { + piwikHelper.registerShortcut('d', _pk_translate('CoreHome_ShortcutCalendar'), function(event) { if (event.altKey) { return; } diff --git a/plugins/CoreHome/javascripts/corehome.js b/plugins/CoreHome/javascripts/corehome.js index b8951ed4c4..76f6554573 100755 --- a/plugins/CoreHome/javascripts/corehome.js +++ b/plugins/CoreHome/javascripts/corehome.js @@ -76,15 +76,41 @@ $( document ).ready(function() { - $('.accessibility-skip-to-content').click(function(e){ + $('.accessibility-skip-to-content').click(function(e){ $('a[name="main"]').attr('tabindex', -1).focus(); $(window).scrollTo($('a[name="main"]')); }); $("nav .activateTopMenu").sideNav({ closeOnClick: true, - edge: 'right', + edge: 'right' }); $('select').material_select(); + + piwikHelper.registerShortcut('?', _pk_translate('CoreHome_ShortcutHelp') , function (event) { + // don't open if an modal is already shown + if (event.altKey || $('.modal.open').length) { + return; + } + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; // IE + } + + var list = $('#shortcuthelp dl'); + list.empty(); + + var keys = Object.keys(piwikHelper.shortcuts).sort(); + + jQuery.each(keys, function(i, key) { + if (piwikHelper.shortcuts.hasOwnProperty(key)) { + list.append($('<dt />').text(key)); + list.append($('<dd />').text(piwikHelper.shortcuts[key])); + } + }); + + piwikHelper.modalConfirm('#shortcuthelp'); + }); });
\ No newline at end of file diff --git a/plugins/CoreHome/javascripts/zen-mode.js b/plugins/CoreHome/javascripts/zen-mode.js index 145e4d4e88..fe052210f9 100644 --- a/plugins/CoreHome/javascripts/zen-mode.js +++ b/plugins/CoreHome/javascripts/zen-mode.js @@ -14,7 +14,7 @@ $(function () { } } - Mousetrap.bind('z', function (event) { + piwikHelper.registerShortcut('z', _pk_translate('CoreHome_ShortcutZenMode'), function (event) { if (event.altKey) { return; } |