PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.5.0
Easy Elements for Elementor – Addons & Website Templates v1.5.0
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.5.0, at widgets/faq/js/faq.js

61 lines 2.1 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 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