PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / content-switcher / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/content-switcher/frontend.js

41 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 'use strict';
3
4 document.querySelectorAll('.bkbg-csw-wrapper').forEach(function (wrap) {
5 var btns = wrap.querySelectorAll('.bkbg-csw-switch-btn');
6 var panels = wrap.querySelectorAll('.bkbg-csw-panel');
7 var animEls= wrap.querySelectorAll('.bkbg-csw-anim');
8
9 function showPanel(targetId) {
10 panels.forEach(function (panel) {
11 var isTarget = panel.getAttribute('data-panel') === targetId;
12 panel.style.display = isTarget ? '' : 'none';
13 panel.setAttribute('aria-hidden', isTarget ? 'false' : 'true');
14 });
15 btns.forEach(function (btn) {
16 var isActive = btn.getAttribute('data-target') === targetId;
17 btn.classList.toggle('is-active', isActive);
18 });
19 }
20
21 btns.forEach(function (btn) {
22 btn.addEventListener('click', function () {
23 showPanel(btn.getAttribute('data-target'));
24 });
25 });
26
27 /* Scroll-in animation */
28 if (animEls.length) {
29 var observer = new IntersectionObserver(function (entries) {
30 entries.forEach(function (entry) {
31 if (entry.isIntersecting) {
32 entry.target.classList.add('bkbg-csw-visible');
33 observer.unobserve(entry.target);
34 }
35 });
36 }, { threshold: 0.1 });
37 animEls.forEach(function (el) { observer.observe(el); });
38 }
39 });
40 })();
41