Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
6 deletions
+62
-6
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+53
-4
app/assets/stylesheets/framework/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
...
@@ -96,6 +96,7 @@ class GitLabDropdown
LOADING_CLASS
=
"is-loading"
LOADING_CLASS
=
"is-loading"
PAGE_TWO_CLASS
=
"is-page-two"
PAGE_TWO_CLASS
=
"is-page-two"
ACTIVE_CLASS
=
"is-active"
ACTIVE_CLASS
=
"is-active"
CURRENT_INDEX
=
0
FILTER_INPUT
=
'.dropdown-input .dropdown-input-field'
FILTER_INPUT
=
'.dropdown-input .dropdown-input-field'
...
@@ -218,6 +219,8 @@ class GitLabDropdown
...
@@ -218,6 +219,8 @@ class GitLabDropdown
return
true
return
true
opened
:
=>
opened
:
=>
@
addArrowKeyEvent
()
contentHtml
=
$
(
'.dropdown-content'
,
@
dropdown
).
html
()
contentHtml
=
$
(
'.dropdown-content'
,
@
dropdown
).
html
()
if
@
remote
&&
contentHtml
is
""
if
@
remote
&&
contentHtml
is
""
@
remote
.
execute
()
@
remote
.
execute
()
...
@@ -228,6 +231,7 @@ class GitLabDropdown
...
@@ -228,6 +231,7 @@ class GitLabDropdown
@
dropdown
.
trigger
(
'shown.gl.dropdown'
)
@
dropdown
.
trigger
(
'shown.gl.dropdown'
)
hidden
:
(
e
)
=>
hidden
:
(
e
)
=>
@
removeArrayKeyEvent
()
if
@
options
.
filterable
if
@
options
.
filterable
@
dropdown
@
dropdown
.
find
(
".dropdown-input-field"
)
.
find
(
".dropdown-input-field"
)
...
@@ -322,8 +326,8 @@ class GitLabDropdown
...
@@ -322,8 +326,8 @@ class GitLabDropdown
).
join
(
''
)
).
join
(
''
)
noResults
:
->
noResults
:
->
html
=
"<li>"
html
=
"<li
class='dropdown-menu-empty-link is-focused'
>"
html
+=
"<a
class='dropdown-menu-empty-link is-focused
'>"
html
+=
"<a
href='#
'>"
html
+=
"No matching results."
html
+=
"No matching results."
html
+=
"</a>"
html
+=
"</a>"
html
+=
"</li>"
html
+=
"</li>"
...
@@ -343,7 +347,7 @@ class GitLabDropdown
...
@@ -343,7 +347,7 @@ class GitLabDropdown
selectedObject
=
@
renderedData
[
selectedIndex
]
selectedObject
=
@
renderedData
[
selectedIndex
]
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
el
.
removeClass
(
ACTIVE_CLASS
)
el
.
removeClass
(
ACTIVE_CLASS
)
field
.
remove
()
field
.
remove
()
...
@@ -384,8 +388,53 @@ class GitLabDropdown
...
@@ -384,8 +388,53 @@ class GitLabDropdown
# simulate a click on the first link
# simulate a click on the first link
$
(
selector
).
trigger
"click"
$
(
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
)
->
$
.
fn
.
glDropdown
=
(
opts
)
->
return
@
.
each
->
return
@
.
each
->
if
(
!
$
.
data
@
,
'glDropdown'
)
if
(
!
$
.
data
@
,
'glDropdown'
)
$
.
data
(
@
,
'glDropdown'
,
new
GitLabDropdown
@
,
opts
)
$
.
data
(
@
,
'glDropdown'
,
new
GitLabDropdown
@
,
opts
)
app/assets/stylesheets/framework/dropdowns.scss
View file @
0e290a84
...
@@ -104,6 +104,14 @@
...
@@ -104,6 +104,14 @@
padding
:
0
10px
;
padding
:
0
10px
;
}
}
.is-focused
{
a
{
background-color
:
$dropdown-link-hover-bg
;
text-decoration
:
none
;
outline
:
0
;
}
}
.divider
{
.divider
{
height
:
1px
;
height
:
1px
;
margin
:
8px
10px
;
margin
:
8px
10px
;
...
@@ -132,8 +140,7 @@
...
@@ -132,8 +140,7 @@
overflow
:
hidden
;
overflow
:
hidden
;
&
:hover
,
&
:hover
,
&
:focus
,
&
:focus
{
&
.is-focused
{
background-color
:
$dropdown-link-hover-bg
;
background-color
:
$dropdown-link-hover-bg
;
text-decoration
:
none
;
text-decoration
:
none
;
outline
:
0
;
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