# blockenberg/2.0.7/blocks/content-switcher/frontend.js

Blockenberg — 600+ Advanced Gutenberg Blocks &amp; AI Agent for WordPress Block Editor, version 2.0.7. 41 lines.

- Page: https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/content-switcher/frontend.js
- Raw: https://pluginprobe.com/plugins/blockenberg/2.0.7/raw/blocks/content-switcher/frontend.js
- Modified: 2026-03-06T12:32:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/content-switcher/frontend.js#L10-L20`.

```javascript
(function () {
    'use strict';

    document.querySelectorAll('.bkbg-csw-wrapper').forEach(function (wrap) {
        var btns   = wrap.querySelectorAll('.bkbg-csw-switch-btn');
        var panels = wrap.querySelectorAll('.bkbg-csw-panel');
        var animEls= wrap.querySelectorAll('.bkbg-csw-anim');

        function showPanel(targetId) {
            panels.forEach(function (panel) {
                var isTarget = panel.getAttribute('data-panel') === targetId;
                panel.style.display = isTarget ? '' : 'none';
                panel.setAttribute('aria-hidden', isTarget ? 'false' : 'true');
            });
            btns.forEach(function (btn) {
                var isActive = btn.getAttribute('data-target') === targetId;
                btn.classList.toggle('is-active', isActive);
            });
        }

        btns.forEach(function (btn) {
            btn.addEventListener('click', function () {
                showPanel(btn.getAttribute('data-target'));
            });
        });

        /* Scroll-in animation */
        if (animEls.length) {
            var observer = new IntersectionObserver(function (entries) {
                entries.forEach(function (entry) {
                    if (entry.isIntersecting) {
                        entry.target.classList.add('bkbg-csw-visible');
                        observer.unobserve(entry.target);
                    }
                });
            }, { threshold: 0.1 });
            animEls.forEach(function (el) { observer.observe(el); });
        }
    });
})();

```
