| 1 |
(function () { |
| 2 |
var _typoKeys = { |
| 3 |
family: 'font-family', weight: 'font-weight', style: 'font-style', |
| 4 |
decoration: 'text-decoration', transform: 'text-transform', |
| 5 |
sizeDesktop: 'font-size-d', sizeTablet: 'font-size-t', sizeMobile: 'font-size-m', |
| 6 |
lineHeightDesktop: 'line-height-d', lineHeightTablet: 'line-height-t', lineHeightMobile: 'line-height-m', |
| 7 |
letterSpacing: 'letter-spacing', wordSpacing: 'word-spacing' |
| 8 |
}; |
| 9 |
function typoCssVarsForEl(el, typo, prefix) { |
| 10 |
if (!typo || typeof typo !== 'object') return; |
| 11 |
Object.keys(typo).forEach(function (k) { |
| 12 |
var v = typo[k]; if (v === '' || v == null) return; |
| 13 |
var css = _typoKeys[k]; if (!css) return; |
| 14 |
if ((k === 'letterSpacing' || k === 'wordSpacing') && typeof v === 'number') v = v + 'px'; |
| 15 |
if ((/^(sizeDesktop|sizeTablet|sizeMobile)$/).test(k) && typeof v === 'number') v = v + 'px'; |
| 16 |
el.style.setProperty(prefix + css, '' + v); |
| 17 |
}); |
| 18 |
} |
| 19 |
|
| 20 |
var BULLETS = { check: '✓', arrow: '→', circle: '●', star: '� |
| 21 |
' }; |
| 22 |
var LEVELS = { beginner: '🟢 Beginner', intermediate: '🟡 Intermediate', advanced: '🔴 Advanced', all: '🔵 All Levels' }; |
| 23 |
|
| 24 |
function init() { |
| 25 |
document.querySelectorAll('.bkbg-lob-app').forEach(function (el) { |
| 26 |
if (el.dataset.rendered) return; |
| 27 |
el.dataset.rendered = '1'; |
| 28 |
var opts; |
| 29 |
try { opts = JSON.parse(el.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 30 |
var o = Object.assign({ |
| 31 |
heading: 'What You\'ll Learn', headingIcon: '🎯', showIcon: true, |
| 32 |
objectives: [], |
| 33 |
showLevel: true, level: 'beginner', |
| 34 |
showReadTime: true, readTime: '', |
| 35 |
bulletStyle: 'check', customBullet: '✓', |
| 36 |
style: 'card', columns: 1, |
| 37 |
bgColor: '#f0fdf4', borderColor: '#86efac', accentColor: '#16a34a', |
| 38 |
headingColor: '#14532d', bulletBg: '#dcfce7', bulletColor: '#16a34a', |
| 39 |
textColor: '#166534', metaColor: '#4b7a5a', |
| 40 |
levelBg: '#16a34a', levelColor: '#ffffff', |
| 41 |
borderRadius: 10, paddingTop: 0, paddingBottom: 0 |
| 42 |
}, opts); |
| 43 |
|
| 44 |
var bullet = o.bulletStyle === 'custom' ? (o.customBullet || '✓') : (BULLETS[o.bulletStyle] || '✓'); |
| 45 |
|
| 46 |
var outer = document.createElement('div'); |
| 47 |
outer.style.cssText = 'padding:' + o.paddingTop + 'px 0 ' + o.paddingBottom + 'px;'; |
| 48 |
|
| 49 |
var wrap = document.createElement('div'); |
| 50 |
wrap.className = 'bkbg-lob-wrap'; |
| 51 |
|
| 52 |
typoCssVarsForEl(wrap, o.headingTypo, '--bkbg-lob-h-'); |
| 53 |
typoCssVarsForEl(wrap, o.objectiveTypo, '--bkbg-lob-o-'); |
| 54 |
var wrapCss = 'padding:20px 24px;box-sizing:border-box;font-family:inherit;'; |
| 55 |
if (o.style === 'card') { |
| 56 |
wrapCss += 'background:' + o.bgColor + ';border:1px solid ' + o.borderColor + ';border-radius:' + o.borderRadius + 'px;'; |
| 57 |
} else if (o.style === 'left-border') { |
| 58 |
wrapCss += 'background:' + o.bgColor + ';border:1px solid ' + o.borderColor + ';border-left:4px solid ' + o.accentColor + ';border-radius:' + o.borderRadius + 'px;'; |
| 59 |
} else if (o.style === 'top-border') { |
| 60 |
wrapCss += 'background:' + o.bgColor + ';border:1px solid ' + o.borderColor + ';border-top:4px solid ' + o.accentColor + ';border-radius:0 0 ' + o.borderRadius + 'px ' + o.borderRadius + 'px;'; |
| 61 |
} else { |
| 62 |
wrapCss += 'background:transparent;padding:0;'; |
| 63 |
} |
| 64 |
wrap.style.cssText = wrapCss; |
| 65 |
|
| 66 |
/* Header */ |
| 67 |
var hdr = document.createElement('div'); |
| 68 |
hdr.className = 'bkbg-lob-header'; |
| 69 |
hdr.style.cssText = 'display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;flex-wrap:wrap;gap:8px;'; |
| 70 |
|
| 71 |
var titleRow = document.createElement('div'); |
| 72 |
titleRow.style.cssText = 'display:flex;align-items:center;gap:10px;'; |
| 73 |
if (o.showIcon && o.headingIcon) { |
| 74 |
var icon = document.createElement('span'); |
| 75 |
icon.className = 'bkbg-lob-icon'; |
| 76 |
icon.style.cssText = 'font-size:24px;line-height:1;flex-shrink:0;'; |
| 77 |
var _IP = window.bkbgIconPicker; |
| 78 |
if (_IP && o.headingIconType && o.headingIconType !== 'custom-char') { |
| 79 |
var _iconNode = _IP.buildFrontendIcon(o.headingIconType, o.headingIcon, o.headingIconDashicon, o.headingIconImageUrl, o.headingIconDashiconColor); |
| 80 |
if (_iconNode) icon.appendChild(_iconNode); |
| 81 |
else icon.textContent = o.headingIcon; |
| 82 |
} else { |
| 83 |
icon.textContent = o.headingIcon; |
| 84 |
} |
| 85 |
titleRow.appendChild(icon); |
| 86 |
} |
| 87 |
var h3 = document.createElement('h3'); |
| 88 |
h3.className = 'bkbg-lob-heading'; |
| 89 |
h3.style.color = o.headingColor; |
| 90 |
h3.innerHTML = o.heading; |
| 91 |
titleRow.appendChild(h3); |
| 92 |
hdr.appendChild(titleRow); |
| 93 |
|
| 94 |
var meta = document.createElement('div'); |
| 95 |
meta.style.cssText = 'display:flex;align-items:center;gap:8px;flex-wrap:wrap;'; |
| 96 |
if (o.showLevel && o.level) { |
| 97 |
var lvl = document.createElement('span'); |
| 98 |
lvl.style.cssText = 'background:' + o.levelBg + ';color:' + o.levelColor + ';font-size:11px;padding:3px 9px;border-radius:20px;font-weight:600;'; |
| 99 |
lvl.textContent = LEVELS[o.level] || o.level; |
| 100 |
meta.appendChild(lvl); |
| 101 |
} |
| 102 |
if (o.showReadTime && o.readTime) { |
| 103 |
var rt = document.createElement('span'); |
| 104 |
rt.style.cssText = 'font-size:12px;color:' + o.metaColor + ';'; |
| 105 |
rt.textContent = '⏱ ' + o.readTime; |
| 106 |
meta.appendChild(rt); |
| 107 |
} |
| 108 |
hdr.appendChild(meta); |
| 109 |
wrap.appendChild(hdr); |
| 110 |
|
| 111 |
/* Objectives */ |
| 112 |
var grid = document.createElement('div'); |
| 113 |
grid.className = 'bkbg-lob-grid'; |
| 114 |
grid.style.cssText = 'display:grid;grid-template-columns:repeat(' + (o.columns || 1) + ',1fr);gap:10px;'; |
| 115 |
(o.objectives || []).forEach(function (obj) { |
| 116 |
var item = document.createElement('div'); |
| 117 |
item.className = 'bkbg-lob-item'; |
| 118 |
item.style.cssText = 'display:flex;align-items:flex-start;gap:10px;'; |
| 119 |
|
| 120 |
var bul = document.createElement('span'); |
| 121 |
bul.className = 'bkbg-lob-bullet'; |
| 122 |
bul.style.cssText = 'background:' + o.bulletBg + ';color:' + o.bulletColor + ';width:24px;height:24px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex-shrink:0;margin-top:1px;'; |
| 123 |
bul.textContent = bullet; |
| 124 |
|
| 125 |
var txt = document.createElement('p'); |
| 126 |
txt.className = 'bkbg-lob-text'; |
| 127 |
txt.style.color = o.textColor; |
| 128 |
txt.innerHTML = obj.text || ''; |
| 129 |
|
| 130 |
item.appendChild(bul); |
| 131 |
item.appendChild(txt); |
| 132 |
grid.appendChild(item); |
| 133 |
}); |
| 134 |
wrap.appendChild(grid); |
| 135 |
|
| 136 |
outer.appendChild(wrap); |
| 137 |
el.parentNode.insertBefore(outer, el); |
| 138 |
}); |
| 139 |
} |
| 140 |
|
| 141 |
if (document.readyState !== 'loading') { init(); } |
| 142 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 143 |
})(); |
| 144 |
|