From 248141f2861881843e972c6f5f8a9ad4f71b06ef Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sun, 6 Jan 2008 09:31:54 +0100 Subject: [PATCH] issue93, jump to next/prev photo with cursor keys Signed-off-by: Andreas Unterkircher --- phpfspot.js | 32 +++++++++++++++++++++++ themes/default/templates/single_photo.tpl | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/phpfspot.js b/phpfspot.js index 26e5090..1b1f05d 100644 --- a/phpfspot.js +++ b/phpfspot.js @@ -418,6 +418,38 @@ function update_sort_order(obj) } // update_sort_order() +function keyDown(e) { + var evt = (e) ? e:(window.event) ? window.event:null; + + if(evt) { + var key = (evt.charCode) ? evt.charCode : + ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)); + + + if(key == 37) /* left curosr */ { + if(document.getElementById('prev_link')) { + var prev_link = document.getElementById('prev_link').href; + window.location.href = prev_link; + } + return; + } + if(key == 38) /* up cursor */ { + } + if(key == 39) /* right curosr */ { + if(document.getElementById('next_link')) { + var next_link = document.getElementById('next_link').href; + window.location.href = next_link; + } + return; + } + } +} + +document.onkeydown=keyDown; +if(document.layers) { + document.captureEvents(Event.KEYDOWN); +} + var startup = 1; var calendar_shown = 0; var calendar_mode = ''; diff --git a/themes/default/templates/single_photo.tpl b/themes/default/templates/single_photo.tpl index 4e1a44e..c87118a 100644 --- a/themes/default/templates/single_photo.tpl +++ b/themes/default/templates/single_photo.tpl @@ -48,7 +48,7 @@
{ if $prev_img } photo icon Previous:
- +
{ /if} -- 2.25.1