diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index b41b31af333f114be6bc3e71bfc8893798da5930..0fb4f4ccf54925b2a2204a48aa57615f4c9ce88b 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -351,6 +351,45 @@ function setupAutocomplete() { }); } +/** + * Handle arrow keys to jump to next record + * @returns {undefined} + */ +function keyboardShortcuts() { + if ($('.pager').length > 0) { + $(window).keydown(function(e) { +// console.log(e.keyCode); + $target = null; + switch (e.keyCode) { + case 37: // left arrow key + e.preventDefault(); + $target = $('.pager').find('a.previous'); + if ($target.length > 0) { + $target[0].click(); + return; + } + case 38: // up arrow key + e.preventDefault(); + if (e.ctrlKey) { + $target = $('.pager').find('a.backtosearch'); + if ($target.length > 0) { + $target[0].click(); + return; + } + } + case 39: //right arrow key + e.preventDefault(); + $target = $('.pager').find('a.next'); + if ($target.length > 0) { + $target[0].click(); + return; + } + case 40: // down arrow key + } + }); + } +} + $(document).ready(function() { // Setup search autocomplete setupAutocomplete(); @@ -358,6 +397,8 @@ $(document).ready(function() { setupBacklinks() ; // Off canvas setupOffcanvas(); + // Keyboard shortcuts in detail view + keyboardShortcuts(); // support "jump menu" dropdown boxes $('select.jumpMenu').change(function(){ $(this).parent('form').submit(); });