HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/ste.komma.pro/resources/js/components/accordionHandler.js
/* ==========================================================================
   Tabs handler
   - Handles the tabs component which has the proper classes.
 ========================================================================== */

const AccordionHandler = {

    accordions : null,

    init: function () {

        AccordionHandler.accordions = document.querySelectorAll('.js-accordion');
        const accordionsLength = AccordionHandler.accordions.length;

        if(isset(AccordionHandler.accordions) && accordionsLength !== 0){
            AccordionHandler.setActiveStepFromHash();
        }
    },

    setActiveStepFromHash: function () {

        // If we have a hash in the url
        if(window.location.hash) {

            const hash = window.location.hash.substring(1);
            const hashItems = document.querySelectorAll('.js-toggle-trigger[data-toggle-id="' + hash + '"]');

            for(let i = 0; i < hashItems.length; i++){
                hashItems[i].classList.add('is-active');
            }
        }
    },
};

AccordionHandler.init();