/// $(document).ready(function () { var cardsToDisplay = 3; var totalItems = $('.faq__section').length; var perLoadItem = 3; var loading = false; var faqId = getUrlParameter('a'); var faqElement = $('#' + faqId); // loadCards({ // cardsToDisplay: cardsToDisplay, // cardClass: 'faq__section', // loadMoreButtonClass: 'faq__more' // }); // expand containers on click $('.faq__section__top').click(function () { var $target = $(this).closest('.faq__section'); // find target and expand, else close if (!$(this).hasClass('faq__section__active')) { resetFaqSection(); $target.find('.faq__section__hidden').stop().slideDown(); $target.find('.faq__section__top, .faq__section__title').addClass('faq__section__active'); $target.find('.icon').addClass('icon-minus-icon').removeClass('icon-plus-icon'); // scroll to faq var headerHeight_1 = $('#header').outerHeight(true); setTimeout(function () { $('html,body').animate({ scrollTop: ($target.offset().top - headerHeight_1) + 'px' }, 800); }, 500); } else { resetFaqSection(); } // else{ // console.log('hide') // $target.find('.faq__section__hidden').slideDown(); // $target.find('.icon').addClass('icon-plus-icon').removeClass('icon-minus-icon') // } return false; }); init(); function resetFaqSection() { //reset all containers $('.faq__section__hidden').stop().slideUp(300); $('.faq__section__top, .faq__section__title').removeClass('faq__section__active'); $('.faq').find('.icon').removeClass('icon-minus-icon').addClass('icon-plus-icon'); } function loadItem() { if (!loading) { loading = true; var from = $('.faq__section:visible').length; var to = from + (perLoadItem - 1); // console.log(from) // console.log(to) $('.faq__section:eq(' + from + ')').fadeIn(50); $('.faq__section:gt(' + from + '):lt(' + to + ')').fadeIn(50); loading = false; } if ($('.faq__section:hidden').length > 0) { $('.faq__more').removeClass('hidden'); } else { $('.faq__more').addClass('hidden'); } } function init() { // first load loadItem(); $('.faq__more').click(function () { loadItem(); }); if (typeof faqId == 'undefined') { // open first container setTimeout(function () { var $firstTarget = $('.faq__section:first'); $firstTarget.find('.faq__section__top').click(); }, 10); } else { if (faqElement.length > 0) { searchAndOpenFaq(); } } function searchAndOpenFaq() { if (faqElement.is(':visible')) { faqElement.find('.faq__section__top').click(); } else { var loadMoreInterval_1 = setInterval(function () { $('.loadMoreButton').click(); if (faqElement.is(':visible')) { faqElement.find('.faq__section__top').click(); clearInterval(loadMoreInterval_1); } }, 100); } } } }); var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } };