issue93, jump to next/prev photo with cursor keys
authorAndreas Unterkircher <unki@netshadow.at>
Sun, 6 Jan 2008 08:31:54 +0000 (09:31 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Sun, 6 Jan 2008 08:31:54 +0000 (09:31 +0100)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.js
themes/default/templates/single_photo.tpl

index 26e50903c63b38cb78532dfe25bc53280ced1ff9..1b1f05d5ca4e1ec8f6f39ad54f56453991dd8198 100644 (file)
@@ -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 = '';
index 4e1a44e6ed74b5e661ca1a1d2fe28c0a2fb3b888..c87118a0328db8dd26d92732ccc2043adb6ad16e 100644 (file)
@@ -48,7 +48,7 @@
    <hr>
    { if $prev_img }
     <u><img src="resources/photo.png" alt="photo icon" />&nbsp;Previous:</u><br />
-    <a href="{$previous_url}" onclick="click(this);">
+    <a href="{$previous_url}" onclick="click(this);" id="prev_link">
      <img src="phpfspot_img.php?idx={$prev_img}&amp;width={$mini_width}" /><br />
     </a>
    { /if}