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 / cta-pulsing-button / frontend.js

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

65 lines 2.8 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 function init() {
5 var blocks = document.querySelectorAll('.bkbg-pb-outer');
6
7 blocks.forEach(function (block) {
8 var btn = block.querySelector('.bkbg-pb-btn');
9 if (!btn) return;
10
11 // ── Hover color swap ───────────────────────────────────────────────
12 var hoverBg = btn.dataset.pbBgHover;
13 var hoverText = btn.dataset.pbTextHover;
14
15 if (hoverBg || hoverText) {
16 var cachedBg = btn.style.background || btn.style.backgroundColor;
17 var cachedColor = btn.style.color;
18 var cachedFilter = btn.style.filter;
19
20 btn.addEventListener('mouseenter', function () {
21 if (hoverBg) { btn.style.background = hoverBg; }
22 if (hoverText) { btn.style.color = hoverText; }
23 btn.style.filter = ''; // disable CSS brightness override during colour swap
24 });
25
26 btn.addEventListener('mouseleave', function () {
27 btn.style.background = cachedBg;
28 btn.style.color = cachedColor;
29 btn.style.filter = cachedFilter;
30 });
31 }
32
33 // ── Reduced-motion: pause pulse animations ─────────────────────────
34 var pulseWrap = block.querySelector('.bkbg-pb-pulse-wrap');
35 if (pulseWrap) {
36 var mq = window.matchMedia('(prefers-reduced-motion: reduce)');
37
38 function applyMotionPref() {
39 var paused = mq.matches ? 'paused' : 'running';
40 pulseWrap.style.setProperty('animation-play-state', paused);
41 var before = window.getComputedStyle(pulseWrap, '::before');
42 // set it on the wrapper's pseudo-element via a class toggle
43 if (mq.matches) {
44 pulseWrap.classList.add('bkbg-pb-reduced-motion');
45 } else {
46 pulseWrap.classList.remove('bkbg-pb-reduced-motion');
47 }
48 }
49
50 applyMotionPref();
51 try { mq.addEventListener('change', applyMotionPref); }
52 catch (e) { mq.addListener(applyMotionPref); } // Safari 13 compat
53 }
54 });
55 }
56
57 // ── Boot ───────────────────────────────────────────────────────────────────
58 if (document.readyState === 'loading') {
59 document.addEventListener('DOMContentLoaded', init);
60 } else {
61 init();
62 }
63
64 }());
65