Stop failing if there is no previous/next to go to
authorJef van Schendel <mail@jefvanschendel.nl>
Mon, 5 Mar 2012 18:27:26 +0000 (19:27 +0100)
committerJef van Schendel <mail@jefvanschendel.nl>
Mon, 5 Mar 2012 18:27:26 +0000 (19:27 +0100)
mediagoblin/static/js/keyboard_navigation.js

index 83d339ff3271efb7bf8c7d25866b69c4cb32d988..d4039a3c3ac17b8087eea84081fc4f5e18a3c399 100644 (file)
 $(document).keydown(function(event){
   switch(event.which){
     case 37:
-      window.location = $('.navigation_left').attr('href');
+      if($('a.navigation_left').length) {
+        window.location = $('a.navigation_left').attr('href');
+      }
       break;
     case 39:
-      window.location = $('.navigation_right').attr('href');
+      if($('a.navigation_right').length) {
+      window.location = $('a.navigation_right').attr('href');
+      }
       break;
   }
 });