Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-03-09 05:26:24 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-03-15 21:34:31 +0300
commitd6f822423d0f9c0d463cc25469833009815eae4a (patch)
treef4bfc44286f0efa24255c4f90270d705f728c90e /app/assets/javascripts/search_autocomplete.js.coffee
parent6f449c63ddab0027ef064b436d98c8e820cbe7b3 (diff)
Tweak behaviours
Diffstat (limited to 'app/assets/javascripts/search_autocomplete.js.coffee')
-rw-r--r--app/assets/javascripts/search_autocomplete.js.coffee22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/assets/javascripts/search_autocomplete.js.coffee b/app/assets/javascripts/search_autocomplete.js.coffee
index a6d5ab65239..3cedf1c7b12 100644
--- a/app/assets/javascripts/search_autocomplete.js.coffee
+++ b/app/assets/javascripts/search_autocomplete.js.coffee
@@ -25,7 +25,8 @@ class @SearchAutocomplete
@saveOriginalState()
- if @locationBadgeEl.is(':empty')
+ # If there's no location badge
+ if !@locationBadgeEl.children().length
@createAutocomplete()
@bindEvents()
@@ -65,7 +66,7 @@ class @SearchAutocomplete
createAutocomplete: ->
@query = "?project_id=" + @projectId + "&project_ref=" + @projectRef
- @catComplete = @searchInput.catcomplete
+ @searchInput.catcomplete
appendTo: 'form.navbar-form'
source: @autocompletePath + @query
minLength: 1
@@ -96,6 +97,7 @@ class @SearchAutocomplete
# Return false to avoid focus on the next element
return false
+ @autocomplete = @searchInput.data 'customCatcomplete'
bindEvents: ->
@searchInput.on 'keydown', @onSearchInputKeyDown
@@ -112,14 +114,19 @@ class @SearchAutocomplete
# Remove tag when pressing backspace and input search is empty
if e.keyCode is @keyCode.BACKSPACE and e.currentTarget.value is ''
@removeLocationBadge()
- @destroyAutocomplete()
+ # @destroyAutocomplete()
@searchInput.focus()
else if e.keyCode is @keyCode.ESCAPE
@restoreOriginalState()
else
# Create new autocomplete if hasn't been created yet and there's no badge
- if !@catComplete? and @locationBadgeEl.is(':empty')
- @createAutocomplete()
+ if @autocomplete is undefined
+ if !@locationBadgeEl.children().length
+ @createAutocomplete()
+ else
+ # There's a badge
+ if @locationBadgeEl.children().length
+ @destroyAutocomplete()
onSearchInputFocus: =>
@wrap.addClass('search-active')
@@ -181,5 +188,6 @@ class @SearchAutocomplete
location.href = result.url
destroyAutocomplete: ->
- @catComplete.destroy() if @catComplete?
- @catComplete = null
+ @autocomplete.destroy() if @autocomplete isnt undefined
+ @searchInput.attr('autocomplete', 'off')
+ @autocomplete = undefined