| 1 |
(function($) { |
| 2 |
"use strict"; |
| 3 |
function handle_faq_($scope) { |
| 4 |
const $faqItems = $scope.find('.eel-faq-item'); |
| 5 |
const duration = 300; |
| 6 |
|
| 7 |
$faqItems.each(function () { |
| 8 |
const $item = $(this); |
| 9 |
const $question = $item.find('.eel-faq-question'); |
| 10 |
const $answer = $item.find('.eel-faq-answer'); |
| 11 |
|
| 12 |
$question.off('click.faqToggle'); |
| 13 |
|
| 14 |
// Initial state |
| 15 |
if ($item.hasClass('active')) { |
| 16 |
$answer.stop().slideDown(0); |
| 17 |
} else { |
| 18 |
$answer.stop().slideUp(0); |
| 19 |
} |
| 20 |
|
| 21 |
$question.on('click.faqToggle', function () { |
| 22 |
const isActive = $item.hasClass('active'); |
| 23 |
|
| 24 |
// Close all other items |
| 25 |
$faqItems.not($item).each(function () { |
| 26 |
var $other = $(this); |
| 27 |
if ($other.hasClass('active')) { |
| 28 |
$other.removeClass('active'); |
| 29 |
$other.find('.eel-faq-answer').stop(true).slideUp(duration); |
| 30 |
} |
| 31 |
}); |
| 32 |
|
| 33 |
// Toggle current |
| 34 |
if (isActive) { |
| 35 |
$item.removeClass('active'); |
| 36 |
$answer.stop(true).slideUp(duration); |
| 37 |
} else { |
| 38 |
$item.addClass('active'); |
| 39 |
$answer.stop(true).slideDown(duration); |
| 40 |
} |
| 41 |
}); |
| 42 |
}); |
| 43 |
} |
| 44 |
|
| 45 |
function checkStickySection() { |
| 46 |
const stickySection = document.querySelector('.eel-faq-sticky'); |
| 47 |
document.body.classList.toggle('sticky-enabled-overlap-faq', !!stickySection); |
| 48 |
} |
| 49 |
|
| 50 |
$(window).on('elementor/frontend/init', function () { |
| 51 |
elementorFrontend.hooks.addAction('frontend/element_ready/global', handle_faq_); |
| 52 |
elementorFrontend.hooks.addAction('frontend/element_ready/eel-faq-accordion.default', handle_faq_); |
| 53 |
|
| 54 |
checkStickySection(); |
| 55 |
|
| 56 |
const observer = new MutationObserver(checkStickySection); |
| 57 |
observer.observe(document.body, { childList: true, subtree: true }); |
| 58 |
}); |
| 59 |
|
| 60 |
})(jQuery); |
| 61 |
|