| 1 |
(function($) { |
| 2 |
"use strict"; |
| 3 |
function handle_faq_($scope) { |
| 4 |
const $faqItems = $scope.find('.eel-faq-item'); |
| 5 |
$faqItems.each(function () { |
| 6 |
const $item = $(this); |
| 7 |
const $question = $item.find('.eel-faq-question'); |
| 8 |
const $answer = $item.find('.eel-faq-answer'); |
| 9 |
$question.off('click.faqToggle'); |
| 10 |
if ($item.hasClass('active')) { |
| 11 |
$answer.css('max-height', $answer[0].scrollHeight + 'px'); |
| 12 |
} else { |
| 13 |
$answer.css('max-height', '0'); |
| 14 |
} |
| 15 |
$question.on('click.faqToggle', function () { |
| 16 |
const isActive = $item.hasClass('active'); |
| 17 |
$faqItems.removeClass('active') |
| 18 |
.find('.eel-faq-answer') |
| 19 |
.css('max-height', '0'); |
| 20 |
|
| 21 |
if (!isActive) { |
| 22 |
$item.addClass('active'); |
| 23 |
$answer.css('max-height', $answer[0].scrollHeight + 'px'); |
| 24 |
} |
| 25 |
}); |
| 26 |
}); |
| 27 |
} |
| 28 |
|
| 29 |
function checkStickySection() { |
| 30 |
const stickySection = document.querySelector('.eel-faq-sticky'); |
| 31 |
document.body.classList.toggle('sticky-enabled-overlap-faq', !!stickySection); |
| 32 |
} |
| 33 |
|
| 34 |
$(window).on('elementor/frontend/init', function () { |
| 35 |
elementorFrontend.hooks.addAction('frontend/element_ready/global', handle_faq_); |
| 36 |
elementorFrontend.hooks.addAction('frontend/element_ready/eel-faq-accordion.default', handle_faq_); |
| 37 |
|
| 38 |
checkStickySection(); |
| 39 |
|
| 40 |
const observer = new MutationObserver(checkStickySection); |
| 41 |
observer.observe(document.body, { childList: true, subtree: true }); |
| 42 |
}); |
| 43 |
|
| 44 |
})(jQuery); |
| 45 |
|