Sha256: e5f091d885ffded2b85070bb3fcfc09f7d68aa324b1003b84b50b6298afc6dc8

Contents?: true

Size: 1.84 KB

Versions: 5

Compression:

Stored size: 1.84 KB

Contents

format :html do
  def accordion_group list, collapse_id=card.cardname.safe_key, args={}
    accordions = ""
    index = 1
    case list
    when Array then accordions = list.join
    when String then accordions = list
    else
      list.each_pair do |title, content|
        accordions << accordion(title, content, "#{collapse_id}-#{index}")
        index += 1
      end
    end
    add_class args, "panel-group"

    wrap_with :div, class: args[:class], id: "accordion-#{collapse_id}",
                    role: "tablist", "aria-multiselectable" => "true" do
      accordions
    end
  end

  def accordion title, content, collapse_id=card.cardname.safe_key
    accordion_content =
      case content
      when Hash  then accordion_group(content, collapse_id)
      when Array then content.present? && list_group(content)
      when String then content
      end
    <<-HTML.html_safe
      <div class="panel panel-default">
        #{accordion_panel(title, accordion_content, collapse_id)}
      </div>
    HTML
  end

  def accordion_panel title, body, collapse_id, panel_heading_link=false
    if body
      <<-HTML
        <div class="panel-heading" role="tab" id="heading-#{collapse_id}">
          <h4 class="panel-title">
            <a data-toggle="collapse" data-parent="#accordion-#{collapse_id}" \
               href="##{collapse_id}" aria-expanded="true" \
               aria-controls="#{collapse_id}">
              #{title}
            </a>
          </h4>
        </div>
        <div id="#{collapse_id}" class="panel-collapse collapse" \
               role="tabpanel" aria-labelledby="heading-#{collapse_id}">
          <div class="panel-body">
            #{body}
          </div>
        </div>
      HTML
    else
      <<-HTML
        <li class="list-group-item">
          <h4 class="panel-title">#{title}</h4>
        </li>
      HTML
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.20.4 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.20.3 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.20.2 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.20.1 mod/bootstrap/set/all/bootstrap/accordion.rb
card-1.20.0 mod/bootstrap/set/all/bootstrap/accordion.rb