debian-mirror-gitlab/app/assets/javascripts/projects_list.js.coffee

33 lines
1,004 B
CoffeeScript
Raw Normal View History

2015-04-26 12:48:37 +05:30
class @ProjectsList
constructor: ->
$(".projects-list .js-expand").on 'click', (e) ->
e.preventDefault()
2016-04-02 18:10:28 +05:30
$projectsList = $(this).closest('.projects-list')
ProjectsList.showPagination($projectsList)
$projectsList.find('li.bottom').hide()
2015-04-26 12:48:37 +05:30
2016-04-02 18:10:28 +05:30
$("#filter_projects").on 'keyup', ->
ProjectsList.filter_results($("#filter_projects"))
2015-04-26 12:48:37 +05:30
2016-04-02 18:10:28 +05:30
@showPagination: ($projectsList) ->
$projectsList.find('li').show()
$('.gl-pagination').show()
2015-04-26 12:48:37 +05:30
2016-04-02 18:10:28 +05:30
@filter_results: ($element) ->
terms = $element.val()
filterSelector = $element.data('filter-selector') || 'span.filter-title'
$projectsList = $('.projects-list')
2015-04-26 12:48:37 +05:30
2016-04-02 18:10:28 +05:30
if not terms
ProjectsList.showPagination($projectsList)
else
$projectsList.find('li').each (index) ->
$this = $(this)
name = $this.find(filterSelector).text()
if name.toLowerCase().indexOf(terms.toLowerCase()) == -1
$this.hide()
else
$this.show()
$('.gl-pagination').hide()