Sha256: 58e213e7eb923cca7dcdc6b7f1efa80e5c3555078696ec4b4ebf426610ac0c7a

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

class Admin.Views.Accordion extends Backbone.View

  el: '.accordion'

  events:
    "click a.arrow": "toggleSlide"

  initialize: =>
    for el in $('.accordion')
      $(el).children('header').append """
        <a class="arrow" href="#">
          <i class="icon icon-arrow-up"></i>
        </a>
          """
      if $(el).hasClass('closed')
        $(el).find('.arrow i').toggleClass "icon-arrow-up"
        $(el).find('.arrow i').toggleClass "icon-arrow-down"
        $(el).find('.fields').hide()

  toggleSlide: (e) =>
    e.preventDefault()
    acc = $(e.target).parents('.accordion')
    acc.toggleClass "closed"
    if acc.hasClass "closed"
      acc.children('.fields').slideUp()
    else
      acc.children('.fields').slideDown()
    if $(e.target).children('.icon').length == 0
      $(e.target).toggleClass "icon-arrow-up"
      $(e.target).toggleClass "icon-arrow-down"
    else
      $(e.target).children('.icon').toggleClass "icon-arrow-up"
      $(e.target).children('.icon').toggleClass "icon-arrow-down"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cambium-0.3.0 lib/generators/cambium/templates/app/assets/javascripts/admin/views/accordion.js.coffee
cambium-0.2.2 lib/generators/cambium/templates/app/assets/javascripts/admin/views/accordion.js.coffee
cambium-0.2.1 lib/generators/cambium/templates/app/assets/javascripts/admin/views/accordion.js.coffee
cambium-0.2.0 lib/generators/cambium/templates/app/assets/javascripts/admin/views/accordion.js.coffee
cambium-0.0.2 lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/accordion.js.coffee
cambium-0.0.1 lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/accordion.js.coffee