Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cursor key navigation through search results
  • Loading branch information
aclement committed Jan 24, 2012
1 parent 4c55202 commit 2f13001
Showing 1 changed file with 28 additions and 1 deletion.
Expand Up @@ -71,6 +71,32 @@ var OpenResourceDialog = dojo.declare("orion.widgets.OpenResourceDialog", [dijit
}
}
});
dojo.connect(this,"onKeyPress",this,function(evt) {
var links, currentFocus, currentSelectionIndex;
if (evt.keyCode === dojo.keys.DOWN_ARROW && this.results) {
links = dojo.query("a", this.results);
currentFocus = dijit.getFocus();
currentSelectionIndex = links.indexOf(currentFocus.node);
if (currentSelectionIndex === -1) {
dijit.focus(links[0]);
} else if (currentSelectionIndex<links.length) {
dijit.focus(links[currentSelectionIndex+1]);
}
dojo.stopEvent(evt);
} else if (evt.keyCode === dojo.keys.UP_ARROW) {
links = dojo.query("a", this.results);
currentFocus = dijit.getFocus();
currentSelectionIndex = links.indexOf(currentFocus.node);
if (currentSelectionIndex < 1) {
// jump to input element
var text = this.resourceName && this.resourceName.get("textbox");
dijit.focus(text);
} else if (currentSelectionIndex > 0) {
dijit.focus(links[currentSelectionIndex-1]);
}
dojo.stopEvent(evt);
}
});
dojo.connect(this, "onMouseUp", function(e) {
// WebKit focuses <body> after link is clicked; override that
e.target.focus();
Expand Down Expand Up @@ -132,4 +158,5 @@ var OpenResourceDialog = dojo.declare("orion.widgets.OpenResourceDialog", [dijit

});
return OpenResourceDialog;
});
});

0 comments on commit 2f13001

Please sign in to comment.