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/SBogers85/dale-int.com/wwwroot/js/main.js
/**
 * Created by Pascal on 30/09/15.
 * Edited by Dries on 05/01/17.
 */
$(function () {

    resizer();

    $(window).resize(
        $.throttle( 250, resizer )
    );

    /*$(window).scroll(
        $.throttle( 250, scroller )
    );*/

    jQuery.each(jQuery('textarea[data-autoresize]'), function() {  //autosize TextArea
        var offset = this.offsetHeight - this.clientHeight;

        var resizeTextarea = function(el) {
            jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
        };
        jQuery(this).on('keyup input', function() { resizeTextarea(this); }).removeAttr('data-autoresize');
    });

    //  Get internal link and animate them examp: <a href='#top'>Home</a>
    $('.internalLink').click(function(){
        animateScroll($(this));
        return false;
    });

    // Custom links in the website
    $('.internalScroll').on('click', function(){
        offset = typeof offset !== 'undefined' ? offset : 0;
        time = typeof time !== 'undefined' ? time : 800;

        var scrollTo = $(this).data('href');

        $('html,body').animate({
            scrollTop: $('#'+scrollTo).offset().top - offset - 98
        }, time);
    });

    //run animateServices when menuItem is clicked
    $('.dienst-menu-item').click(function(){

        if($(window).width() <= 1024){

            offset = typeof offset !== 'undefined' ? offset : 0;
            time = typeof time !== 'undefined' ? time : 800;


            var servicesBlockTop = ($('#services').offset().top);
            var windowTop = ($(window).scrollTop());

            var windowMin = windowTop - 5;
            var windowMax = windowTop + 5;

            // If the top of the servicesblock is between the windowtopmin and windowtopmax, do nothing!
            if(servicesBlockTop <= windowMin || servicesBlockTop >= windowMax ){

                $('html,body').animate({
                    scrollTop: $('#services').offset().top - offset
                }, time);
            }
        }

        animateServices($(this));
        return false;
    });

});

function animateServices(e) {
    // Search active service content
    var preActivatedService = $('.dienst-outer').find('.active');
    // Search active service link
    var preActivatedServiceLink = $('.dienst-menu').find('.active');

    // Passing trough the clicked service index number
    var clickedServiceId = e.index();

    // Seach service content that is equal with service index number of clicked link
    var activatedService = $('.dienst-outer').find('.dienst-block').eq(clickedServiceId);

    var activatedServiceLink = e;

    // Remove active classes from the previous active service and service link
    preActivatedServiceLink.removeClass('active');
    preActivatedService.removeClass('active');

    // Add active classes to clicked service and content
    activatedServiceLink.addClass('active');
    activatedService.addClass('active');
}

function resizer() {

    //RESET PARALLEX WHEN MOBILE
    if ( $(window).width() <= 900 ) {

        /*$('.about-floating-block').css({
            bottom: '0px'
        },0);*/

        $('.image-background').animate({
            'background-position-x': 0 + 'px'
        },0);

    }

}

function scroller() {

}

function isElementFullInViewport(el) {
    //special bonus for those using jQuery
    if(el.length > 0){
        if (typeof jQuery === "function" && el instanceof jQuery) {
            el = el[0];
        }

        var rect = el.getBoundingClientRect();

        return (
            rect.top >= 0 &&
            rect.bottom <= (window.innerHeight || $(window).height())
        );
    }
}

function isElementPartInViewport(el)
{
    if(el.length > 0) {
        //special bonus for those using jQuery
        if (typeof jQuery !== 'undefined' && el instanceof jQuery) el = el[0];

        var rect = el.getBoundingClientRect();
        // DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
        var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
        var windowWidth = (window.innerWidth || document.documentElement.clientWidth);

        var vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
        var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);

        return (vertInView && horInView);
    }
}

function isElementPartExtraInViewport(el, margin)
{
    if(el.length > 0) {
        //special bonus for those using jQuery
        if (typeof jQuery !== 'undefined' && el instanceof jQuery) el = el[0];

        var rect = el.getBoundingClientRect();
        // DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
        var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
        var windowWidth = (window.innerWidth || document.documentElement.clientWidth);

        var vertInView = (rect.top <= (windowHeight - margin)) && ((rect.top + rect.height) >= 0);
        var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);

        return (vertInView && horInView);
    }
}

function tabletOrMobile() {
    if(window.navigator.userAgent.match(/Mobile/i)
        || window.navigator.userAgent.match(/iPhone/i)
        || window.navigator.userAgent.match(/iPod/i)
        || window.navigator.userAgent.match(/IEMobile/i)
        || window.navigator.userAgent.match(/Windows Phone/i)
        || window.navigator.userAgent.match(/Android/i)
        || window.navigator.userAgent.match(/BlackBerry/i)
        || window.navigator.userAgent.match(/webOS/i)) {
        return true;
        //alert('True - Mobile - ' + navigator.userAgent);
    } else {
        //alert('False - Mobile - ' + navigator.userAgent);
        //return false;
    }
    if(window.navigator.userAgent.match(/Tablet/i)
        || window.navigator.userAgent.match(/iPad/i)
        || window.navigator.userAgent.match(/Nexus 7/i)
        || window.navigator.userAgent.match(/Nexus 10/i)
        || window.navigator.userAgent.match(/KFAPWI/i)) {
        return true;
        //alert('True - Tablet - ' + navigator.userAgent);
    }
    if($('body').width() <= 500){
        return true;
    }
    else {
        //alert('False - Tablet - ' + navigator.userAgent);
        //return false;
    }
}

function animateScroll(e, offset, time){
    offset = typeof offset !== 'undefined' ? offset : 0;
    time = typeof time !== 'undefined' ? time : 800;

    var scrollTo = e.attr('data-link');
    scrollTo = scrollTo.substr(scrollTo.indexOf('#')+1);

    $('.mobile-navigation').removeClass('active');

    $(window).width() > 900 ? offset += 98 : offset += 60;

    $('html,body').animate({
        scrollTop: $('#' + scrollTo).offset().top - offset
    }, time);

}