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/rentman2019.komma.pro/resources/assets/js/site/compareTableHandler.js
/* ==========================================================================
   CompareTableHandler handler
   - Handles the CompareTable component which has the proper classes.
 ========================================================================== */

export const CompareTableHandler = {

    init: function () {

        const compareTableList = document.querySelectorAll('.js-compare-table');
        const compareTableListCount = compareTableList.length;

        if(isset(compareTableList) && compareTableListCount !== 0){
            for(let i = 0; i < compareTableListCount; i++){
                const compareTable = compareTableList[i];
                compareTable.addEventListener('click', CompareTableHandler.toggleCompareTable, false);
            }
        }
    },

    toggleCompareTable: function (event) {
        const item = event.target;

        // Bail if we didn't click on the toggle element
        if (!item.classList.contains('js-toggle-description')) return;

        item.classList.toggle('hide-description');
        item.parentElement.classList.toggle('is-open');

        // var index = indexInParent(item);
        // var parentIndex = indexInParent(item.parentNode);
        // var packages = item.closest('.js-compare-table').querySelectorAll('.package');
        //
        // for (var i = 0; i < packages.length; i++) {
        //     var section = packages[i].children[parentIndex];
        //     section.children[index].classList.toggle('open');
        // }
        //
        // // Toggle our content by setting the active class
        // item.classList.toggle('open');
    }
};