Commit 330ffb2c authored by Aria Givi's avatar Aria Givi

added possibility to tab through result-divs

parent ba5088d9
......@@ -3,18 +3,39 @@ $(document).ready(function () {
$('.no-js').addClass('hide');
});
document.onkeydown = checkKey;
// Flag used for checking if the user was shown the keyboard control information
ctrlInfo = false;
currentResultIndex = 1;
document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
if (e.keyCode == '9') {
e.preventDefault();
$("#keyboard-ctrl-info").show();
$("#keyboard-ctrl-info").focus();
guideThroughMenu($(document.activeElement));
}
}
function guideThroughMenu(focused) {
if(!ctrlInfo) {
ctrlInfo = true;
showInfoBox();
} else {
focusNextResult();
}
}
function showInfoBox() {
$("#keyboard-ctrl-info").show();
$("#keyboard-ctrl-info").focus();
}
function focusNextResult() {
$("div[data-index='"+ currentResultIndex + "'").focus();
n = $(".result").length;
currentResultIndex = 1 + currentResultIndex % n;
console.log(currentResultIndex + " - " + n);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment