Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
MetaGer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
54
Issues
54
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
open-source
MetaGer
Commits
2f8d92a2
Commit
2f8d92a2
authored
Aug 07, 2019
by
Aria Givi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first link in search results can now be selected and 'clicked on' with keyboard
parent
27a83eff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
resources/js/keyboardNavigation.js
resources/js/keyboardNavigation.js
+12
-12
No files found.
resources/js/keyboardNavigation.js
View file @
2f8d92a2
...
...
@@ -2,7 +2,6 @@ var ctrlInfo = false; // Flag used for checking if the user was shown the
var
currentResultIndex
=
1
;
// stores index of result which was focused last
var
currentElementData
=
{
// Object used for storing currently focused element and element type (e.g. anchor tag or result div)
element
:
$
(
"
div.result
"
).
first
(),
selector
:
"
div.result
"
,
type
:
"
result
"
};
...
...
@@ -19,12 +18,11 @@ $(document).on('keydown', function(e) {
}
});
function
setFocus
(
e
,
selector
,
type
)
{
function
setFocus
(
e
,
type
)
{
currentElementData
.
element
=
e
;
currentElementData
.
selector
=
selector
;
currentElementData
.
type
=
type
;
currentElementData
.
element
.
focus
();
console
.
log
(
currentElementData
);
currentElementData
.
element
.
focus
();
}
function
tabKeyPressed
()
{
...
...
@@ -37,29 +35,31 @@ function tabKeyPressed() {
}
function
enterKeyPressed
()
{
if
(
currentElementData
.
type
=
"
result
"
)
{
// setFocus(currentElementData.element, "link")
}
if
(
currentElementData
.
type
===
"
result
"
)
{
console
.
log
(
$
(
"
:focus
"
).
find
(
"
a
"
).
first
());
setFocus
(
$
(
"
:focus
"
).
find
(
"
a
"
).
first
(),
"
link
"
)
}
else
if
(
currentElementData
.
type
===
"
link
"
)
{
window
.
location
=
currentElementData
.
element
.
attr
(
'
href
'
);
}
}
function
showInfoBox
()
{
$
(
"
#keyboard-ctrl-info
"
).
show
();
setFocus
(
$
(
"
#keyboard-ctrl-info
"
),
"
#keyboard-ctrl-info
"
,
"
infobox
"
);
setFocus
(
$
(
"
#keyboard-ctrl-info
"
),
"
infobox
"
);
}
function
focusNextElement
()
{
if
(
currentElementData
.
type
===
"
result
"
)
{
focusNextResult
();
}
else
{
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
div.result
"
,
"
result
"
);
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
result
"
);
}
}
function
focusNextResult
()
{
if
(
currentElementData
.
element
.
next
().
length
>
0
)
{
setFocus
(
currentElementData
.
element
.
next
(),
''
,
"
result
"
);
setFocus
(
currentElementData
.
element
.
next
(),
"
result
"
);
}
else
{
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
div.result
"
,
"
result
"
);
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
result
"
);
}
}
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