<?xml version="1.0" encoding="UTF-8"?>
<root>
    <default>
        <includes>
            <!--
                Path to css and js files into plugins folder.
                If your files are not in plugins folder, use absolute paths.
            -->
            <css>
                <file>accordion/badger-accordion.css</file>
            </css>
            <js>
                <file>accordion/badger-accordion.js</file>
            </js>
        </includes>
        <js_code><![CDATA[    if (typeof(phpfbAccordion) == "undefined") {
        window.phpfbAccordion = [];
        var firstInvalid,
            fsIndex;
    }
    phpfbAccordion["%selector%"] = new BadgerAccordion(document.querySelector("%selector%"));
    fsIndex = 0;
    document.querySelectorAll('%selector% fieldset').forEach((fs) => {
        fs.dataset.acIndex = fsIndex;
        fsIndex ++;
    });
    let invalidClasses = ['is-invalid', 'is-danger', 'is-invalid-input', 'uk-form-danger'];
    firstInvalid = null;
    invalidClasses.forEach(ic => {
        if (document.querySelector('%selector% .' + ic) !== null) {
            firstInvalid = document.querySelector('%selector% .' + ic);
        }
    });
    setTimeout(() => {
        phpfbAccordion["%selector%"].calculateAllPanelsHeight();
        if (firstInvalid !== null) {
            let fieldset = firstInvalid.closest('fieldset');
            let fieldsetIndex = fieldset.dataset.acIndex;
            phpfbAccordion["%selector%"].open(fieldsetIndex);
        } else {
            phpfbAccordion["%selector%"].open(0);
        }
    }, 200);]]>
        </js_code>
    </default>

    <custom>
        <!--
            If you need differents includes for your custom code,
            copy the default '<includes>' structure and put the needed files into '<file>' nodes.
            You can add several files nodes if necessary.
        -->
        <js_code>
            <!-- your custom code here -->
        </js_code>
    </custom>
</root>
