|
|
@ -2,21 +2,14 @@ var currentIndex = 0 |
|
|
|
|
|
|
|
|
|
|
|
function nav(offset) { |
|
|
|
function nav(offset) { |
|
|
|
var items = document.querySelectorAll('.items:not(.disabled)') |
|
|
|
var items = document.querySelectorAll('.items:not(.disabled)') |
|
|
|
if (offset === -1) { |
|
|
|
|
|
|
|
if (currentIndex <= 0) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (offset === 1) { |
|
|
|
|
|
|
|
if (currentIndex >= items.length - 1) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
console.error(`nav called with unknown offset: ${offset}`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentIndex += offset |
|
|
|
currentIndex += offset |
|
|
|
|
|
|
|
if (currentIndex < 0) { |
|
|
|
|
|
|
|
currentIndex += items.length |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (currentIndex >= items.length) { |
|
|
|
|
|
|
|
currentIndex -= items.length |
|
|
|
|
|
|
|
} |
|
|
|
items[currentIndex].focus() |
|
|
|
items[currentIndex].focus() |
|
|
|
items[currentIndex].addEventListener('keydown', handleKeyDown) |
|
|
|
items[currentIndex].addEventListener('keydown', handleKeyDown) |
|
|
|
} |
|
|
|
} |
|
|
|