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
Jérome Perrin
gitlab-ce
Commits
6c891962
Commit
6c891962
authored
Mar 08, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enter button trigger first row click when searching
parent
57294f30
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
11 deletions
+30
-11
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+29
-10
app/assets/stylesheets/framework/dropdowns.scss
app/assets/stylesheets/framework/dropdowns.scss
+1
-1
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
6c891962
class
GitLabDropdownFilter
class
GitLabDropdownFilter
BLUR_KEYCODES
=
[
27
,
40
]
BLUR_KEYCODES
=
[
27
,
40
]
constructor
:
(
@
dropdown
,
@
remote
,
@
query
,
@
keys
,
@
data
,
@
callback
)
->
constructor
:
(
@
dropdown
,
@
options
)
->
@
input
=
@
dropdown
.
find
(
".dropdown-input .dropdown-input-field"
)
@
input
=
@
dropdown
.
find
(
".dropdown-input .dropdown-input-field"
)
# Key events
# Key events
timeout
=
""
timeout
=
""
@
input
.
on
"keyup"
,
(
e
)
=>
@
input
.
on
"keyup"
,
(
e
)
=>
if
e
.
keyCode
is
13
&&
@
input
.
val
()
isnt
""
if
@
options
.
enterCallback
@
options
.
enterCallback
()
return
clearTimeout
timeout
clearTimeout
timeout
timeout
=
setTimeout
=>
timeout
=
setTimeout
=>
blur_field
=
@
shouldBlur
e
.
keyCode
blur_field
=
@
shouldBlur
e
.
keyCode
...
@@ -15,9 +20,9 @@ class GitLabDropdownFilter
...
@@ -15,9 +20,9 @@ class GitLabDropdownFilter
if
blur_field
if
blur_field
@
input
.
blur
()
@
input
.
blur
()
if
@
remote
if
@
options
.
remote
@
query
search_text
,
(
data
)
=>
@
options
.
query
search_text
,
(
data
)
=>
@
callback
(
data
)
@
options
.
callback
(
data
)
else
else
@
filter
search_text
@
filter
search_text
,
250
,
250
...
@@ -26,12 +31,12 @@ class GitLabDropdownFilter
...
@@ -26,12 +31,12 @@ class GitLabDropdownFilter
return
BLUR_KEYCODES
.
indexOf
(
keyCode
)
>=
0
return
BLUR_KEYCODES
.
indexOf
(
keyCode
)
>=
0
filter
:
(
search_text
)
->
filter
:
(
search_text
)
->
data
=
@
data
()
data
=
@
options
.
data
()
results
=
data
results
=
data
if
search_text
isnt
""
if
search_text
isnt
""
results
=
fuzzaldrinPlus
.
filter
(
data
,
search_text
,
results
=
fuzzaldrinPlus
.
filter
(
data
,
search_text
,
key
:
@
keys
key
:
@
options
.
keys
)
)
@
callback
results
@
callback
results
...
@@ -89,10 +94,16 @@ class GitLabDropdown
...
@@ -89,10 +94,16 @@ class GitLabDropdown
# Init filiterable
# Init filiterable
if
@
options
.
filterable
if
@
options
.
filterable
@
filter
=
new
GitLabDropdownFilter
@
dropdown
,
@
options
.
filterRemote
,
@
options
.
data
,
@
options
.
search
.
fields
,
=>
@
filter
=
new
GitLabDropdownFilter
@
dropdown
,
remote
:
@
options
.
filterRemote
query
:
@
options
.
data
keys
:
@
options
.
search
.
fields
data
:
=>
return
@
fullData
return
@
fullData
,
(
data
)
=>
callback
:
(
data
)
=>
@
parseData
data
@
parseData
data
enterCallback
:
=>
@
selectFirstRow
()
# Event listeners
# Event listeners
@
dropdown
.
on
"shown.bs.dropdown"
,
@
opened
@
dropdown
.
on
"shown.bs.dropdown"
,
@
opened
...
@@ -234,6 +245,14 @@ class GitLabDropdown
...
@@ -234,6 +245,14 @@ class GitLabDropdown
input
=
"<input type='hidden' name='
#{
fieldName
}
' value='
#{
value
}
' />"
input
=
"<input type='hidden' name='
#{
fieldName
}
' value='
#{
value
}
' />"
@
dropdown
.
before
input
@
dropdown
.
before
input
selectFirstRow
:
->
selector
=
'.dropdown-content li:first-child a'
if
@
dropdown
.
find
(
".dropdown-toggle-page"
).
length
selector
=
".dropdown-page-one .dropdown-content li:first-child a"
# similute a click on the first link
$
(
selector
).
trigger
"click"
$
.
fn
.
glDropdown
=
(
opts
)
->
$
.
fn
.
glDropdown
=
(
opts
)
->
return
@
.
each
->
return
@
.
each
->
new
GitLabDropdown
@
,
opts
new
GitLabDropdown
@
,
opts
app/assets/stylesheets/framework/dropdowns.scss
View file @
6c891962
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
position
:
absolute
;
position
:
absolute
;
top
:
100%
;
top
:
100%
;
left
:
0
;
left
:
0
;
z-index
:
9
999
;
z-index
:
9
;
width
:
240px
;
width
:
240px
;
margin-top
:
2px
;
margin-top
:
2px
;
margin-bottom
:
0
;
margin-bottom
:
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