From 5bfb5c1c2f84f4f98fa4812157fcc882c7e07bff Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Tue, 25 Apr 2017 23:32:56 +0200 Subject: [PATCH] Add keyboard shortcuts and "anti-cache-postfix" for the main.js #26 --- resources/public/js/main.js | 15 ++++++++++++++ resources/templates/detail.html | 35 +++++++++++++++++---------------- resources/templates/layout.html | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/resources/public/js/main.js b/resources/public/js/main.js index 5800c97..c72d6df 100644 --- a/resources/public/js/main.js +++ b/resources/public/js/main.js @@ -3,4 +3,19 @@ $(function () { var page = $(e.target).val(); window.location = '/page/' + page; }); + + $(document).on('keydown', function(e) { + switch (e.keyCode) { + case 76: // l + case 39: // --> + var prevUrl = $('#prev-image').attr('href'); + if (prevUrl !== undefined) window.location = prevUrl; + break; + case 72: // h + case 37: // <-- + var nextUrl = $('#next-image').attr('href'); + if (nextUrl !== undefined) window.location = nextUrl; + break; + } + }); }); diff --git a/resources/templates/detail.html b/resources/templates/detail.html index 2cf8f57..7f5f9df 100644 --- a/resources/templates/detail.html +++ b/resources/templates/detail.html @@ -4,27 +4,28 @@
{% if next-image %} - - {% else %} - - {% endif %} - - Neuer - + + {% else %} + + {% endif %} - + Neuer + + + + Gallerie - + - {% if prev-image %} - - {% else %} - - {% endif %} - Älter - - + {% if prev-image %} + + {% else %} + + {% endif %} + + Älter +
diff --git a/resources/templates/layout.html b/resources/templates/layout.html index c8125f7..d222e5e 100644 --- a/resources/templates/layout.html +++ b/resources/templates/layout.html @@ -91,7 +91,7 @@ {% script "/assets/jquery/jquery.min.js" %} {% script "/assets/tether/dist/js/tether.min.js" %} {% script "/assets/bootstrap/js/bootstrap.min.js" %} - {% script "/js/main.js" %} + {% script "/js/main.js?v2" %}