Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
27a83eff
Commit
27a83eff
authored
5 years ago
by
Aria Givi
Browse files
Options
Downloads
Patches
Plain Diff
changed the way currently focused element is stored
parent
251bb8bf
No related branches found
Branches containing commit
No related tags found
2 merge requests
!1453
Development
,
!1447
Resolve "Make result page keyboard maneuverable"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
resources/js/keyboardNavigation.js
+32
-29
32 additions, 29 deletions
resources/js/keyboardNavigation.js
with
34 additions
and
30 deletions
.gitignore
+
2
−
1
View file @
27a83eff
...
...
@@ -8,6 +8,7 @@ Homestead.yaml
.orig
.vscode
langfiles.zip
npm-debug.log
# The Files created by Webpack in the build process
/public/**/*.css
!/public/fonts/arimo/stylesheet.css
...
...
@@ -19,4 +20,4 @@ langfiles.zip
/.buildpath
/.project
composer.lock
\ No newline at end of file
composer.lock
This diff is collapsed.
Click to expand it.
resources/js/keyboardNavigation.js
+
32
−
29
View file @
27a83eff
var
ctrlInfo
=
false
;
// Flag used for checking if the user was shown the keyboard control information
/*
var current
Element = [
["Results", false]
];
*/
var
currentResultIndex
=
1
;
// stores result which was focused last
var
current
ResultIndex
=
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
"
};
$
(
document
).
on
(
'
keydown
'
,
function
(
e
)
{
e
=
e
||
window
.
event
;
...
...
@@ -12,51 +12,54 @@ $(document).on('keydown', function(e) {
if
(
e
.
keyCode
==
'
9
'
)
{
e
.
preventDefault
();
tabKeyPressed
();
// Check for ENTER keypress
}
else
if
(
e
.
keyCode
==
'
13
'
)
{
e
.
preventDefault
();
enterKeyPressed
();
}
});
function
setFocus
(
e
,
selector
,
type
)
{
currentElementData
.
element
=
e
;
currentElementData
.
selector
=
selector
;
currentElementData
.
type
=
type
;
currentElementData
.
element
.
focus
();
console
.
log
(
currentElementData
);
}
function
tabKeyPressed
()
{
if
(
!
ctrlInfo
)
{
ctrlInfo
=
true
;
showInfoBox
();
}
else
{
focusNextElement
(
$
(
"
:focus
"
)
);
focusNextElement
();
}
}
function
enterKeyPressed
()
{
if
(
$
(
"
:focus
"
).
hasClass
(
"
result
"
))
{
//$(":focus").children("a").focus();
console
.
log
(
$
(
"
:focus
"
).
children
(
"
a
"
));
}
if
(
currentElementData
.
type
=
"
result
"
)
{
// setFocus(currentElementData.element, "link")
}
}
function
showInfoBox
()
{
infoBox
=
$
(
"
#keyboard-ctrl-info
"
);
infoBox
.
show
();
infoBox
.
focus
();
$
(
"
#keyboard-ctrl-info
"
).
show
();
setFocus
(
$
(
"
#keyboard-ctrl-info
"
),
"
#keyboard-ctrl-info
"
,
"
infobox
"
);
}
function
focusNextElement
(
currentFocus
)
{
if
(
current
Focus
.
hasClass
(
"
result
"
)
)
{
focusNextResult
(
currentFocus
);
function
focusNextElement
()
{
if
(
current
ElementData
.
type
===
"
result
"
)
{
focusNextResult
();
}
else
{
focusResult
(
);
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
div.result
"
,
"
result
"
);
}
}
function
focusResult
()
{
$
(
"
div[data-index='
"
+
currentResultIndex
+
"
'
"
).
focus
();
n
=
$
(
"
.result
"
).
length
;
currentResultIndex
=
1
+
currentResultIndex
%
n
;
console
.
log
(
currentResultIndex
+
"
-
"
+
n
);
}
function
focusNextResult
(
currentFocus
)
{
if
(
currentFocus
.
next
().
length
>
0
)
{
currentFocus
.
next
().
focus
();
function
focusNextResult
()
{
if
(
currentElementData
.
element
.
next
().
length
>
0
)
{
setFocus
(
currentElementData
.
element
.
next
(),
''
,
"
result
"
);
}
else
{
$
(
"
div
[
.result
]
"
).
first
().
focus
(
);
setFocus
(
$
(
"
div.result
"
).
not
(
'
.ad
'
).
first
(),
"
div.result
"
,
"
result
"
);
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment