Commit 06a4d28f authored by Aria Givi's avatar Aria Givi

some name changes for clarity

parent 2f8d92a2
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 currentElementData = { // Object used for storing currently focused element and element type (e.g. anchor tag or result div)
var currentFocusedElement = { // Object used for storing currently focused element and element type (e.g. anchor tag or result div)
element: $("div.result").first(),
type: "result"
};
......@@ -18,11 +18,10 @@ $(document).on('keydown', function(e) {
}
});
function setFocus(e, type) {
currentElementData.element = e;
currentElementData.type = type;
console.log(currentElementData);
currentElementData.element.focus();
function focusElement(e, type) {
currentFocusedElement.element = e;
currentFocusedElement.type = type;
currentFocusedElement.element.focus();
}
function tabKeyPressed() {
......@@ -35,31 +34,31 @@ function tabKeyPressed() {
}
function enterKeyPressed() {
if(currentElementData.type === "result") {
if(currentFocusedElement.type === "result") {
console.log($(":focus").find("a").first());
setFocus($(":focus").find("a").first(), "link")
} else if(currentElementData.type === "link") {
window.location = currentElementData.element.attr('href');
focusElement($(":focus").find("a").first(), "link")
} else if(currentFocusedElement.type === "link") {
window.location = currentFocusedElement.element.attr('href');
}
}
function showInfoBox() {
$("#keyboard-ctrl-info").show();
setFocus($("#keyboard-ctrl-info"), "infobox");
$("#keyboard-nav-info").show();
focusElement($("#keyboard-nav-info"), "infobox");
}
function focusNextElement() {
if(currentElementData.type === "result") {
if(currentFocusedElement.type === "result") {
focusNextResult();
} else {
setFocus($("div.result").not('.ad').first(), "result");
focusElement($("div.result").not('.ad').first(), "result");
}
}
function focusNextResult() {
if(currentElementData.element.next().length > 0) {
setFocus(currentElementData.element.next(), "result");
if(currentFocusedElement.element.next().length > 0) {
focusElement(currentFocusedElement.element.next(), "result");
} else {
setFocus($("div.result").not('.ad').first(), "result");
focusElement($("div.result").not('.ad').first(), "result");
}
}
......@@ -3,4 +3,4 @@
@import "./resultpage/product.less";
@import "./resultpage/quicktips.less";
@import "./resultpage/result-saver.less";
@import "./resultpage/keyboard-ctrl.less";
\ No newline at end of file
@import "./resultpage/keyboard-nav.less";
\ No newline at end of file
/* Keyboard control styles*/
#keyboard-ctrl-info {
#keyboard-nav-info {
display: none;
position: relative;
margin: 10px 0;
......@@ -14,7 +14,7 @@
border: 10px solid yellow;
}
.keyboard-ctrl-info-header{
.keyboard-nav-info-header{
text-align: center;
h5 {
font-weight: bold;
......
<div id="keyboard-ctrl-info" tabindex="0">
<div class="keyboard-ctrl-info-content">
<div class="keyboard-ctrl-info-header">
<h5 class="keyboard-ctrl-info-title">Tastatur-Navigationsanleitung</h5>
<div class="keyboard-ctrl-info-body">
<div id="keyboard-nav-info" tabindex="0">
<div class="keyboard-nav-info-content">
<div class="keyboard-nav-info-header">
<h5 class="keyboard-nav-info-title">Tastatur-Navigationsanleitung</h5>
<div class="keyboard-nav-info-body">
<p>Die Navigation durch die Ergebnisseite ist hierarchisch aufgebaut.</p>
<ul>
<li>TAB-Taste: Innerhalb der aktuellen Ebene zum nächsten Element springen.</li>
......
......@@ -60,7 +60,8 @@ mix
[
"resources/js/scriptResultPage.js",
"resources/js/result-saver.js",
"resources/js/translations.js"
"resources/js/translations.js",
"resources/js/keyboardNavigation.js"
],
"public/js/scriptResultPage.js"
)
......@@ -68,7 +69,7 @@ mix
.babel("resources/js/bitpay.js", "public/js/bitpay.js")
// utility
.babel(
["resources/js/utility.js", "resources/js/keyboardNavigation.js", "resources/js/translations.js"],
["resources/js/utility.js", "resources/js/translations.js"],
"public/js/utility.js"
)
.babel("resources/js/widgets.js", "public/js/widgets.js")
......
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