diff options
author | Go MAEDA <maeda@farend.jp> | 2018-10-04 13:27:09 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-10-04 13:27:09 +0000 |
commit | 7516823617108bd23d0004143f5602dad7d74527 (patch) | |
tree | 6643000f6f60875dd67c6c352dab3e03d4191758 /public/javascripts/application.js | |
parent | 7d615fd516c60c0c448d3a35f56641e14b463c61 (diff) | |
download | redmine-7516823617108bd23d0004143f5602dad7d74527.tar.gz redmine-7516823617108bd23d0004143f5602dad7d74527.zip |
Adds file preview prev/next navigation with arrow keys (#29395).
Patch by Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@17569 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public/javascripts/application.js')
-rw-r--r-- | public/javascripts/application.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 5221152fb..76f65bf4c 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -756,6 +756,36 @@ function setupTabs() { } } +function setupFilePreviewNavigation() { + // only bind arrow keys when preview navigation is present + const element = $('.pagination.filepreview').first(); + if (element) { + + const handleArrowKey = function(selector, e){ + const href = $(element).find(selector).attr('href'); + if (href) { + window.location = href; + e.preventDefault(); + } + }; + + $(document).keydown(function(e) { + if(e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return; + switch(e.key) { + case 'ArrowLeft': + handleArrowKey('.previous a', e); + break; + + case 'ArrowRight': + handleArrowKey('.next a', e); + break; + } + }); + } +} + + + function hideOnLoad() { $('.hol').hide(); } @@ -879,3 +909,4 @@ $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); $(document).ready(defaultFocus); $(document).ready(setupTabs); +$(document).ready(setupFilePreviewNavigation); |