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/Eurotools/euro-tools.nl/resources/assets/js/site/sideMenu.js
/* ==========================================================================
 Navigation handler
 ========================================================================== */

/**
 * Main navigation
 */
var SideMenu = {

    // Initialize click event
    init: function () {

        SideMenu.normalHeight = $(".category-menu ul").css( "height" );
        SideMenu.checkHeight();

        // Bind clicks to burger button and overlay
        $('.category-menu>ul>li>a').bind('click', function (event) {
            if ($(this).parent().parent().has("ul").length > 0) {
                var id = $(this).parent().data("id");
                $(this).parent().toggleClass('active');
                var subMenu = $(".category-menu ul[data-parent-id=" + id + "]");

                subMenu.toggleClass('open');

                SideMenu.checkHeight();

                console.log('0');

                $(".category-menu ul.open li.subcategory-header span, .category-menu ul.open .bg").bind('click', function () {
                    $(".category-menu ul.open").removeClass('open').prev().removeClass('active');
                    $(".category-menu>ul").css('height', SideMenu.normalHeight);
                });

                // $(".category-menu ul li.active a").bind('click', function (ev) {
                //     console.log('1');
                //     $(this).parent().removeClass('active');
                //     var id = $(this).parent().data("id");
                //     $(".category-menu ul[data-parent-id=" + id + "]").removeClass('open');
                //     ev.stopPropagation();
                // });
                event.stopPropagation();

                return false;
                //$(this).child('ul').show();
            }
        });

        $(".category-menu ul.open li.subcategory-header span, .category-menu ul.open .bg").bind('click', function () {
            $(".category-menu ul.open").removeClass('open').prev().removeClass('active');
        });

        // $(".category-menu ul li.active a").bind('click', function () {
        //     console.log('2');
        //     $(this).parent().removeClass('active');
        //     var id = $(this).parent().data("id");
        //     $(".category-menu ul[data-parent-id=" + id + "]").removeClass('open');
        // });

        //$('#close-navigation').bind('click',nav.close)
    },

    checkHeight: function () {
        var subMenuElement = $(".category-menu ul.open");
        if(subMenuElement.height() > ($(".category-menu ul").height()+50)) {
            $(".category-menu>ul").css('height', subMenuElement.height() + 'px');
        } else {
            subMenuElement.css('height', "100%");
        }
    }
};

SideMenu.init();