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/inzigd.komma.pro/resources/js/site/navigationHandler.js
/* ==========================================================================
   Navigation handler
   - Handles the navigation component which has the proper classes.
 ========================================================================== */

const NavigationHandler = {

    init: function () {
        const navTrigger = document.querySelector('.js-nav-trigger');
        NavigationHandler.initNavigation(navTrigger);
    },

    initNavigation: function (navTrigger) {
        navTrigger.addEventListener('click', NavigationHandler.toggleNavigation, false);
    },

toggleNavigation: function (event) {
        const nav = document.querySelector('.js-nav');

        // Check if nav exists
        if (!nav) return;

        // Prevent default link behavior
        event.preventDefault();

        // If the nav is already active, collapse it and quit
        if (document.body.classList.contains('nav-is-active')) {
            document.body.classList.remove('nav-is-active');
            return;
        }

        // Toggle active nav by setting a class on the body
        document.body.classList.toggle('nav-is-active');
    }
};

NavigationHandler.init();