Sha256: 3560fe7b4a6e18ec6ab4c0e2de06b6eaa676899080daafd25ef0ac0c74b2af3f
Contents?: true
Size: 1004 Bytes
Versions: 2
Compression:
Stored size: 1004 Bytes
Contents
# Easy handling of accordion elements # The structure should be as follows: # # <div class='accordion'> # <div class='accordion-item'> # <div class='title'>Title</div> # <div class='content'> ... your content ... </div> # </div> # # // repeat accordion-items ... # </div> # window.SC ||= {} class window.SC.Accordion extends Backbone.View events: "click .title" : "handleClick" initialize: -> @items = @$("> .accordion-item") @open = null @initiallyOpenItem() initiallyOpenItem: -> if window.location.hash elem = $(window.location.hash) @openItem(elem.parent()) if elem.hasClass("title") openItem: (elem) -> @closeItem(@open) if @open @open = elem.addClass("open") closeItem: (elem) -> elem.removeClass("open") @open = null toggleItem: (elem) -> if elem.hasClass("open") @closeItem(elem) else @openItem(elem) handleClick: (event) => item = $(event.currentTarget).parent() @toggleItem(item)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
partystreusel-0.0.2 | vendor/assets/javascripts/sc.accordion.js.coffee |
partystreusel-0.0.1 | vendor/assets/javascripts/sc.accordion.js.coffee |