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:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-03 20:18:23 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-03 20:18:23 +0400
commit5f6eb09cdf1bb264e788521cd7289e419fd68e13 (patch)
tree246ad4c5dd621e6179e62f509f268f90d73d49cd /app/assets
parente8f1331fa4b3f4c4037f6509b2a846f521f506fc (diff)
Improve issue filtering. Make tests pass
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/issues.js.coffee40
1 files changed, 23 insertions, 17 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee
index 54de93a4e04..2499ad5ad80 100644
--- a/app/assets/javascripts/issues.js.coffee
+++ b/app/assets/javascripts/issues.js.coffee
@@ -43,25 +43,31 @@
$(".selected_issue").bind "change", Issues.checkChanged
-
+ # Make sure we trigger ajax request only after user stop typing
initSearch: ->
- form = $("#issue_search_form")
- last_terms = ""
+ @timer = null
$("#issue_search").keyup ->
- terms = $(this).val()
- unless terms is last_terms
- last_terms = terms
- if terms.length >= 2 or terms.length is 0
- $.ajax
- type: "GET"
- url: location.href
- data: "issue_search=" + terms
- complete: ->
- $(".loading").hide()
- success: (data) ->
- $('.issues-holder').html(data.html)
- Issues.reload()
- dataType: "json"
+ clearTimeout(@timer);
+ @timer = setTimeout(Issues.filterResults, 500)
+
+ filterResults: =>
+ form = $("#issue_search_form")
+ search = $("#issue_search").val()
+ $('.issues-holder').css("opacity", '0.5')
+ issues_url = form.attr('action') + '? '+ form.serialize()
+
+ $.ajax
+ type: "GET"
+ url: form.attr('action')
+ data: form.serialize()
+ complete: ->
+ $('.issues-holder').css("opacity", '1.0')
+ success: (data) ->
+ $('.issues-holder').html(data.html)
+ # Change url so if user reload a page - search results are saved
+ History.replaceState {page: issues_url}, document.title, issues_url
+ Issues.reload()
+ dataType: "json"
checkChanged: ->
checked_issues = $(".selected_issue:checked")