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 / split-testimonial / frontend.js

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

108 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 var _typoKeys = [
3 ['family','font-family'],['weight','font-weight'],['style','font-style'],
4 ['decoration','text-decoration'],['transform','text-transform']
5 ];
6 var _sizeKeys = [['sizeDesktop','font-size-d'],['sizeTablet','font-size-t'],['sizeMobile','font-size-m']];
7 var _lhKeys = [['lineHeightDesktop','line-height-d'],['lineHeightTablet','line-height-t'],['lineHeightMobile','line-height-m']];
8 var _lsKeys = [['letterSpacingDesktop','letter-spacing-d'],['letterSpacingTablet','letter-spacing-t'],['letterSpacingMobile','letter-spacing-m']];
9 var _wsKeys = [['wordSpacingDesktop','word-spacing-d'],['wordSpacingTablet','word-spacing-t'],['wordSpacingMobile','word-spacing-m']];
10 function typoCssVarsForEl(el, obj, prefix) {
11 if (!obj || typeof obj !== 'object') return;
12 var all = _typoKeys.concat(_sizeKeys,_lhKeys,_lsKeys,_wsKeys);
13 for (var i = 0; i < all.length; i++) {
14 var v = obj[all[i][0]];
15 if (v !== undefined && v !== '' && v !== null) el.style.setProperty(prefix + '-' + all[i][1], String(v));
16 }
17 }
18
19 document.querySelectorAll('.bkbg-split-testimonial-app').forEach(function (root) {
20 var opts = {};
21 try { opts = JSON.parse(root.dataset.opts || '{}'); } catch (e) {}
22
23 var wrap = document.createElement('div');
24 wrap.className = 'bkbg-split-testimonial-wrap';
25 wrap.style.cssText = 'background:' + (opts.bgColor || '#1e1b4b') + ';padding:' + (opts.paddingTop || 80) + 'px 40px ' + (opts.paddingBottom || 80) + 'px;';
26 wrap.style.setProperty('--bkbg-st-max', (opts.maxWidth || 1100) + 'px');
27 wrap.style.setProperty('--bkst-qt-sz', (opts.quoteSize || 28) + 'px');
28 wrap.style.setProperty('--bkst-qt-w', String(opts.quoteFontWeight || 400));
29 wrap.style.setProperty('--bkst-nm-sz', ((opts.authorSize || 16) + 2) + 'px');
30 wrap.style.setProperty('--bkst-mt-sz', (opts.authorSize || 16) + 'px');
31 typoCssVarsForEl(wrap, opts.quoteTypo, '--bkst-qt');
32 typoCssVarsForEl(wrap, opts.nameTypo, '--bkst-nm');
33 typoCssVarsForEl(wrap, opts.metaTypo, '--bkst-mt');
34
35 if (opts.showQuoteMark !== false) {
36 var qm = document.createElement('div');
37 qm.className = 'bkbg-st-quote-mark';
38 qm.style.color = opts.quoteMarkColor || 'rgba(124,58,237,.45)';
39 qm.textContent = '\u201C';
40 wrap.appendChild(qm);
41 }
42
43 var avatarRadius = opts.avatarShape === 'circle' ? '50%' : opts.avatarShape === 'rounded' ? '20%' : '0';
44 var avatarSz = (opts.avatarSize || 120) + 'px';
45 var isLeftPhoto = (opts.layout || 'left-photo') === 'left-photo';
46
47 var inner = document.createElement('div');
48 inner.className = 'bkbg-st-inner';
49 inner.style.gridTemplateColumns = isLeftPhoto ? '1fr 2fr' : '2fr 1fr';
50
51 // Photo column
52 var photoCol = document.createElement('div');
53 photoCol.className = 'bkbg-st-photo-col';
54 photoCol.style.order = isLeftPhoto ? '0' : '1';
55
56 var avatarDiv = document.createElement('div');
57 avatarDiv.className = 'bkbg-st-avatar';
58 avatarDiv.style.cssText = 'width:' + avatarSz + ';height:' + avatarSz + ';border-radius:' + avatarRadius + ';background:' + (opts.accentBg || '#7c3aed') + ';box-shadow:0 0 0 6px ' + (opts.accentBg || '#7c3aed') + '44;';
59
60 if (opts.authorImageUrl) {
61 var img = document.createElement('img');
62 img.src = opts.authorImageUrl;
63 img.alt = opts.authorAlt || '';
64 avatarDiv.appendChild(img);
65 }
66 photoCol.appendChild(avatarDiv);
67
68 var authorWrap = document.createElement('div');
69 authorWrap.style.textAlign = 'center';
70 var authorName = document.createElement('div');
71 authorName.className = 'bkbg-st-author-name';
72 authorName.textContent = opts.authorName || '';
73 var authorMeta = document.createElement('div');
74 authorMeta.className = 'bkbg-st-author-meta';
75 authorMeta.style.color = opts.authorColor || '#c4b5fd';
76 authorMeta.textContent = opts.authorTitle + (opts.showCompany && opts.authorCompany ? ', ' + opts.authorCompany : '');
77 authorWrap.appendChild(authorName);
78 authorWrap.appendChild(authorMeta);
79 photoCol.appendChild(authorWrap);
80
81 // Quote column
82 var quoteCol = document.createElement('div');
83 quoteCol.className = 'bkbg-st-quote-col';
84 quoteCol.style.order = isLeftPhoto ? '1' : '0';
85
86 if (opts.showStars !== false) {
87 var stars = document.createElement('div');
88 stars.className = 'bkbg-st-stars';
89 stars.style.cssText = 'font-size:24px;color:' + (opts.starColor || '#fbbf24') + ';';
90 var n = opts.stars || 5;
91 stars.textContent = '�
92 '.repeat(n) + ''.repeat(5 - n);
93 quoteCol.appendChild(stars);
94 }
95
96 var blockquote = document.createElement('blockquote');
97 blockquote.className = 'bkbg-st-quote';
98 blockquote.style.color = opts.quoteColor || '#fff';
99 blockquote.innerHTML = opts.quote || '';
100 quoteCol.appendChild(blockquote);
101
102 inner.appendChild(photoCol);
103 inner.appendChild(quoteCol);
104 wrap.appendChild(inner);
105 root.parentNode.replaceChild(wrap, root);
106 });
107 })();
108