| 1 |
wp.domReady(function () { |
| 2 |
var SOCIAL_ICONS = { twitter: '𝕏', linkedin: 'in', instagram: '◉', website: '🌐', youtube: '▶', tiktok: '♪', facebook: 'f' }; |
| 3 |
|
| 4 |
function typoCssVarsForEl(typo, prefix, el) { |
| 5 |
if (!typo) return; |
| 6 |
if (typo.family) el.style.setProperty(prefix + 'font-family', "'" + typo.family + "', sans-serif"); |
| 7 |
if (typo.weight) el.style.setProperty(prefix + 'font-weight', typo.weight); |
| 8 |
if (typo.transform) el.style.setProperty(prefix + 'text-transform', typo.transform); |
| 9 |
if (typo.style) el.style.setProperty(prefix + 'font-style', typo.style); |
| 10 |
if (typo.decoration) el.style.setProperty(prefix + 'text-decoration', typo.decoration); |
| 11 |
var su = typo.sizeUnit || 'px'; |
| 12 |
if (typo.sizeDesktop !== '' && typo.sizeDesktop != null) el.style.setProperty(prefix + 'font-size-d', typo.sizeDesktop + su); |
| 13 |
if (typo.sizeTablet !== '' && typo.sizeTablet != null) el.style.setProperty(prefix + 'font-size-t', typo.sizeTablet + su); |
| 14 |
if (typo.sizeMobile !== '' && typo.sizeMobile != null) el.style.setProperty(prefix + 'font-size-m', typo.sizeMobile + su); |
| 15 |
var lhu = typo.lineHeightUnit || ''; |
| 16 |
if (typo.lineHeightDesktop !== '' && typo.lineHeightDesktop != null) el.style.setProperty(prefix + 'line-height-d', typo.lineHeightDesktop + lhu); |
| 17 |
if (typo.lineHeightTablet !== '' && typo.lineHeightTablet != null) el.style.setProperty(prefix + 'line-height-t', typo.lineHeightTablet + lhu); |
| 18 |
if (typo.lineHeightMobile !== '' && typo.lineHeightMobile != null) el.style.setProperty(prefix + 'line-height-m', typo.lineHeightMobile + lhu); |
| 19 |
var lsu = typo.letterSpacingUnit || 'px'; |
| 20 |
if (typo.letterSpacingDesktop !== '' && typo.letterSpacingDesktop != null) el.style.setProperty(prefix + 'letter-spacing-d', typo.letterSpacingDesktop + lsu); |
| 21 |
if (typo.letterSpacingTablet !== '' && typo.letterSpacingTablet != null) el.style.setProperty(prefix + 'letter-spacing-t', typo.letterSpacingTablet + lsu); |
| 22 |
if (typo.letterSpacingMobile !== '' && typo.letterSpacingMobile != null) el.style.setProperty(prefix + 'letter-spacing-m', typo.letterSpacingMobile + lsu); |
| 23 |
var wsu = typo.wordSpacingUnit || 'px'; |
| 24 |
if (typo.wordSpacingDesktop !== '' && typo.wordSpacingDesktop != null) el.style.setProperty(prefix + 'word-spacing-d', typo.wordSpacingDesktop + wsu); |
| 25 |
if (typo.wordSpacingTablet !== '' && typo.wordSpacingTablet != null) el.style.setProperty(prefix + 'word-spacing-t', typo.wordSpacingTablet + wsu); |
| 26 |
if (typo.wordSpacingMobile !== '' && typo.wordSpacingMobile != null) el.style.setProperty(prefix + 'word-spacing-m', typo.wordSpacingMobile + wsu); |
| 27 |
} |
| 28 |
|
| 29 |
document.querySelectorAll('.bkbg-bios-app').forEach(function (el) { |
| 30 |
var a = JSON.parse(el.dataset.opts || '{}'); |
| 31 |
var isCentered = a.layout === 'centered'; |
| 32 |
var isRight = a.layout === 'image-right'; |
| 33 |
|
| 34 |
var wrap = document.createElement('div'); |
| 35 |
wrap.className = 'bkbg-bios-wrap'; |
| 36 |
wrap.style.background = a.bgColor || '#ffffff'; |
| 37 |
wrap.style.paddingTop = (a.paddingTop || 80) + 'px'; |
| 38 |
wrap.style.paddingBottom = (a.paddingBottom || 80) + 'px'; |
| 39 |
|
| 40 |
var inner = document.createElement('div'); |
| 41 |
inner.className = 'bkbg-bios-inner' + (isCentered ? ' bkbg-bios-inner--centered' : isRight ? ' bkbg-bios-inner--right' : ''); |
| 42 |
inner.style.maxWidth = (a.maxWidth || 1060) + 'px'; |
| 43 |
inner.style.margin = '0 auto'; |
| 44 |
inner.style.padding = '0 24px'; |
| 45 |
|
| 46 |
/* === Photo === */ |
| 47 |
var photoWrap = document.createElement('div'); |
| 48 |
photoWrap.className = 'bkbg-bios-photo-wrap'; |
| 49 |
photoWrap.style.width = (isCentered ? 280 : (a.imageWidth || 380)) + 'px'; |
| 50 |
if (isCentered) { photoWrap.style.margin = '0 auto 32px'; } |
| 51 |
|
| 52 |
if (a.showDecorator) { |
| 53 |
var deco = document.createElement('div'); |
| 54 |
deco.className = 'bkbg-bios-decorator'; |
| 55 |
deco.style.background = a.decoratorColor || '#f3f0ff'; |
| 56 |
deco.style.borderRadius = ((a.imageRadius || 16) + 16) + 'px'; |
| 57 |
photoWrap.appendChild(deco); |
| 58 |
} |
| 59 |
|
| 60 |
var shapeRadius = ''; |
| 61 |
if (a.imageShape === 'circle') shapeRadius = '50%'; |
| 62 |
else if (a.imageShape === 'rounded') shapeRadius = (a.imageRadius || 16) + 'px'; |
| 63 |
|
| 64 |
if (a.imageUrl) { |
| 65 |
var photo = document.createElement('img'); |
| 66 |
photo.src = a.imageUrl; |
| 67 |
photo.alt = a.imageAlt || ''; |
| 68 |
photo.className = 'bkbg-bios-photo bkbg-bios-photo--' + (a.imageShape || 'rounded'); |
| 69 |
if (shapeRadius) { photo.style.borderRadius = shapeRadius; } |
| 70 |
photoWrap.appendChild(photo); |
| 71 |
} else { |
| 72 |
var placeholder = document.createElement('div'); |
| 73 |
placeholder.className = 'bkbg-bios-photo-placeholder bkbg-bios-photo--' + (a.imageShape || 'rounded'); |
| 74 |
if (shapeRadius) { placeholder.style.borderRadius = shapeRadius; } |
| 75 |
placeholder.textContent = '🧑'; |
| 76 |
photoWrap.appendChild(placeholder); |
| 77 |
} |
| 78 |
|
| 79 |
/* === Text === */ |
| 80 |
var textEl = document.createElement('div'); |
| 81 |
textEl.className = 'bkbg-bios-text'; |
| 82 |
textEl.style.flex = '1'; |
| 83 |
|
| 84 |
var nameEl = document.createElement('h2'); |
| 85 |
nameEl.className = 'bkbg-bios-name'; |
| 86 |
nameEl.style.cssText = 'color:' + (a.nameColor || '#111827') + ';margin:0 0 6px;'; |
| 87 |
nameEl.innerHTML = a.name || ''; |
| 88 |
textEl.appendChild(nameEl); |
| 89 |
|
| 90 |
var titleEl = document.createElement('p'); |
| 91 |
titleEl.className = 'bkbg-bios-title'; |
| 92 |
titleEl.style.cssText = 'color:' + (a.titleColor || '#7c3aed') + ';margin:0 0 8px;'; |
| 93 |
titleEl.innerHTML = a.title || ''; |
| 94 |
textEl.appendChild(titleEl); |
| 95 |
|
| 96 |
if (a.showSubtitle && a.subtitle) { |
| 97 |
var subEl = document.createElement('p'); |
| 98 |
subEl.className = 'bkbg-bios-subtitle'; |
| 99 |
subEl.style.cssText = 'color:' + (a.subtitleColor || '#6b7280') + ';margin:0 0 20px;'; |
| 100 |
subEl.innerHTML = a.subtitle; |
| 101 |
textEl.appendChild(subEl); |
| 102 |
} |
| 103 |
|
| 104 |
if (a.showCredentials && a.credentials && a.credentials.length) { |
| 105 |
var credWrap = document.createElement('div'); |
| 106 |
credWrap.className = 'bkbg-bios-credentials' + (isCentered ? ' bkbg-bios-credentials--centered' : ''); |
| 107 |
a.credentials.forEach(function (c) { |
| 108 |
if (!c.text) return; |
| 109 |
var chip = document.createElement('span'); |
| 110 |
chip.className = 'bkbg-bios-credential'; |
| 111 |
chip.style.background = a.credentialBg || '#f3f0ff'; |
| 112 |
chip.style.color = a.credentialColor || '#5b21b6'; |
| 113 |
chip.innerHTML = c.text; |
| 114 |
credWrap.appendChild(chip); |
| 115 |
}); |
| 116 |
textEl.appendChild(credWrap); |
| 117 |
} |
| 118 |
|
| 119 |
if (a.bio) { |
| 120 |
var bioEl = document.createElement('div'); |
| 121 |
bioEl.className = 'bkbg-bios-bio'; |
| 122 |
bioEl.style.cssText = 'color:' + (a.bioColor || '#374151') + ';margin-bottom:20px;'; |
| 123 |
bioEl.innerHTML = a.bio; |
| 124 |
textEl.appendChild(bioEl); |
| 125 |
} |
| 126 |
|
| 127 |
if (a.showQuote && a.highlightQuote) { |
| 128 |
var quoteEl = document.createElement('blockquote'); |
| 129 |
quoteEl.className = 'bkbg-bios-quote'; |
| 130 |
quoteEl.style.borderLeftColor = a.quoteBorderColor || '#7c3aed'; |
| 131 |
var quoteP = document.createElement('p'); |
| 132 |
quoteP.style.cssText = 'color:' + (a.quoteColor || '#111827') + ';margin:0;'; |
| 133 |
quoteP.innerHTML = a.highlightQuote; |
| 134 |
quoteEl.appendChild(quoteP); |
| 135 |
textEl.appendChild(quoteEl); |
| 136 |
} |
| 137 |
|
| 138 |
/* Actions row */ |
| 139 |
var actionsEl = document.createElement('div'); |
| 140 |
actionsEl.className = 'bkbg-bios-actions'; |
| 141 |
|
| 142 |
if (a.ctaEnabled && a.ctaLabel) { |
| 143 |
var ctaEl = document.createElement('a'); |
| 144 |
ctaEl.className = 'bkbg-bios-cta'; |
| 145 |
ctaEl.href = a.ctaUrl || '#'; |
| 146 |
ctaEl.style.background = a.ctaBg || '#7c3aed'; |
| 147 |
ctaEl.style.color = a.ctaColor || '#ffffff'; |
| 148 |
if (a.ctaIsExternal) { ctaEl.target = '_blank'; ctaEl.rel = 'noopener noreferrer'; } |
| 149 |
ctaEl.innerHTML = a.ctaLabel; |
| 150 |
actionsEl.appendChild(ctaEl); |
| 151 |
} |
| 152 |
|
| 153 |
if (a.showSocials && a.socials && a.socials.length) { |
| 154 |
var socialsEl = document.createElement('div'); |
| 155 |
socialsEl.className = 'bkbg-bios-socials'; |
| 156 |
a.socials.forEach(function (s) { |
| 157 |
if (!s.url) return; |
| 158 |
var link = document.createElement('a'); |
| 159 |
link.className = 'bkbg-bios-social-link'; |
| 160 |
link.href = s.url; |
| 161 |
link.target = '_blank'; |
| 162 |
link.rel = 'noopener noreferrer'; |
| 163 |
link.title = s.label || s.platform; |
| 164 |
link.style.color = a.socialColor || '#6b7280'; |
| 165 |
link.textContent = SOCIAL_ICONS[s.platform] || (s.platform ? s.platform[0].toUpperCase() : '?'); |
| 166 |
socialsEl.appendChild(link); |
| 167 |
}); |
| 168 |
actionsEl.appendChild(socialsEl); |
| 169 |
} |
| 170 |
|
| 171 |
textEl.appendChild(actionsEl); |
| 172 |
|
| 173 |
inner.appendChild(photoWrap); |
| 174 |
inner.appendChild(textEl); |
| 175 |
wrap.appendChild(inner); |
| 176 |
typoCssVarsForEl(a.typoName, '--bkbg-bios-name-', wrap); |
| 177 |
typoCssVarsForEl(a.typoTitle, '--bkbg-bios-title-', wrap); |
| 178 |
typoCssVarsForEl(a.typoSubtitle, '--bkbg-bios-subtitle-', wrap); |
| 179 |
typoCssVarsForEl(a.typoBio, '--bkbg-bios-bio-', wrap); |
| 180 |
typoCssVarsForEl(a.typoQuote, '--bkbg-bios-quote-', wrap); |
| 181 |
el.replaceWith(wrap); |
| 182 |
}); |
| 183 |
}); |
| 184 |
|