diff options
author | Josh Frye <joshfng@gmail.com> | 2016-02-03 18:21:14 -0500 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-02-04 13:03:41 -0500 |
commit | 2ad094132de3c491511261bf0e6a2e577fd699dd (patch) | |
tree | 7ba4cf6ed687cde58b13a0c4151ac243db09e47f /app/assets/javascripts/projects_list.js.coffee | |
parent | 2c871ca1968846871ed264cad34b50611eecae3b (diff) | |
download | gitlab-ce-2ad094132de3c491511261bf0e6a2e577fd699dd.tar.gz |
Various filter fixes
Diffstat (limited to 'app/assets/javascripts/projects_list.js.coffee')
-rw-r--r-- | app/assets/javascripts/projects_list.js.coffee | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/app/assets/javascripts/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index 384b95118c9..ebf7140b7e3 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -1,35 +1,24 @@ -@ProjectsList = - init: -> +class @ProjectsList + constructor: -> $(".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() - initSearch: -> - @timer = null - $("#projects-list-filter").keyup -> - clearTimeout(@timer) - @timer = setTimeout(ProjectsList.filterResults, 500) + $(".projects-list-filter").keyup -> + terms = $(this).val() + uiBox = $('div.projects-list-holder') + filterSelector = $(this).data('filter-selector') || 'span.filter-title' - filterResults: => - form = $("#project-list-form") - search = $("#issue_search").val() - uiBox = $('div.projects-list-holder') + if terms == "" || terms == undefined + uiBox.find("ul.projects-list li").show() + else + uiBox.find("ul.projects-list li").each (index) -> + name = $(this).find(filterSelector).text() - $('.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() + if name.toLowerCase().search(terms.toLowerCase()) == -1 + $(this).hide() + else + $(this).show() + uiBox.find("ul.projects-list li.bottom").hide() |