The Framework Code

twigs/framework/util/accmacro.twig

File List

{% macro accordion(id, tabs, carets = FALSE) %}
    {% import '@content/iconmacro.twig' as fa %}
    <div class="accordion" id="{{id}}">
        {% for t in tabs %}
            <div class="card">
                <div class="card-header" id="{{t.id}}">
                    <h4 class="mb-0">
                        <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#col{{t.id}}" aria-expanded="true" aria-controls="col{{t.id}}">{{t.title}}{% if carets %} {{fa.fa('caret-right')}}{% endif %}</button>
                    </h4>
                </div>
                <div id="col{{t.id}}" class="collapse" aria-labelledby="{{t.id}}" data-parent="#{{id}}">
                    <div class="card-body">
                        {% if t.with is defined %}
                            {% include t.file with t.with%}
                        {% else %}
                            {% include t.file%}
                        {% endif %}
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endmacro accordion %}

{% macro caretJS(id) %}
    $('#{{id}}').on('show.bs.collapse', function(e){
        let ch = $(e.target).attr('aria-labelledby');
        $('.fa-caret-right', $('#'+ch)).removeClass('fa-caret-right').addClass('fa-caret-down');
    }).on('hide.bs.collapse', function(e) {
        let ch = $(e.target).attr('aria-labelledby');
        $('.fa-caret-down', $('#'+ch)).removeClass('fa-caret-down').addClass('fa-caret-right');
    });
{% endmacro caretJS %}