Skip to content
Snippets Groups Projects
Commit 330ffb2c authored by Aria Givi's avatar Aria Givi
Browse files

added possibility to tab through result-divs

parent ba5088d9
No related branches found
No related tags found
2 merge requests!1453Development,!1447Resolve "Make result page keyboard maneuverable"
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment