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/straffer.komma.nl/wwwroot/js/mobile.js
var $mbBlur = $('.blur');
var $mb = $('.mobile');
var $mbContent = $('.mobile .mb_content');
var $mbDropdown = $('.mb_dropdown');

var $mbBtnNav = $('.mobile_btn.nav');
var $mbBtnContact = $('.mobile_btn.contact');

var $mbNav = $('#mobile_nav');
var $mbContact = $('#mobile_contact');

// Platforms
var mobileSafari = false;
var mobileAndroid = false;
mbCheckPlatform();


// Maximize content height
mbResize();
$(window).resize(mbResize);

// Disable hover on phones
if(mobileAndroid || mobileSafari)
{
    $mb.addClass('phone');
}

/** Click Events **/

// On button click
$mbBtnNav.click(function(){
    if($mbNav.height() > 0)
    {
        // Close lists
        mbClose($mbNav,$mbBtnNav);

        // Close dropdown lists
        var allLists = $mbNav.find('.mb_dropdown');
        for(var i=0;i<allLists.length;i++)
        {
            var $childUl = allLists.eq(i).children('ul').eq(0);
            mbCloseSub($childUl);
        }
        // Unlock body
        mnUnlockBody();

    }
    else
    {
        mbClose($mbContact,$mbBtnContact);
        mbOpen($mbNav,$mbBtnNav);
        mnLockBody();
    }
});

// On button click
$mbBtnContact.click(function(){
    if($mbContact.height() > 0)
    {
        mbClose($mbContact,$mbBtnContact);

        // Unlock body
        mnUnlockBody();

        // Style
        $mbBtnContact.removeClass('selected');
    }
    else
    {
        mbClose($mbNav,$mbBtnNav);
        mbOpen($mbContact,$mbBtnContact);
        mnLockBody();

        // Style
        $mbBtnContact.addClass('selected');
    }
});

// On button click
$mbBlur.click(function(){
    mbClose($mbContact,$mbBtnContact);
    mbClose($mbNav,$mbBtnNav);
    mnUnlockBody();
});

// Dropdown click
$mbDropdown.children('.title').click(function(){
    var $ul = $(this).siblings('ul');
    if($ul.height() > 0)
    {
        mbCloseSub($ul.eq(0));
        var allLists = $ul.find('.mb_dropdown');
        for(var i=0;i<allLists.length;i++)
        {
            var $childUl = allLists.eq(i).children('ul').eq(0);
            mbCloseSub($childUl);
        }
    }
    else
    {
        mbOpenSub($ul.eq(0));
    }
});


/** Functions **/

// Set mobile content height
function mbResize()
{
    var h100 = $(window).height() - 60; // - header
    if(mobileSafari) h100 += 70;
    if(mobileAndroid) h100 += 70;

    $mbContent.css({ maxHeight: h100+'px' });

    // resize blur
    $mbBlur.css({ height: (h100+60)+'px'});
}

// Show navigation
function mbOpen($obj,$btn)
{
    // Slide out menu
    $obj.css({ display: 'block' });
    var ulH = $obj.children('.inner').outerHeight();
    $obj.stop().animate({ height: ulH+'px' },300,function()
    {
        $obj.css({ height: 'auto' });
    });

    // Style
    $btn.addClass('selected');
}

// Hide navigation
function mbClose($obj,$btn)
{
    // Collapese menu
    $obj.animate({ height: 0 },300,function()
    {
        $obj.css({ display: 'none'  });
    });

    // Style
    $btn.removeClass('selected');
}

// Open submenu
function mbOpenSub($ul)
{
    // Slide out menu
    $ul.css({ display: 'block' });
    var ulH = $ul.children().size() * $ul.children('li').eq(0).height();
    $ul.stop().animate({ height: ulH+'px' },300,function()
    {
        $ul.css({ height: 'auto' });
    });

    // Style
    $ul.parent('li').addClass('selected');
}

// Close submenu
function mbCloseSub($ul)
{
    // Collapese menu
    $ul.stop().animate({ height: 0 },300,function()
    {
        $ul.css({ display: 'none' });
    });

    // Style
    $ul.parent('li').removeClass('selected');
}

// Lock the body underneath the mobile menu
function mnLockBody()
{
    //  Get 100%
    var h100 = $(window).height();
    if(mobileSafari) h100 += 70;
    if(mobileAndroid) h100 += 70;

    // Disable mouse scroll
    //$body.css({height: h100+'px', overflowY: 'hidden'  });
    //$body.removeClass('scrollable');

    // Show blur
    $mbBlur.css({ display: 'block', height: h100+'px'});
    $mbBlur.animate({ opacity: .6 },300);
}

// Unlock the body underneath the mobile menu
function mnUnlockBody()
{
    // Enable mouse scroll
    //$body.css({  height: '', overflowY: ''  });
    //$body.addClass('scrollable');

    // Hide blur
    $mbBlur.animate({ opacity: 0 },300,function()
    {
        $mbBlur.css({ display: 'none' });
    });
}


// Check if mobile safari
function mbCheckPlatform()
{
    // Assign a variable for the device being used
    var nAgt = navigator.userAgent.toLowerCase();;

    // First check to see if the platform is an iPhone or iPod
    if(navigator.platform == 'iPhone' || navigator.platform == 'iPod'){
        // In Safari, the true version is after "Safari"
        if ((nAgt.indexOf('safari'))!=-1) {
            // Set a variable to use later
            mobileSafari = 'safari';
        }
        if ((nAgt.indexOf('android'))!=-1) {
            // Set a variable to use later
            mobileAndroid = 'android';
        }

    }
}