From 64d262ff775be02ad15946ea8307aadc6de1e2dc Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 1 Jul 2011 22:10:55 +0530 Subject: [PATCH] up and down keys for navigation --- edgware/static/js/files/browse.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/edgware/static/js/files/browse.js b/edgware/static/js/files/browse.js index 076f17e..6225e2b 100644 --- a/edgware/static/js/files/browse.js +++ b/edgware/static/js/files/browse.js @@ -80,6 +80,17 @@ $(function() { }, "json"); }); + $(document).keydown(function(e) { + var k = e.keyCode; + if (k==40) { + e.preventDefault(); + moveListDown(); + } + if (k==38) { + e.preventDefault(); + moveListUp(); + } + }); $(window).resize(function() { var minuser = 400; @@ -179,3 +190,19 @@ function getSelectedIds() { }); return ids; } + +function moveListDown() { + var currentIndex = $('.selectedItem').index(".fileItem"); + if (currentIndex == $('.fileItem').length) { + return; + } + $('.fileItem').eq(currentIndex + 1).click(); +} + +function moveListUp() { + var currentIndex = $('.selectedItem').index(".fileItem"); + if (currentIndex == 0) { + return; + } + $('.fileItem').eq(currentIndex - 1).click(); +}