Better keyboard navigation
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 09:00:20 +0000 (02:00 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 19:21:21 +0000 (12:21 -0700)
Up on first item (or no selection) cancels the selection.
Down on last item doesn't move selection.

horde/js/KeyNavList.js

index 026aba6..4a41d15 100644 (file)
@@ -245,24 +245,18 @@ var KeyNavList = Class.create({
 
     markPrevious: function()
     {
-        var elt;
-
-        if (this.selected) {
-            elt = this.selected.previous();
-        }
-
-        this.markSelected((!this.selected || !elt) ? this.div.down().childElements().last() : elt);
+        this.markSelected(this.selected ? this.selected.previous() : null);
     },
 
     markNext: function()
     {
-        var elt;
+        var elt = this.selected
+            ? this.selected.next()
+            : this.div.down().childElements().first();
 
-        if (this.selected) {
-            elt = this.selected.next();
+        if (elt) {
+            this.markSelected(elt);
         }
-
-        this.markSelected((!this.selected || !elt) ? this.div.down().childElements().first() : elt);
     },
 
     getCurrentEntry: function()