Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
2614a4c8
Commit
2614a4c8
authored
Sep 02, 2019
by
Aria Givi
Browse files
changed some minor stuff, added comments
parent
183e7db4
Changes
2
Hide whitespace changes
Inline
Side-by-side
resources/js/keyboardNavigation.js
View file @
2614a4c8
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
'
)
{
focus
Info
Box
();
focus
Nav
Box
();
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
();
...
...
resources/less/metager/pages/resultpage/keyboard-nav.less
View file @
2614a4c8
/* 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;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment