gitlab-org--gitlab-foss/app/assets/javascripts/dashboard.js.coffee

34 lines
837 B
CoffeeScript
Raw Normal View History

2013-05-02 07:36:53 -04:00
class Dashboard
constructor: ->
@initSidebarTab()
$(".dash-filter").keyup ->
2013-06-19 06:52:25 -04:00
terms = $(this).val()
uiBox = $(this).parents('.ui-box').first()
2013-06-19 06:52:25 -04:00
if terms == "" || terms == undefined
uiBox.find(".dash-list li").show()
2013-06-19 06:52:25 -04:00
else
uiBox.find(".dash-list li").each (index) ->
2013-07-13 02:55:46 -04:00
name = $(this).find(".filter-title").text()
2013-06-19 06:52:25 -04:00
if name.toLowerCase().search(terms.toLowerCase()) == -1
2013-06-19 06:52:25 -04:00
$(this).hide()
else
$(this).show()
2013-05-02 07:36:53 -04:00
initSidebarTab: ->
key = "dashboard_sidebar_filter"
# store selection in cookie
$('.dash-sidebar-tabs a').on 'click', (e) ->
$.cookie(key, $(e.target).attr('id'))
# show tab from cookie
sidebar_filter = $.cookie(key)
$("#" + sidebar_filter).tab('show') if sidebar_filter
@Dashboard = Dashboard