Sha256: 5b4289e79e8370afc35fa1960ea500b53f93194da2a222bb7d8491fe3d47ea8c

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# -----------------------------------------------------------------------------
# LIST TABS
# -----------------------------------------------------------------------------
@listTabs =

  # PRIVATE ===================================================================

  _bind_tabs: ->
    @$title.addClass "title-with-tabs"
    @$tabs =$ "<aside class='header-tabs'>"
    @$title.after @$tabs
    @tabLinks = []

    for title, urlParams of @config.listTabs
      @_add_tab(title, urlParams)

    $firstTab = @tabLinks[0]
    @selectTab($firstTab, false)

  _add_tab: (title, urlParams) ->
    $tab =$ "<button>#{title}</button>"
    @$tabs.append $tab
    @tabLinks.push $tab

    $tab.on "click", (e) =>
      $tab =$ e.currentTarget
      @selectTab($tab, true)

  # PUBLIC ====================================================================

  selectTab: ($tab, resetList) ->
    @$tabs.children().removeClass "active"
    $tab.addClass "active"
    tabName = $tab.html()
    params = @config.listTabs[tabName]

    if resetList
      @showSpinner()
      @config.arrayStore.filter(params)
    else
      @config.arrayStore.filterParams = params

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chr-0.5.8 app/assets/javascripts/chr/list_tabs.coffee