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
Boxiang Sun
gitlab-ce
Commits
8c1d50e6
Commit
8c1d50e6
authored
Mar 23, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes removing the location badge with backspace on the last character
parent
abe56ad6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
app/assets/javascripts/search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+19
-4
No files found.
app/assets/javascripts/search_autocomplete.js.coffee
View file @
8c1d50e6
...
@@ -36,6 +36,8 @@ class @SearchAutocomplete
...
@@ -36,6 +36,8 @@ class @SearchAutocomplete
@
searchInput
.
addClass
(
'disabled'
)
@
searchInput
.
addClass
(
'disabled'
)
@
saveTextLength
()
@
bindEvents
()
@
bindEvents
()
# Finds an element inside wrapper element
# Finds an element inside wrapper element
...
@@ -45,6 +47,9 @@ class @SearchAutocomplete
...
@@ -45,6 +47,9 @@ class @SearchAutocomplete
saveOriginalState
:
->
saveOriginalState
:
->
@
originalState
=
@
serializeState
()
@
originalState
=
@
serializeState
()
saveTextLength
:
->
@
lastTextLength
=
@
searchInput
.
val
().
length
createAutocomplete
:
->
createAutocomplete
:
->
@
searchInput
.
glDropdown
@
searchInput
.
glDropdown
filterInputBlur
:
false
filterInputBlur
:
false
...
@@ -65,6 +70,8 @@ class @SearchAutocomplete
...
@@ -65,6 +70,8 @@ class @SearchAutocomplete
# Prevent multiple ajax calls
# Prevent multiple ajax calls
return
if
@
loadingSuggestions
return
if
@
loadingSuggestions
return
if
@
badgePresent
()
@
loadingSuggestions
=
true
@
loadingSuggestions
=
true
jqXHR
=
$
.
get
(
@
autocompletePath
,
{
jqXHR
=
$
.
get
(
@
autocompletePath
,
{
...
@@ -102,10 +109,11 @@ class @SearchAutocomplete
...
@@ -102,10 +109,11 @@ class @SearchAutocomplete
scope
:
@
scopeInputEl
.
val
()
scope
:
@
scopeInputEl
.
val
()
# Location badge
# Location badge
_location
:
$
.
trim
(
@
locationText
.
text
()
)
_location
:
@
locationText
.
text
(
)
}
}
bindEvents
:
->
bindEvents
:
->
@
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
...
@@ -123,12 +131,19 @@ class @SearchAutocomplete
...
@@ -123,12 +131,19 @@ class @SearchAutocomplete
onDropdownOpen
:
(
e
)
=>
onDropdownOpen
:
(
e
)
=>
@
dropdown
.
dropdown
(
'toggle'
)
@
dropdown
.
dropdown
(
'toggle'
)
onSearchInputKeyDown
:
=>
# Saves last length of the entered text
@
saveTextLength
()
onSearchInputKeyUp
:
(
e
)
=>
onSearchInputKeyUp
:
(
e
)
=>
switch
e
.
keyCode
switch
e
.
keyCode
when
KEYCODE
.
BACKSPACE
when
KEYCODE
.
BACKSPACE
if
e
.
currentTarget
.
value
is
''
# when trying to remove the location badge
if
@
lastTextLength
is
0
and
@
badgePresent
()
@
removeLocationBadge
()
@
removeLocationBadge
()
@
searchInput
.
focus
()
# When removing the last character and no badge is present
if
@
lastTextLength
is
1
and
!
@
badgePresent
()
@
disableAutocomplete
()
@
disableAutocomplete
()
when
KEYCODE
.
ESCAPE
when
KEYCODE
.
ESCAPE
if
@
badgePresent
()
if
@
badgePresent
()
...
...
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