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
55
Issues
55
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
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
27a83eff
Commit
27a83eff
authored
Aug 07, 2019
by
Aria Givi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed the way currently focused element is stored
parent
251bb8bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
30 deletions
+34
-30
.gitignore
.gitignore
+2
-1
resources/js/keyboardNavigation.js
resources/js/keyboardNavigation.js
+32
-29
No files found.
.gitignore
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
...
...
resources/js/keyboardNavigation.js
View file @
27a83eff
var
ctrlInfo
=
false
;
// Flag used for checking if the user was shown the keyboard control information
/* var currentElement = [
["Results", false]
];
*/
var
currentResultIndex
=
1
;
// stores result which was focused last
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
"
};
$
(
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
"
);
}
}
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