Commit 2614a4c8 authored by Aria Givi's avatar Aria Givi

changed some minor stuff, added comments

parent 183e7db4
var ctrlInfo = false; // Flag used for checking if the user was shown the keyboard control information
/**
* Flag ctrlInfo is used for initial display of the navigation box
*/
var ctrlInfo = false;
$(document).ready(function () {
// Add entry point for tabbing to the first result
$('[data-index="1"').attr("id", "results-entry");
$('#foki a').first().attr("id", "settings-entry");
// Initially focus the searchbar
$('div.search-input input').focus();
});
/**
* Simulate a click on enter keypress when focused on labels
*/
$('label').on('keydown', function(e) {
if(e.keyCode == '13') {
$(this).click();
}
});
/**
* Handles tab keypress and escape keypress
*/
$(document).on('keydown', function(e) {
e = e || window.event;
// On first tab keypress there is special behaviour and the ctrlInfo flag is set
if(!ctrlInfo && e.keyCode == '9') {
focusInfoBox();
focusNavBox();
e.preventDefault();
ctrlInfo = true;
} else if(e.keyCode == '27') {
......@@ -23,24 +34,39 @@ $(document).on('keydown', function(e) {
}
});
function escKeyPressed() {
focusInfoBox();
$('input[type="checkbox"]').removeAttr('checked');
}
function focusInfoBox() {
/**
* Shows the navigation box and focuses the first <a> tag
*/
function focusNavBox() {
$('#keyboard-nav-info').show();
$('#keyboard-nav-info a').first().focus();
}
/**
* Focuses the navigation box and unchecks all checkboxes
*/
function escKeyPressed() {
focusNavBox();
$('input[type="checkbox"]').removeAttr('checked');
}
/**
* Focuses the first <a> tag of the first result
*/
function focusResults() {
$('#results-entry .result-title a').focus();
}
/**
* Focuses the first <a> tag of the focus options
*/
function focusSettings() {
$('#foki a').first().focus();
}
/**
* Focuses the first <tag> of the sidebar
*/
function focusNavigation() {
$('#sidebarToggle').prop('checked', true);
$('.sidebar-list a').first().focus();
......
/* Keyboard control styles*/
#keyboard-nav-info {
display: none;
position: relative;
......@@ -10,11 +9,7 @@
border: 1px solid #f00;
background-color: #fff;
&:focus {
border: 10px solid yellow;
}
.keyboard-nav-info-header{
.keyboard-nav-info-header {
text-align: center;
h5 {
font-weight: bold;
......
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