Sha256: f6f548831239b9364002a06390d61d33968e8e749d7b5fbc4a1415873a30533c

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

# Tabs hash management adapted from SO answer :
#   http://stackoverflow.com/a/21443271/685925
#
class Para.Tabs
  constructor: (options = {}) ->
    @$el = $(options.el)
    @showActiveTab()
    @$('a[data-toggle="tab"]').on('shown.bs.tab', @onTabShown)

  showActiveTab: ->
    @$('a[href="' + location.hash + '"]').tab('show') if location.hash isnt ''

  onTabShown: (e) =>
    tabHash = $(e.target).attr('href').substr(1)
    history.pushState(null, null, "##{ tabHash }")

  $: (args...) ->
    $.fn.find.apply(@$el, args)

$(document).on 'page:change', ->
  $('[data-form-tabs]').each (i, el) -> new Para.Tabs(el: el)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
para-0.5.4 app/assets/javascripts/para/admin/tabs.coffee