Sha256: 124b4a39082d6b982d22ec23fad99b45cfafb9766f15492eb621debf6ee57847

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

#= require partystreusel/base
#= require partystreusel/scroll_to

class Accordion extends Partystreusel.Base
  @className = 'Accordion'

  constructor: (el) ->
    super
    @$el.find('.accordion__title').on 'click', @toggleItem
    @items = @$el.find('.accordion__item')
    @offset = @$el.data('scroll-offset')

  toggleItem: (e) =>
    item = $(e.target).closest('.accordion__item')
    currentOpen = item.hasClass('accordion__item--open')

    @items.removeClass('accordion__item--open')
    item.toggleClass('accordion__item--open') unless currentOpen

    e.preventDefault()
    Partystreusel.scrollTo(item, @offset)

Partystreusel.Accordion = Accordion

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
partystreusel-1.1.0pre2 app/assets/javascripts/partystreusel/accordion.js.coffee