From 74762cb3de885dc01717bf83937655b24958472b Mon Sep 17 00:00:00 2001 From: Aria Date: Thu, 29 Aug 2019 12:48:29 +0200 Subject: [PATCH] Removed existing code, instead working with tabindeces, still requires logic for the navigation box --- resources/js/keyboardNavigation.js | 86 +++++++++++-------- .../views/layouts/keyboardNavBox.blade.php | 6 +- .../views/layouts/researchandtabs.blade.php | 2 +- resources/views/layouts/result.blade.php | 4 +- resources/views/parts/filter.blade.php | 2 +- resources/views/parts/searchbar.blade.php | 8 +- 6 files changed, 62 insertions(+), 46 deletions(-) diff --git a/resources/js/keyboardNavigation.js b/resources/js/keyboardNavigation.js index 6093a60c..09bb2750 100644 --- a/resources/js/keyboardNavigation.js +++ b/resources/js/keyboardNavigation.js @@ -1,3 +1,43 @@ +var ctrlInfo = false; + +$('label').on('keydown', function(e) { + if(e.keyCode == '13') { + $(this).click(); + } +}); + +$(document).on('keydown', function(e) { + e = e || window.event; + if(!ctrlInfo && e.keyCode == '9') { + focusInfoBox(); + e.preventDefault(); + ctrlInfo = true; + } else if(e.keyCode == '27') { + escKeyPressed(); + } +}); + +function escKeyPressed() { + focusInfoBox(); +} + +function focusInfoBox() { + $("#keyboard-nav-info").show(); + $("#keyboard-nav-info a").first().focus(); +} + +function jumpToResults() { + +} + +function jumpToSettings() { + +} + +function jumpToNavigation() { + +} +/* var ctrlInfo = false; // Flag used for checking if the user was shown the keyboard control information var currentResultIndex = 1; // stores index of result which was focused last var currentFocusedElement = { // Object used for storing currently focused element and element type (e.g. anchor tag or result div) @@ -6,37 +46,17 @@ var currentFocusedElement = { // Object used for storing currently focused mode: "results" }; + $(document).ready(function () { $('[data-index="1"').attr("id", "results-entry"); focusElement($("div.search-input input"), "input"); }); -$(document).on('keydown', function(e) { - e = e || window.event; - // Check for TAB keypress - if (e.keyCode == '9') { - if(e.shiftKey) { - // Add logic for reverse tabbing - } else { - tabKeyPressed(); - e.preventDefault(); - } - // Check for ENTER keypress - } else if (e.keyCode == '13') { - enterKeyPressed(); - e.preventDefault(); - // Check for ESC keypress - } else if(e.keyCode == '27') { - escKeyPressed(); - } -}); -function focusElement(e, type) { - currentFocusedElement.element = e; - currentFocusedElement.type = (type !== undefined ? type : currentFocusedElement.type); - currentFocusedElement.element.focus(); -} + +// Focuses passed element and sets currentFocusedElement object + function tabKeyPressed() { if(!ctrlInfo) { @@ -50,6 +70,7 @@ function tabKeyPressed() { function enterKeyPressed() { if(currentFocusedElement.type === "infobox") { focusElement($(currentFocusedElement.element.attr('href')), "result"); + console.log(currentFocusedElement.element.html()); /* switch(currentFocusedElement.element.attr('id')) { case 'results-nav': console.log(currentFocusedElement.element.attr('id')); @@ -62,7 +83,7 @@ function enterKeyPressed() { break; default: console.log(currentFocusedElement.element.attr('id')); - } */ + } } else if(currentFocusedElement.type === "result") { focusElement($(":focus").find("a").first(), "link") } else if(currentFocusedElement.type === "link" || "infobox") { @@ -72,16 +93,9 @@ function enterKeyPressed() { } } -function escKeyPressed() { - if(currentFocusedElement.type === "link") { - focusElement(currentFocusedElement.element.parents(".result"), "result"); - } -} -function showInfoBox() { - $("#keyboard-nav-info").show(); - focusElement($("#keyboard-nav-info a").first(), "infobox"); -} + + function focusNextElement() { if(currentFocusedElement.type === "infobox") { @@ -121,4 +135,6 @@ function rotateInfoBoxLinks() { default: focusElement($('#results-nav'), 'infobox'); } -} \ No newline at end of file +} + +*/ \ No newline at end of file diff --git a/resources/views/layouts/keyboardNavBox.blade.php b/resources/views/layouts/keyboardNavBox.blade.php index 638656ae..b08a9e3f 100644 --- a/resources/views/layouts/keyboardNavBox.blade.php +++ b/resources/views/layouts/keyboardNavBox.blade.php @@ -4,9 +4,9 @@
Tastatur-Navigation
diff --git a/resources/views/layouts/researchandtabs.blade.php b/resources/views/layouts/researchandtabs.blade.php index c5c86b31..29faa833 100644 --- a/resources/views/layouts/researchandtabs.blade.php +++ b/resources/views/layouts/researchandtabs.blade.php @@ -3,7 +3,7 @@
diff --git a/resources/views/parts/filter.blade.php b/resources/views/parts/filter.blade.php index 719b6bea..8f7734b5 100644 --- a/resources/views/parts/filter.blade.php +++ b/resources/views/parts/filter.blade.php @@ -3,7 +3,7 @@
@if(sizeof($metager->getAvailableParameterFilter()) > 0)
-
diff --git a/resources/views/parts/searchbar.blade.php b/resources/views/parts/searchbar.blade.php index 83b79537..cdaf93b1 100644 --- a/resources/views/parts/searchbar.blade.php +++ b/resources/views/parts/searchbar.blade.php @@ -3,18 +3,18 @@