Sha256: 0ea6a90735c6278de5819e3bbc30cc8cd5262e6d45247489564804ad6b02fcae

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

class App.UI.Tabs
  constructor: (node, delegator) ->
    @sel = $(node)
    @delegator = delegator
    this.handle()

  handle: ->
    elementsSize = @sel.find('a').size()
    @sel.find('a').click (e) =>
      e.preventDefault()
      return if $(e.target).hasClass "active"
      index = 0
      for child in $(e.target).parent().children('a')
        break if $(child).text() is $(e.target).text()
        index += 1
      width = parseInt @sel.css 'width'
      left = width / elementsSize * index
      @sel.find('a.active').removeClass 'active'
      $(e.target).addClass 'active'
      @sel.find('div.background').velocity {left: left}, 200
      @delegator[$(e.target).data("action")]()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loco-rails-0.0.1 lib/assets/javascripts/loco/ui/tabs.coffee