Sha256: 77fc3fa1c3a607c44e2b5d2c10e3c00e7805a0bcdac3f7aa9ce50db409c1bacf

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

#= require partystreusel/base

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

  constructor: (el) ->
    super
    @$el.find('.js-offcanvas__toggler').on 'click', @toggle
    @$el.find('.offcanvas__overlay').on 'click', @toggle
    @$el.find('.offcanvas-nav__link').on 'click', @toggleNavLink

  toggle: =>
    @$el.toggleClass('offcanvas--open')
    if @$el.hasClass('offcanvas--open')
      @trigger('open', @$el)
    else
      @trigger('close', @$el)

  toggleNavLink: (e) =>
    navLink = $(e.target).closest('.offcanvas-nav__link')
    subNav = navLink.next('.offcanvas-nav__sub')
    return if subNav.length == 0
    e.preventDefault()
    subNav.toggleClass('offcanvas-nav__sub--open')

Partystreusel.Offcanvas = Offcanvas

Version data entries

1 entries across 1 versions & 1 rubygems

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