diff options
author | Josh Frye <joshfng@gmail.com> | 2016-02-04 01:24:14 +0300 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-02-04 19:40:19 +0300 |
commit | 2c871ca1968846871ed264cad34b50611eecae3b (patch) | |
tree | 8c81fdcefe02af0ad8362dd25601f2556d695a09 /app/assets | |
parent | 7522ac0b3cf4a777fda5dce3baa699970e5133a6 (diff) |
Delay filter until user stops typing
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/dashboard.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/issues.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js.coffee | 49 | ||||
-rw-r--r-- | app/assets/javascripts/user.js.coffee | 2 |
4 files changed, 31 insertions, 24 deletions
diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index 00ee503ff16..dc0b9597d1f 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -1,3 +1,3 @@ class @Dashboard constructor: -> - new ProjectsList() + ProjectsList.init() diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index a0acf3028bf..54e00741424 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -45,7 +45,7 @@ filterResults: => form = $("#issue_search_form") - search = $("#issue_search").val() + search = $("#projects-list-filter").val() $('.issues-holder').css("opacity", '0.5') issues_url = form.attr('action') + '?' + form.serialize() diff --git a/app/assets/javascripts/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index b4776493629..384b95118c9 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -1,28 +1,35 @@ -class @ProjectsList - constructor: -> +@ProjectsList = + init: -> $(".projects-list .js-expand").on 'click', (e) -> e.preventDefault() list = $(this).closest('.projects-list') list.find("li").show() list.find("li.bottom").hide() + this.initSearch() - $(".projects-list-filter").keyup -> - terms = $(this).val() - uiBox = $('div.projects-list-holder') - filterSelector = $(this).data('filter-selector') || 'span.filter-title' + initSearch: -> + @timer = null + $("#projects-list-filter").keyup -> + clearTimeout(@timer) + @timer = setTimeout(ProjectsList.filterResults, 500) - $('.projects-list-holder').css("opacity", '0.5') - form = $("#project-list-form") - project_filter_url = form.attr('action') + '?' + form.serialize() - $.ajax - type: "GET" - url: form.attr('action') - data: form.serialize() - complete: -> - $('.projects-list-holder').css("opacity", '1.0') - success: (data) -> - $('.projects-list-holder').html(data.html) - # Change url so if user reload a page - search results are saved - history.replaceState {page: project_filter_url}, document.title, project_filter_url - dataType: "json" - uiBox.find("ul.projects-list li.bottom").hide() + filterResults: => + form = $("#project-list-form") + search = $("#issue_search").val() + uiBox = $('div.projects-list-holder') + + $('.projects-list-holder').css("opacity", '0.5') + + project_filter_url = form.attr('action') + '?' + form.serialize() + $.ajax + type: "GET" + url: form.attr('action') + data: form.serialize() + complete: -> + $('.projects-list-holder').css("opacity", '1.0') + success: (data) -> + $('.projects-list-holder').html(data.html) + # Change url so if user reload a page - search results are saved + history.replaceState {page: project_filter_url}, document.title, project_filter_url + dataType: "json" + uiBox.find("ul.projects-list li.bottom").hide() diff --git a/app/assets/javascripts/user.js.coffee b/app/assets/javascripts/user.js.coffee index ec4271b092c..eb7f7bb26b1 100644 --- a/app/assets/javascripts/user.js.coffee +++ b/app/assets/javascripts/user.js.coffee @@ -1,7 +1,7 @@ class @User constructor: -> $('.profile-groups-avatars').tooltip("placement": "top") - new ProjectsList() + ProjectsList.init() $('.hide-project-limit-message').on 'click', (e) -> path = '/' |