From b7bdeb592e8eb4a6c29fffbc6c664d917daa4907 Mon Sep 17 00:00:00 2001
From: Cornelius <cornelius.amzar@bsz-bw.de>
Date: Wed, 18 Nov 2015 15:20:31 +0100
Subject: [PATCH] Keyboard Shortcuts in detail view

One can navigate using the left and right arrow keys. Press ctrl + arrow up to get back to result list.
---
 themes/bootstrap3/js/common.js | 41 ++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index b41b31af333..0fb4f4ccf54 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(); });
-- 
GitLab