Commit 251bb8bf authored by Aria Givi's avatar Aria Givi

results can now be chosen, tabbing between anchor elements still missing

parent 2396367e
var ctrlInfo = false; // Flag used for checking if the user was shown the keyboard control information
/* var currentElement = [
["Results", false]
];
*/
var currentResultIndex = 1; // stores result which was focused last
document.onkeydown = checkKey;
function checkKey(e) {
$(document).on('keydown', function(e) {
e = e || window.event;
// Check for TAB keypress
// Check for TAB keypress
if (e.keyCode == '9') {
e.preventDefault();
tabKeyPressed($(document.activeElement));
tabKeyPressed();
} else if (e.keyCode == '13') {
enterKeyPressed();
}
}
});
function tabKeyPressed() {
if(!ctrlInfo) {
......@@ -20,16 +26,22 @@ function tabKeyPressed() {
}
}
function enterKeyPressed() {
if($(":focus").hasClass("result")) {
//$(":focus").children("a").focus();
console.log($(":focus").children("a"));
}
}
function showInfoBox() {
$("#keyboard-ctrl-info").show();
$("#keyboard-ctrl-info").focus();
infoBox = $("#keyboard-ctrl-info");
infoBox.show();
infoBox.focus();
}
function focusNextElement(currentFocus) {
if(currentFocus.hasClass("result")) {
focusNextResult(currentFocus);
} else if(false) {
} else {
focusResult();
}
......@@ -42,8 +54,9 @@ function focusResult() {
}
function focusNextResult(currentFocus) {
if(!currentFocus.next().focus()) {
alert("test");
if(currentFocus.next().length > 0) {
currentFocus.next().focus();
} else {
$("div[.result]").first().focus();
}
console.log(currentFocus);
}
\ 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