<commit_before># 
# Params: @args {
#   parent: parent element
#   multiplePanels: can you have multiple panels open
#   callback: optional function
#   activeClass: optional args
#     elem: element to add/remove the class
#     className: classname to add/remove
# }
# 

define ['jquery'], ($) ->
 
  class Accordion

    config =
      multiplePanels: false

    openPanel : (panel) ->
      if config.multiplePanels is false then @closeAllPanels()
      panel = @sanitisePanel(panel)
      panel.removeClass('is-hidden')
      if config.hasOwnProperty('activeClass')
        panel.closest(config.activeClass.elem).addClass(config.activeClass.className)

    closePanel : (panel) ->
      panel = @sanitisePanel(panel)
      panel.addClass('is-hidden')
      if config.hasOwnProperty('activeClass')
        panel.closest(config.activeClass.elem).removeClass(config.activeClass.className)

    closeAllPanels : (panels) ->
      @panels.addClass('is-hidden')
      if config.hasOwnProperty('activeClass')
        @parent.find(config.activeClass.elem).removeClass(config.activeClass.className)

    refresh : () ->
      @panels = @parent.find('.js-accordion-panel')
      @closeAllPanels(@panels)

    constructor : (args) ->
      config = $.extend config, args
      @parent = $(config.parent)
      @panels = @parent.find('.js-accordion-panel')

      @sanitisePanel = (panel) =>
        if typeof(panel) == 'number'
          $(@panels[panel])
        else
          $(panel)

      @closeAllPanels(@panels)
      config.callback && config.callback(@parent)<commit_msg>Accordion closes an open tab on click<commit_after># 
# Params: @args {
#   parent: parent element
#   multiplePanels: can you have multiple panels open
#   callback: optional function
#   activeClass: optional args
#     elem: element to add/remove the class
#     className: classname to add/remove
# }
# 

define ['jquery'], ($) ->
 
  class Accordion

    config =
      multiplePanels: false

    openPanel : (panel) ->
      panel = @sanitisePanel(panel)
      if config.hasOwnProperty('activeClass')
        panelContainer = panel.closest(config.activeClass.elem)
        if panelContainer.hasClass(config.activeClass.className)
          @closePanel(panel)
        else
          if config.multiplePanels is false then @closeAllPanels()
          panel.removeClass('is-hidden')
          panel.closest(config.activeClass.elem).addClass(config.activeClass.className)
      else
        if config.multiplePanels is false then @closeAllPanels()
        panel.removeClass('is-hidden')
      

    closePanel : (panel) ->
      panel = @sanitisePanel(panel)
      panel.addClass('is-hidden')
      if config.hasOwnProperty('activeClass')
        panel.closest(config.activeClass.elem).removeClass(config.activeClass.className)

    closeAllPanels : (panels) ->
      @panels.addClass('is-hidden')
      if config.hasOwnProperty('activeClass')
        @parent.find(config.activeClass.elem).removeClass(config.activeClass.className)

    refresh : () ->
      @panels = @parent.find('.js-accordion-panel')
      @closeAllPanels(@panels)

    constructor : (args) ->
      config = $.extend config, args
      @parent = $(config.parent)
      @panels = @parent.find('.js-accordion-panel')

      @sanitisePanel = (panel) =>
        if typeof(panel) == 'number'
          $(@panels[panel])
        else if panel.jquery isnt undefined
          panel
        else
          $(panel)

      @closeAllPanels(@panels)
      config.callback && config.callback(@parent)
{'fraction_non_alphanumeric': 0.12411648289510885, 'fraction_numerical': 0.0, 'mean_word_length': 2.8582333696837514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2272574', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1019, 'n_words': 203}