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