BigW Consortium Gitlab

dashboard.js.coffee 836 Bytes
Newer Older
1 2 3 4
class Dashboard
  constructor: ->
    @initSidebarTab()

5
    $(".dash-filter").keyup ->
6
      terms = $(this).val()
7
      uiBox = $(this).parents('.panel').first()
8
      if terms == "" || terms == undefined
9
        uiBox.find(".dash-list li").show()
10
      else
11
        uiBox.find(".dash-list li").each (index) ->
12
          name = $(this).find(".filter-title").text()
13

14
          if name.toLowerCase().search(terms.toLowerCase()) == -1
15 16 17 18 19 20
            $(this).hide()
          else
            $(this).show()



21 22 23 24 25 26 27 28 29 30 31 32 33
  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