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
Léo-Paul Géneau
gitlab-ce
Commits
ee87d15c
Commit
ee87d15c
authored
Apr 05, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change approach, do not use timeouts
parent
7baebd32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
20 deletions
+14
-20
app/assets/javascripts/search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+12
-18
app/views/layouts/_search.html.haml
app/views/layouts/_search.html.haml
+2
-2
No files found.
app/assets/javascripts/search_autocomplete.js.coffee
View file @
ee87d15c
...
@@ -137,13 +137,17 @@ class @SearchAutocomplete
...
@@ -137,13 +137,17 @@ class @SearchAutocomplete
}
}
bindEvents
:
->
bindEvents
:
->
$
(
document
).
on
'click'
,
@
onDocumentClick
@
searchInput
.
on
'keydown'
,
@
onSearchInputKeyDown
@
searchInput
.
on
'keydown'
,
@
onSearchInputKeyDown
@
searchInput
.
on
'keyup'
,
@
onSearchInputKeyUp
@
searchInput
.
on
'keyup'
,
@
onSearchInputKeyUp
@
searchInput
.
on
'click'
,
@
onSearchInputClick
@
searchInput
.
on
'click'
,
@
onSearchInputClick
@
searchInput
.
on
'focus'
,
@
onSearchInputFocus
@
searchInput
.
on
'focus'
,
@
onSearchInputFocus
@
searchInput
.
on
'blur'
,
@
onSearchInputBlur
@
clearInput
.
on
'click'
,
@
onRemoveLocationClick
@
clearInput
.
on
'click'
,
@
onRemoveLocationClick
onDocumentClick
:
(
e
)
=>
if
not
$
.
contains
(
@
dropdown
[
0
],
e
.
target
)
and
@
isFocused
@
onSearchInputBlur
()
enableAutocomplete
:
->
enableAutocomplete
:
->
# No need to enable anything if user is not logged in
# No need to enable anything if user is not logged in
return
if
!
gon
.
current_user_id
return
if
!
gon
.
current_user_id
...
@@ -193,27 +197,21 @@ class @SearchAutocomplete
...
@@ -193,27 +197,21 @@ class @SearchAutocomplete
e
.
stopImmediatePropagation
()
e
.
stopImmediatePropagation
()
onSearchInputFocus
:
=>
onSearchInputFocus
:
=>
@
isFocused
=
true
@
wrap
.
addClass
(
'search-active'
)
@
wrap
.
addClass
(
'search-active'
)
onRemoveLocationClick
:
(
e
)
=>
onRemoveLocationClick
:
(
e
)
=>
e
.
preventDefault
()
e
.
preventDefault
()
@
removeLocationBadge
()
@
removeLocationBadge
()
@
searchInput
.
val
(
''
).
focus
()
@
searchInput
.
val
(
''
).
focus
()
@
skipBlurEvent
=
true
onSearchInputBlur
:
(
e
)
=>
onSearchInputBlur
:
(
e
)
=>
@
skipBlurEvent
=
false
@
isFocused
=
false
@
wrap
.
removeClass
(
'search-active'
)
# We should wait to make sure we are not clearing the input instead
setTimeout
(
=>
return
if
@
skipBlurEvent
@
wrap
.
removeClass
(
'search-active'
)
# If input is blank then restore state
if
@
searchInput
.
val
()
is
''
# If input is blank then restore state
@
restoreOriginalState
()
if
@
searchInput
.
val
()
is
''
@
restoreOriginalState
()
,
150
)
addLocationBadge
:
(
item
)
->
addLocationBadge
:
(
item
)
->
category
=
if
item
.
category
?
then
"
#{
item
.
category
}
: "
else
''
category
=
if
item
.
category
?
then
"
#{
item
.
category
}
: "
else
''
...
@@ -291,9 +289,5 @@ class @SearchAutocomplete
...
@@ -291,9 +289,5 @@ class @SearchAutocomplete
$el
.
removeClass
(
'is-active'
)
$el
.
removeClass
(
'is-active'
)
@
disableAutocomplete
()
@
disableAutocomplete
()
@
onSearchInputFocus
()
@
searchInput
.
val
(
''
).
focus
()
@
searchInput
.
val
(
''
).
focus
()
# We need to wait because of @skipBlurEvent
setTimeout
(
=>
@
onSearchInputFocus
()
,
200
)
app/views/layouts/_search.html.haml
View file @
ee87d15c
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
%a
.is-focused.dropdown-menu-empty-link
%a
.is-focused.dropdown-menu-empty-link
Loading...
Loading...
=
dropdown_loading
=
dropdown_loading
%i
.search-icon
%i
.search-icon
%i
.clear-icon.js-clear-input
%i
.clear-icon.js-clear-input
=
hidden_field_tag
:group_id
,
@group
.
try
(
:id
)
=
hidden_field_tag
:group_id
,
@group
.
try
(
:id
)
=
hidden_field_tag
:project_id
,
@project
&&
@project
.
persisted?
?
@project
.
id
:
''
,
id:
'search_project_id'
=
hidden_field_tag
:project_id
,
@project
&&
@project
.
persisted?
?
@project
.
id
:
''
,
id:
'search_project_id'
...
...
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