Sha256: 3dbac7f70e801552f1bb4a42f0278a0fd90e4430691df1b475878394637d6344

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

# -----------------------------------------------------------------------------
# VIEW TABS
# -----------------------------------------------------------------------------

@viewTabs =

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

  _build_tabs: ->
    @$title.addClass 'title-with-tabs'

    @_create_tabs()
    @_activate_tab(0)


  _create_tabs: ->
    @tabGroups = []
    groupsHash      = {}

    for g in @form.groups
      groupsHash[g.klassName] = g

    @$tabs =$ "<aside class='header-tabs'></aside>"
    @$title.after @$tabs

    for tab_id, tab_title of @config.viewTabs
      @tabGroups.push(groupsHash[tab_id])
      @$tabs.append(@_create_button(tab_title))


  _create_button: (name) ->
    $tabButton =$ "<a href='#'>#{ name }</a>"
    $tabButton.on 'click', (e) =>
      @_on_tab_click($(e.currentTarget))
      e.preventDefault()
    return $tabButton


  _on_tab_click: ($link) ->
    index = @$tabs.children().index($link)
    @_activate_tab(index)


  _activate_tab: (index) ->
    @$tabs.children().removeClass('active')
    @$tabs.find(":nth-child(#{ index + 1 })").addClass('active')

    for g in @tabGroups
      g.$el.hide()

    @tabGroups[index].$el.show()

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
chr-0.5.1 app/assets/javascripts/chr/view_tabs.coffee
chr-0.5.0 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.25 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.24 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.23 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.22 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.21 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.20 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.19 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.18 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.17 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.15 app/assets/javascripts/chr/view_tabs.coffee
chr-0.4.14 app/assets/javascripts/chr/view_tabs.coffee