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