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
330ffb2c
Commit
330ffb2c
authored
Jul 24, 2019
by
Aria Givi
Browse files
added possibility to tab through result-divs
parent
ba5088d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
resources/js/utility.js
View file @
330ffb2c
...
...
@@ -3,18 +3,39 @@ $(document).ready(function () {
$
(
'
.no-js
'
).
addClass
(
'
hide
'
);
});
document
.
onkeydown
=
checkKey
;
// Flag used for checking if the user was shown the keyboard control information
ctrlInfo
=
false
;
currentResultIndex
=
1
;
document
.
onkeydown
=
checkKey
;
function
checkKey
(
e
)
{
e
=
e
||
window
.
event
;
if
(
e
.
keyCode
==
'
9
'
)
{
e
.
preventDefault
();
$
(
"
#keyboard-ctrl-info
"
).
show
();
$
(
"
#keyboard-ctrl-info
"
).
focus
();
guideThroughMenu
(
$
(
document
.
activeElement
));
}
}
function
guideThroughMenu
(
focused
)
{
if
(
!
ctrlInfo
)
{
ctrlInfo
=
true
;
showInfoBox
();
}
else
{
focusNextResult
();
}
}
function
showInfoBox
()
{
$
(
"
#keyboard-ctrl-info
"
).
show
();
$
(
"
#keyboard-ctrl-info
"
).
focus
();
}
function
focusNextResult
()
{
$
(
"
div[data-index='
"
+
currentResultIndex
+
"
'
"
).
focus
();
n
=
$
(
"
.result
"
).
length
;
currentResultIndex
=
1
+
currentResultIndex
%
n
;
console
.
log
(
currentResultIndex
+
"
-
"
+
n
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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