Add keyboard shortcuts and "anti-cache-postfix" for the main.js #26

This commit is contained in:
Aaron Fischer 2017-04-25 23:32:56 +02:00
parent 4bb8dfb2e9
commit 5bfb5c1c2f
3 changed files with 34 additions and 18 deletions

View file

@ -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;
}
});
});

View file

@ -4,12 +4,13 @@
<div class="btn-group pull-right clearfix" role="group">
{% if next-image %}
<a class="btn btn-secondary" href="/show/{{ next-image.id }}">
<a class="btn btn-secondary" href="/show/{{ next-image.id }}" id="next-image">
{% else %}
<a class="btn btn-secondary disabled" href="#">
{% endif %}
<span class="fa fa-arrow-left"></span>
Neuer
<span class="fa fa-arrow-left"></span> Neuer
</a>
<a class="btn btn-secondary" href="/">
@ -18,12 +19,12 @@
</a>
{% if prev-image %}
<a class="btn btn-secondary" href="/show/{{ prev-image.id }}">
<a class="btn btn-secondary" href="/show/{{ prev-image.id }}" id="prev-image">
{% else %}
<a class="btn btn-secondary disabled" href="#">
{% endif %}
Älter
<span class="fa fa-arrow-right"></span>
Älter <span class="fa fa-arrow-right"></span>
</a>
</div>

View file

@ -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" %}
</body>
</html>