Sha256: cb3a189f4b53e79effc2ce8d795c62aa7681273e2e79aa5b42d423fa079a0481
Contents?: true
Size: 1.38 KB
Versions: 42
Compression:
Stored size: 1.38 KB
Contents
class NfgUi.CollapsibleToggle constructor: (@el) -> @target = @collapseTarget() @iconBase = 'fa' @collapseIconClass = "fa-#{@el.data 'collapsed-icon'}" @collapsedIconClass = "fa-#{@el.data 'collapse-icon'}" @initialize() @el.click (e) => @swapIcon() initialize: -> if @target.hasClass 'show' @el .find ".#{@collapseIconClass}" .removeClass @collapseIconClass .addClass @collapsedIconClass else @el .find ".#{@collapsedIconClass}" .removeClass @collapsedIconClass .addClass @collapseIconClass collapseTarget: -> if @el.is('a') then return $(@el.attr 'href') if @el.is('button') then return $(@el.data 'target') swapIcon: -> @target.on 'show.bs.collapse', (e) => @el .find ".#{@collapseIconClass}" .removeClass @collapseIconClass .addClass @collapsedIconClass @target.on 'hide.bs.collapse', (e) => @el .find ".#{@collapsedIconClass}" .removeClass @collapsedIconClass .addClass @collapseIconClass initNfgUiCollapsibleToggle = () -> el = $("[data-toggle='collapse'][data-collapse-icon][data-collapsed-icon]") return unless el.length el.each -> inst = new NfgUi.CollapsibleToggle $(@) if NfgUi.turbolinks $(document).on('turbolinks:load', initNfgUiCollapsibleToggle) else $(document).ready(initNfgUiCollapsibleToggle)
Version data entries
42 entries across 42 versions & 1 rubygems