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/SBogers57/topsluchtfilters.nl/wwwroot/public/js/tops_main_160205.js
/**
 * Define objects
 */
var $window = $(window);
var $scroller = $('#scroller');
var $wrapper = $('#wrapper');
var $main = $('#main');
var $header = $('header.main');
var $footer = $('footer');
var $footerBtn = $('.footer_btn');


/**
 * Define global variables
 */
// iPad, iPhone or any other touch device?
var isTouch = (navigator.userAgent.match(/iPad/i) != null) || (navigator.userAgent.match(/iPhone/i) != null);

// Height of footer that is always visible
var showFooter = 30;

// Difference between scroller height and scrollTop
var difFooter = 0;

// Is the footer opend by click
var footerClicked = false;

// Is the page scrolled to the bottom
var isAtBottom = false;



/**
 * define Functions
 */

/*
 * Aside call to action hover
 */
$('#aside_cta li').hover(function()
{
    var liW = $(this).children('a').width();
    $(this).css({ left: -(liW-40)+'px' })
},
function()
{
    $(this).css({ left: 0 })
});


/**
 * Form Spam check
 */
var $form = $('form.spam-check');
if($form.size()){
    $('<input type="hidden" />').attr({
        name: 'secretCode',
        id: 'secretCode',
        value: 'isHuman'
    }).appendTo($form);
}


/*
 * Open footer
 */
$footerBtn.click(function()
{
    if(isAtBottom)
    {
        toggleFooterScroll(null);
    }
    else
    {
        toggleFooterClick(null);
    }
});

$wrapper.click(function()
{
    if(isAtBottom)
    {
        toggleFooterScroll('close');
    }
    else
    {
        toggleFooterClick('close');
    }
});

// Open or close the footer when orange button is clicked
function toggleFooterClick(action)
{
    if( ! smallView())
    {
        var speed = 300;
        var h, t,sh, ctaB;

        if( ! footerClicked && ( action == 'open' || action == null  ))
        {
            // Set variable
            footerClicked = true;

            // Move wrapper
            h = ctaB = $footer.children('.inner').height();
            t = h - $header.height() - showFooter;
            sh = $scroller.height() - h;
        }
        else if( footerClicked && (action == 'close' || action == null) )
        {
            footerClicked = false;

            // Move wrapper
            h = ctaB = showFooter;
            t = -1*$header.height();
            sh = $scroller.height() + $footer.children('.inner').height();
        }

        $wrapper.animate({ top: -t+'px' },speed);
        $wrapper.animate({ top: -t+'px' },speed);
        $footer.animate({ height: h+'px' },speed);
        $scroller.animate({ height: sh+'px' },speed);

        // Footer button
        $footerBtn.animate({ bottom: (h - 11) + 'px' },speed);

        if($('#ambiance').size() > 0)
        {
            // Lift the ambiance photo and pattern
            $ambiance.animate({ top: -t+'px' },speed);
            $pattern.animate({ top: -t+'px' },speed);
        }

        if($('#home').size() > 0)
        {
            if( ! altView() && $window.height() > 1035 )
            {
                // Lift the ambiance photo and pattern
                $cta.animate({ bottom: ctaB + 'px'},speed);
            }
        }
    }
}

// Open or close the footer by scroll
function toggleFooterScroll(action)
{
    if( ! smallView())
    {
        var speed = 300;
        var st;
        // Fully opened?
        if($footer.height() == $footer.children('.inner').height())
        {
            // Close by scroll
            if(action == 'close' || action == null)
            {
                st = $window.scrollTop() - difFooter;
                $("html, body").animate({ scrollTop: st+'px'},speed);
            }
        }
        else
        {
            // Open by scroll
            if(action == 'open' || action == null)
            {
                st = $window.scrollTop() - difFooter + $footer.children('.inner').height();
                $("html, body").animate({ scrollTop: st+'px'},speed);
            }
        }
    }
}

function altView()
{
    return ($(window).width() > 750 && $(window).width() <= 1000)
}

function smallView()
{
    return $(window).width() <= 750
}