PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.3.9
Easy Elements for Elementor – Addons & Website Templates v1.3.9
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / faq / js / faq.js

faq.js in Easy Elements for Elementor – Addons & Website Templates 1.3.9, at widgets/faq/js/faq.js

45 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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