BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0e290a84
Commit
0e290a84
authored
Mar 23, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started arrow key movement on dropdowns
parent
c3875b5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
6 deletions
+62
-6
gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+53
-4
dropdowns.scss
app/assets/stylesheets/framework/dropdowns.scss
+9
-2
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
0e290a84
...
...
@@ -96,6 +96,7 @@ class GitLabDropdown
LOADING_CLASS
=
"is-loading"
PAGE_TWO_CLASS
=
"is-page-two"
ACTIVE_CLASS
=
"is-active"
CURRENT_INDEX
=
0
FILTER_INPUT
=
'.dropdown-input .dropdown-input-field'
...
...
@@ -218,6 +219,8 @@ class GitLabDropdown
return
true
opened
:
=>
@
addArrowKeyEvent
()
contentHtml
=
$
(
'.dropdown-content'
,
@
dropdown
).
html
()
if
@
remote
&&
contentHtml
is
""
@
remote
.
execute
()
...
...
@@ -228,6 +231,7 @@ class GitLabDropdown
@
dropdown
.
trigger
(
'shown.gl.dropdown'
)
hidden
:
(
e
)
=>
@
removeArrayKeyEvent
()
if
@
options
.
filterable
@
dropdown
.
find
(
".dropdown-input-field"
)
...
...
@@ -322,8 +326,8 @@ class GitLabDropdown
).
join
(
''
)
noResults
:
->
html
=
"<li>"
html
+=
"<a
class='dropdown-menu-empty-link is-focused
'>"
html
=
"<li
class='dropdown-menu-empty-link is-focused'
>"
html
+=
"<a
href='#
'>"
html
+=
"No matching results."
html
+=
"</a>"
html
+=
"</li>"
...
...
@@ -343,7 +347,7 @@ class GitLabDropdown
selectedObject
=
@
renderedData
[
selectedIndex
]
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
el
.
removeClass
(
ACTIVE_CLASS
)
field
.
remove
()
...
...
@@ -384,8 +388,53 @@ class GitLabDropdown
# simulate a click on the first link
$
(
selector
).
trigger
"click"
addArrowKeyEvent
:
->
ARROW_KEY_CODES
=
[
38
,
40
]
$input
=
@
dropdown
.
find
(
".dropdown-input-field"
)
selector
=
'.dropdown-content li:not(.divider)'
if
@
dropdown
.
find
(
".dropdown-toggle-page"
).
length
selector
=
".dropdown-page-one
#{
selector
}
"
$
(
'body'
).
on
'keydown'
,
(
e
)
=>
currentKeyCode
=
e
.
keyCode
if
ARROW_KEY_CODES
.
indexOf
(
currentKeyCode
)
>=
0
e
.
preventDefault
()
e
.
stopPropagation
()
$listItems
=
$
(
selector
,
@
dropdown
)
if
@
options
.
filterable
$input
.
blur
()
if
currentKeyCode
is
40
# Move down
CURRENT_INDEX
+=
1
if
CURRENT_INDEX
<
$listItems
.
length
else
if
currentKeyCode
is
38
# Move up
CURRENT_INDEX
-=
1
if
CURRENT_INDEX
>
0
@
highlightRowAtIndex
(
CURRENT_INDEX
)
return
false
removeArrayKeyEvent
:
->
$
(
'body'
).
off
'keydown'
highlightRowAtIndex
:
(
index
,
prevIndex
)
->
# Remove the class for the previously focused row
$
(
'.is-focused'
,
@
dropdown
).
removeClass
'is-focused'
# Update the class for the row at the specific index
selector
=
".dropdown-content li:not(.divider):eq(
#{
index
}
)"
if
@
dropdown
.
find
(
".dropdown-toggle-page"
).
length
selector
=
".dropdown-page-one
#{
selector
}
"
$listItem
=
$
(
selector
,
@
dropdown
)
$listItem
.
addClass
"is-focused"
$
.
fn
.
glDropdown
=
(
opts
)
->
return
@
.
each
->
if
(
!
$
.
data
@
,
'glDropdown'
)
$
.
data
(
@
,
'glDropdown'
,
new
GitLabDropdown
@
,
opts
)
app/assets/stylesheets/framework/dropdowns.scss
View file @
0e290a84
...
...
@@ -104,6 +104,14 @@
padding
:
0
10px
;
}
.is-focused
{
a
{
background-color
:
$dropdown-link-hover-bg
;
text-decoration
:
none
;
outline
:
0
;
}
}
.divider
{
height
:
1px
;
margin
:
8px
10px
;
...
...
@@ -132,8 +140,7 @@
overflow
:
hidden
;
&
:hover
,
&
:focus
,
&
.is-focused
{
&
:focus
{
background-color
:
$dropdown-link-hover-bg
;
text-decoration
:
none
;
outline
:
0
;
...
...
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