diff --git a/resources/js/keyboardNavigation.js b/resources/js/keyboardNavigation.js new file mode 100644 index 0000000000000000000000000000000000000000..4b52bc439f20d972846f0012ec2458cc6cf5be59 --- /dev/null +++ b/resources/js/keyboardNavigation.js @@ -0,0 +1,49 @@ +var ctrlInfo = false; // Flag used for checking if the user was shown the keyboard control information +var currentResultIndex = 1; // stores result which was focused last + +document.onkeydown = checkKey; +function checkKey(e) { + e = e || window.event; +// Check for TAB keypress + if (e.keyCode == '9') { + e.preventDefault(); + tabKeyPressed($(document.activeElement)); + } +} + +function tabKeyPressed() { + if(!ctrlInfo) { + ctrlInfo = true; + showInfoBox(); + } else { + focusNextElement($(":focus")); + } +} + +function showInfoBox() { + $("#keyboard-ctrl-info").show(); + $("#keyboard-ctrl-info").focus(); +} + +function focusNextElement(currentFocus) { + if(currentFocus.hasClass("result")) { + focusNextResult(currentFocus); + } else if(false) { + + } else { + focusResult(); + } +} +function focusResult() { + $("div[data-index='"+ currentResultIndex + "'").focus(); + n = $(".result").length; + currentResultIndex = 1 + currentResultIndex % n; + console.log(currentResultIndex + " - " + n); +} + +function focusNextResult(currentFocus) { + if(!currentFocus.next().focus()) { + alert("test"); + } + console.log(currentFocus); +} \ No newline at end of file diff --git a/resources/js/utility.js b/resources/js/utility.js index 9e958be17afca4a74382ad580c24692191be8ef0..4a94950271def55a3b887de3b0bfaee2a4a4dbd9 100644 --- a/resources/js/utility.js +++ b/resources/js/utility.js @@ -1,41 +1,4 @@ $(document).ready(function () { $('.js-only').removeClass('js-only'); $('.no-js').addClass('hide'); -}); - -// 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(); - 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 +}); \ No newline at end of file diff --git a/resources/less/metager/pages/resultpage/keyboard-ctrl.less b/resources/less/metager/pages/resultpage/keyboard-ctrl.less index af67c504469a200011276fbdd55f0ca2cd3e388c..82e3aa9d63fa95c85aa356823c68a5b2feebaa6e 100644 --- a/resources/less/metager/pages/resultpage/keyboard-ctrl.less +++ b/resources/less/metager/pages/resultpage/keyboard-ctrl.less @@ -16,5 +16,12 @@ .keyboard-ctrl-info-header{ text-align: center; + h5 { + font-weight: bold; + } + } + + ul { + text-align: left; } } \ No newline at end of file diff --git a/resources/views/layouts/ad.blade.php b/resources/views/layouts/ad.blade.php index dc010c73d12cde5d72ddcc16741f62502a050eef..c7cd6e4d64f65824dc1b6ce8a1ed061d83ff43eb 100644 --- a/resources/views/layouts/ad.blade.php +++ b/resources/views/layouts/ad.blade.php @@ -1,5 +1,5 @@ @if(isset($ad) && !$apiAuthorized) -