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/SBogers84/zuiderbos.nl/wwwroot/js/faq.js
/**
 * Created by Pascal on 07/08/17.
 */

var resize = false;

$(function () {

    // Resize page for calculation faq item height
    resizeMyPage();

    // Recalculate again for preventing too large items
    setTimeout(function(){
        resize = false;
        resizeMyPage();
    }, 1000);

    $(window).resize(
        $.throttle(100, resizeMyPage)
    );

    $('.faq-item .name').click(function () {
        $('.forced-active').removeClass('forced-active');
        if ($(this).parent().hasClass('active')) {
            $(this).parent().removeClass('active').addClass('hide');
        }
        else {
            $('.faq-item').addClass('hide').removeClass('active');
            $(this).parent().removeClass('hide').addClass('active').addClass('forced-active');
        }
        // $('body').animate({
        //     scrollTop: $(this).offset().top - 80
        // }, 800);

    })
});

function resizeMyPage() {

    //if( $(window).width() <= 825 && resize ) return;

    $('.faq-item').addClass('hide').removeClass('active');

    // Main content must be at least 200px higher then the impression block
    $('.content-placeholder .main').css('min-height', $('.faq .page-impression').height() + 200);

    // Resizing for the grey block on (default)pages
    var greyHeight = $('.content-placeholder .main').height() - $('.faq .page-impression').height() + 100;
    var greyWidth = ($('.content-placeholder').width() - $('.faq .content-placeholder>.grid-row').width()) / 2 + $('.faq .page-impression').width();
    $('.grey-block').height(greyHeight).width(greyWidth);

    $('.faq-items .faq-item .answer').css('height', 'auto');

    $('.faq-items .faq-item').each(function () {

        $(this).removeClass('hide').addClass('noTrans');

        var faqHeight = $(this).find('.answer').height() + 56;

        $(this).find('.answer').css('height', faqHeight);

        if ($(this).hasClass('active')) $(this).removeClass('noTrans');
        else $(this).addClass('hide').removeClass('noTrans');

        $(this).addClass('hide').removeClass('noTrans');
    });

    $('.forced-active').addClass('active');
    $('.faq-items .faq-item.active').removeClass('hide');

    resize = true;

}