Skip to content
Permalink
Browse files

refactored keyboard handling to a switch statement for clarity.

  • Loading branch information...
dbolter committed Nov 13, 2008
1 parent 976b9b5 commit ed4f58c6d3c914baafaf07ab1d168e6c199b8693
Showing with 12 additions and 12 deletions.
  1. +12 −12 ui/ui.accordion.js
@@ -106,18 +106,18 @@ $.widget("ui.accordion", {
var currentIndex = this.options.headers.index(e.target);
var toFocus = false;

if (e.keyCode == keyCode.RIGHT || e.keyCode == keyCode.DOWN){

toFocus = this.options.headers[(currentIndex + 1) % length];

} else if (e.keyCode == keyCode.LEFT || e.keyCode == keyCode.UP) {

toFocus = this.options.headers[(currentIndex - 1 + length) % length];

} else if (e.keyCode == keyCode.SPACE || e.keyCode == keyCode.ENTER) {

return clickHandler.call(this.element[0], { target: e.target });

switch(e.keyCode) {
case keyCode.RIGHT:
case keyCode.DOWN:
toFocus = this.options.headers[(currentIndex + 1) % length];
break;
case keyCode.LEFT:
case keyCode.UP:
toFocus = this.options.headers[(currentIndex - 1 + length) % length];
break;
case keyCode.SPACE:
case keyCode.ENTER:
return clickHandler.call(this.element[0], { target: e.target });
}

if (toFocus) {

0 comments on commit ed4f58c

Please sign in to comment.
You can’t perform that action at this time.