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
3898bffd
Commit
3898bffd
authored
Mar 18, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code improvements
parent
79a4292f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
41 deletions
+31
-41
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+9
-12
app/assets/javascripts/search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+22
-29
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
3898bffd
...
...
@@ -20,7 +20,7 @@ class GitLabDropdownFilter
blur_field
=
@
shouldBlur
e
.
keyCode
search_text
=
@
input
.
val
()
if
blur_field
&&
@
filterInputBlur
if
blur_field
and
@
filterInputBlur
@
input
.
blur
()
if
@
options
.
remote
...
...
@@ -88,7 +88,7 @@ class GitLabDropdown
# Set Defaults
{
# If no input is passed create a default one
@
filterInput
=
@
$
(
FILTER_INPUT
)
@
filterInput
=
@
getElement
(
FILTER_INPUT
)
@
highlight
=
false
@
filterInputBlur
=
true
}
=
@
options
...
...
@@ -97,8 +97,7 @@ class GitLabDropdown
# If selector was passed
if
_
.
isString
(
@
filterInput
)
@
filterInput
=
@
$
(
@
filterInput
)
@
filterInput
=
@
getElement
(
@
filterInput
)
search_fields
=
if
@
options
.
search
then
@
options
.
search
.
fields
else
[];
...
...
@@ -156,8 +155,9 @@ class GitLabDropdown
if
self
.
options
.
clicked
self
.
options
.
clicked
()
$
:
(
selector
)
->
$
(
selector
,
@
dropdown
)
# Finds an element inside wrapper element
getElement
:
(
selector
)
->
@
dropdown
.
find
selector
toggleLoading
:
->
$
(
'.dropdown-menu'
,
@
dropdown
).
toggleClass
LOADING_CLASS
...
...
@@ -268,12 +268,9 @@ class GitLabDropdown
highlightTextMatches
:
(
text
,
term
)
->
occurrences
=
fuzzaldrinPlus
.
match
(
text
,
term
)
textArr
=
text
.
split
(
''
)
textArr
.
forEach
(
character
,
i
,
textArr
)
->
if
i
in
occurrences
textArr
[
i
]
=
"<b>
#{
character
}
</b>"
textArr
.
join
''
text
.
split
(
''
).
map
((
character
,
i
)
->
if
i
in
occurrences
then
"<b>
#{
character
}
</b>"
else
character
).
join
(
''
)
noResults
:
->
html
=
"<li>"
...
...
app/assets/javascripts/search_autocomplete.js.coffee
View file @
3898bffd
...
...
@@ -20,15 +20,15 @@ class @SearchAutocomplete
# Dropdown Element
@
dropdown
=
@
wrap
.
find
(
'.dropdown'
)
@
locationBadgeEl
=
@
$
(
'.search-location-badge'
)
@
locationText
=
@
$
(
'.location-text'
)
@
scopeInputEl
=
@
$
(
'#scope'
)
@
searchInput
=
@
$
(
'.search-input'
)
@
projectInputEl
=
@
$
(
'#search_project_id'
)
@
groupInputEl
=
@
$
(
'#group_id'
)
@
searchCodeInputEl
=
@
$
(
'#search_code'
)
@
repositoryInputEl
=
@
$
(
'#repository_ref'
)
@
scopeInputEl
=
@
$
(
'#scope'
)
@
locationBadgeEl
=
@
getElement
(
'.search-location-badge'
)
@
locationText
=
@
getElement
(
'.location-text'
)
@
scopeInputEl
=
@
getElement
(
'#scope'
)
@
searchInput
=
@
getElement
(
'.search-input'
)
@
projectInputEl
=
@
getElement
(
'#search_project_id'
)
@
groupInputEl
=
@
getElement
(
'#group_id'
)
@
searchCodeInputEl
=
@
getElement
(
'#search_code'
)
@
repositoryInputEl
=
@
getElement
(
'#repository_ref'
)
@
scopeInputEl
=
@
getElement
(
'#scope'
)
@
saveOriginalState
()
...
...
@@ -36,7 +36,8 @@ class @SearchAutocomplete
@
bindEvents
()
$
:
(
selector
)
->
# Finds an element inside wrapper element
getElement
:
(
selector
)
->
@
wrap
.
find
(
selector
)
saveOriginalState
:
->
...
...
@@ -60,11 +61,9 @@ class @SearchAutocomplete
@
searchInput
.
on
'blur'
,
@
onSearchInputBlur
enableAutocomplete
:
->
self
=
@
@
query
=
"?project_id="
+
@
projectId
+
"&project_ref="
+
@
projectRef
dropdownMenu
=
self
.
dropdown
.
find
(
'.dropdown-menu'
)
@
searchInput
.
glDropdown
(
dropdownMenu
=
@
dropdown
.
find
(
'.dropdown-menu'
)
_this
=
@
@
searchInput
.
glDropdown
filterInputBlur
:
false
filterable
:
true
filterRemote
:
true
...
...
@@ -73,13 +72,11 @@ class @SearchAutocomplete
search
:
fields
:
[
'text'
]
data
:
(
term
,
callback
)
->
$
.
ajax
url
:
self
.
autocompletePath
+
self
.
query
data
:
$
.
get
(
_this
.
autocompletePath
,
{
project_id
:
_this
.
projectId
project_ref
:
_this
.
projectRef
term
:
term
beforeSend
:
->
# dropdownMenu.addClass 'is-loading'
success
:
(
response
)
->
},
(
response
)
->
data
=
[]
# Save groups ordering according to server response
...
...
@@ -101,16 +98,12 @@ class @SearchAutocomplete
data
.
push
text
:
item
.
label
url
:
item
.
url
callback
(
data
)
complete
:
->
# dropdownMenu.removeClass 'is-loading'
)
@
dropdown
.
addClass
(
'open'
)
@
searchInput
.
removeClass
(
'disabled'
)
@
autocomplete
=
true
;
@
autocomplete
=
true
onDropdownOpen
:
(
e
)
=>
@
dropdown
.
dropdown
(
'toggle'
)
...
...
@@ -158,7 +151,7 @@ class @SearchAutocomplete
inputs
=
Object
.
keys
@
originalState
for
input
in
inputs
@
$
(
"#
#{
input
}
"
).
val
(
@
originalState
[
input
])
@
getElement
(
"#
#{
input
}
"
).
val
(
@
originalState
[
input
])
if
@
originalState
.
_location
is
''
...
...
@@ -200,6 +193,6 @@ class @SearchAutocomplete
@
resetSearchState
()
disableAutocomplete
:
->
if
@
autocomplete
isnt
undefined
if
@
autocomplete
?
@
searchInput
.
addClass
(
'disabled'
)
@
autocomplete
=
undefined
@
autocomplete
=
null
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