Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
MetaGer
Commits
2614a4c8
Commit
2614a4c8
authored
Sep 02, 2019
by
Aria Givi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed some minor stuff, added comments
parent
183e7db4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
15 deletions
+36
-15
resources/js/keyboardNavigation.js
resources/js/keyboardNavigation.js
+35
-9
resources/less/metager/pages/resultpage/keyboard-nav.less
resources/less/metager/pages/resultpage/keyboard-nav.less
+1
-6
No files found.
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
()
{
$
(
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
'
)
{
focus
Info
Box
();
focus
Nav
Box
();
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
();
...
...
resources/less/metager/pages/resultpage/keyboard-nav.less
View file @
2614a4c8
/* 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;
...
...
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