1946 lines
57 KiB
JavaScript
1946 lines
57 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
var CONFIG_URL = 'site.json';
|
|
|
|
function getNestedValue(obj, path) {
|
|
return path.split('.').reduce(function (current, key) {
|
|
return current && current[key] !== undefined ? current[key] : undefined;
|
|
}, obj);
|
|
}
|
|
|
|
function applyMeta(config) {
|
|
var title = getNestedValue(config, 'meta.title');
|
|
if (title) {
|
|
document.title = title;
|
|
}
|
|
}
|
|
|
|
function hexToRgb(hex) {
|
|
var normalized = String(hex).replace('#', '');
|
|
if (normalized.length !== 6) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
r: parseInt(normalized.slice(0, 2), 16),
|
|
g: parseInt(normalized.slice(2, 4), 16),
|
|
b: parseInt(normalized.slice(4, 6), 16)
|
|
};
|
|
}
|
|
|
|
function toHex(value) {
|
|
var hex = Math.round(value).toString(16);
|
|
return hex.length === 1 ? '0' + hex : hex;
|
|
}
|
|
|
|
function lightenHex(hex, amount) {
|
|
var rgb = hexToRgb(hex);
|
|
if (!rgb) {
|
|
return hex;
|
|
}
|
|
|
|
return '#' + toHex(rgb.r + (255 - rgb.r) * amount)
|
|
+ toHex(rgb.g + (255 - rgb.g) * amount)
|
|
+ toHex(rgb.b + (255 - rgb.b) * amount);
|
|
}
|
|
|
|
function applyTheme(config) {
|
|
var theme = config.theme;
|
|
if (!theme) {
|
|
return;
|
|
}
|
|
|
|
var root = document.documentElement;
|
|
|
|
if (theme.accent) {
|
|
var accent = theme.accent;
|
|
var accentEnd = theme.accentLight || lightenHex(accent, 0.28);
|
|
var accentHover = theme.accentHover || lightenHex(accent, 0.1);
|
|
var accentHoverEnd = theme.accentLight || lightenHex(accent, 0.35);
|
|
var rgb = hexToRgb(accent);
|
|
|
|
root.style.setProperty('--eventup-accent', accent);
|
|
root.style.setProperty('--eventup-accent-start', accent);
|
|
root.style.setProperty('--eventup-accent-end', accentEnd);
|
|
root.style.setProperty('--eventup-accent-hover-start', accentHover);
|
|
root.style.setProperty('--eventup-accent-hover-end', accentHoverEnd);
|
|
|
|
if (rgb) {
|
|
root.style.setProperty(
|
|
'--eventup-accent-shadow-25',
|
|
'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', 0.25)'
|
|
);
|
|
root.style.setProperty(
|
|
'--eventup-accent-shadow-40',
|
|
'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', 0.4)'
|
|
);
|
|
}
|
|
}
|
|
|
|
if (theme.heading && theme.heading.color) {
|
|
root.style.setProperty('--eventup-heading-color', theme.heading.color);
|
|
}
|
|
}
|
|
|
|
function resolveLogoSource(logo, placementKey) {
|
|
if (!logo) {
|
|
return null;
|
|
}
|
|
|
|
var placementConfig = placementKey && logo[placementKey] ? logo[placementKey] : null;
|
|
|
|
if (placementConfig && (placementConfig.url || placementConfig.image)) {
|
|
return {
|
|
url: placementConfig.url || (placementConfig.image && placementConfig.image.url) || '',
|
|
alt: placementConfig.alt || (placementConfig.image && placementConfig.image.alt) || '',
|
|
maxHeight: placementConfig.maxHeight
|
|
};
|
|
}
|
|
|
|
if (logo.image) {
|
|
return {
|
|
url: logo.image.url || '',
|
|
alt: logo.image.alt || '',
|
|
maxHeight: placementConfig && placementConfig.maxHeight
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function applyLogo(config) {
|
|
var logo = getNestedValue(config, 'components.logo');
|
|
if (!logo) {
|
|
return;
|
|
}
|
|
|
|
var placements = document.querySelectorAll('[data-site-component="logo"]');
|
|
|
|
placements.forEach(function (placement) {
|
|
var placementKey = placement.getAttribute('data-logo-placement');
|
|
var placementConfig = placementKey ? logo[placementKey] : null;
|
|
var showPlacement = logo.show !== false;
|
|
|
|
if (placementConfig && placementConfig.show === false) {
|
|
showPlacement = false;
|
|
}
|
|
|
|
if (!showPlacement) {
|
|
placement.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
placement.style.display = '';
|
|
|
|
var img = placement.querySelector('[data-logo-image]');
|
|
var logoSource = resolveLogoSource(logo, placementKey);
|
|
|
|
if (img && logoSource && logoSource.url) {
|
|
var maxHeight = logoSource.maxHeight;
|
|
if (maxHeight) {
|
|
img.style.maxHeight = maxHeight + 'px';
|
|
img.style.height = 'auto';
|
|
img.style.width = 'auto';
|
|
img.style.maxWidth = '100%';
|
|
img.style.objectFit = 'contain';
|
|
img.style.display = 'inline-block';
|
|
if (placementKey === 'header') {
|
|
document.documentElement.style.setProperty('--site-header-logo-max-height', maxHeight + 'px');
|
|
}
|
|
}
|
|
|
|
img.style.visibility = 'hidden';
|
|
img.onload = function () {
|
|
img.style.visibility = 'visible';
|
|
if (typeof window.updateNavbarSpacer === 'function') {
|
|
window.updateNavbarSpacer();
|
|
}
|
|
};
|
|
img.src = logoSource.url;
|
|
|
|
if (logoSource.alt) {
|
|
img.alt = logoSource.alt;
|
|
}
|
|
}
|
|
|
|
var link = placement.tagName === 'A' ? placement : placement.querySelector('a');
|
|
if (link && logo.link) {
|
|
if (logo.link.show === false) {
|
|
if (link.tagName === 'A') {
|
|
link.removeAttribute('href');
|
|
link.style.cursor = 'default';
|
|
}
|
|
} else if (logo.link.url) {
|
|
link.href = logo.link.url;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function applyHeroLogo(config) {
|
|
var logo = getNestedValue(config, 'components.logo');
|
|
var heroSection = document.querySelector('[data-site-component="hero"]');
|
|
var wrap = heroSection && heroSection.querySelector('[data-hero-logo]');
|
|
var img = heroSection && heroSection.querySelector('[data-hero-logo-image]');
|
|
|
|
if (!wrap || !img) {
|
|
return;
|
|
}
|
|
|
|
var heroLogo = logo && logo.hero;
|
|
var showHeroLogo = heroLogo && heroLogo.show !== false;
|
|
|
|
if (!showHeroLogo || !heroLogo.url) {
|
|
wrap.hidden = true;
|
|
return;
|
|
}
|
|
|
|
wrap.hidden = false;
|
|
|
|
if (heroLogo.maxHeight) {
|
|
img.style.maxHeight = heroLogo.maxHeight + 'px';
|
|
} else {
|
|
img.style.removeProperty('max-height');
|
|
}
|
|
|
|
img.style.maxWidth = '100%';
|
|
img.style.height = 'auto';
|
|
img.style.width = 'auto';
|
|
img.style.objectFit = 'contain';
|
|
|
|
if (heroLogo.alt) {
|
|
img.alt = heroLogo.alt;
|
|
}
|
|
|
|
img.src = heroLogo.url;
|
|
}
|
|
|
|
function bindCtaLink(link, cta, config) {
|
|
if (!link || !cta) {
|
|
return;
|
|
}
|
|
|
|
if (cta.text) {
|
|
link.textContent = cta.text;
|
|
}
|
|
|
|
if (cta.target === 'modal') {
|
|
link.href = '#';
|
|
link.removeAttribute('target');
|
|
link.removeAttribute('rel');
|
|
|
|
if (window.EventUpRegistrationModal && window.EventUpRegistrationModal.bindLink) {
|
|
window.EventUpRegistrationModal.bindLink(link, cta, config);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (cta.url) {
|
|
link.href = cta.url;
|
|
}
|
|
|
|
if (cta.target === '_blank') {
|
|
link.target = '_blank';
|
|
link.rel = 'noopener noreferrer';
|
|
} else {
|
|
link.removeAttribute('target');
|
|
link.removeAttribute('rel');
|
|
}
|
|
}
|
|
|
|
function applyNavbarCta(config) {
|
|
var cta = getNestedValue(config, 'components.hero.cta');
|
|
var navItem = document.querySelector('[data-nav-cta]');
|
|
var navLink = document.querySelector('[data-nav-cta-link]');
|
|
|
|
if (!navItem || !navLink) {
|
|
return;
|
|
}
|
|
|
|
if (!cta || cta.show === false) {
|
|
navItem.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
navItem.style.display = '';
|
|
bindCtaLink(navLink, cta, config);
|
|
}
|
|
|
|
function applyHero(config) {
|
|
var hero = getNestedValue(config, 'components.hero');
|
|
if (!hero) {
|
|
return;
|
|
}
|
|
|
|
var heroSection = document.querySelector('[data-site-component="hero"]');
|
|
if (!heroSection) {
|
|
return;
|
|
}
|
|
|
|
if (hero.show === false) {
|
|
heroSection.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
heroSection.style.display = '';
|
|
|
|
if (hero.image && hero.image.url && hero.image.show !== false) {
|
|
heroSection.style.backgroundImage = 'url("' + hero.image.url + '")';
|
|
heroSection.style.backgroundRepeat = 'no-repeat';
|
|
heroSection.style.backgroundSize = 'cover';
|
|
heroSection.style.backgroundPosition = 'center';
|
|
}
|
|
|
|
var fields = heroSection.querySelectorAll('[data-hero-field]');
|
|
fields.forEach(function (el) {
|
|
var fieldKey = el.getAttribute('data-hero-field');
|
|
var value = hero[fieldKey];
|
|
|
|
if (value === undefined || value === null || value === '') {
|
|
el.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
el.style.display = '';
|
|
el.textContent = value;
|
|
});
|
|
|
|
var ctaWrap = heroSection.querySelector('[data-hero-cta]');
|
|
var ctaLink = heroSection.querySelector('[data-hero-cta-link]');
|
|
var cta = hero.cta;
|
|
|
|
if (ctaWrap && cta) {
|
|
if (cta.show === false) {
|
|
ctaWrap.style.display = 'none';
|
|
} else {
|
|
ctaWrap.style.display = '';
|
|
|
|
if (ctaLink) {
|
|
bindCtaLink(ctaLink, cta, config);
|
|
}
|
|
}
|
|
}
|
|
|
|
applyHeroLogo(config);
|
|
}
|
|
|
|
function formatCountdownTarget(dateStr, timeStr) {
|
|
if (!dateStr) {
|
|
return null;
|
|
}
|
|
|
|
var dateParts = dateStr.split('-');
|
|
if (dateParts.length !== 3) {
|
|
return null;
|
|
}
|
|
|
|
var year = parseInt(dateParts[0], 10);
|
|
var month = parseInt(dateParts[1], 10);
|
|
var day = parseInt(dateParts[2], 10);
|
|
|
|
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
|
return null;
|
|
}
|
|
|
|
var time = timeStr || '00:00';
|
|
var timeParts = time.split(':');
|
|
var hours = String(parseInt(timeParts[0], 10) || 0);
|
|
var minutes = String(parseInt(timeParts[1], 10) || 0);
|
|
var seconds = String(parseInt(timeParts[2], 10) || 0);
|
|
|
|
if (minutes.length < 2) {
|
|
minutes = '0' + minutes;
|
|
}
|
|
if (seconds.length < 2) {
|
|
seconds = '0' + seconds;
|
|
}
|
|
|
|
return year + '/' + month + '/' + day + ' ' + hours + ':' + minutes + ':' + seconds;
|
|
}
|
|
|
|
var COUNTDOWN_HTML =
|
|
'<div class="time-entry days"><span>%-D</span> <b>:</b> Days</div> '
|
|
+ '<div class="time-entry hours"><span>%H</span> <b>:</b> Hours</div> '
|
|
+ '<div class="time-entry minutes"><span>%M</span> <b>:</b> Minutes</div> '
|
|
+ '<div class="time-entry seconds"><span>%S</span> Seconds</div> ';
|
|
|
|
function startCountdown(clock, target) {
|
|
var $clock = jQuery(clock);
|
|
|
|
if ($clock.data('countdown-instance') !== undefined) {
|
|
$clock.countdown('remove');
|
|
}
|
|
|
|
$clock.off('update.countdown finish.countdown');
|
|
$clock.on('update.countdown finish.countdown', function (event) {
|
|
jQuery(this).html(event.strftime(COUNTDOWN_HTML));
|
|
});
|
|
|
|
$clock.countdown(target);
|
|
}
|
|
|
|
function applyCountdown(config) {
|
|
var countdown = getNestedValue(config, 'components.hero.countdown');
|
|
var section = document.querySelector('[data-site-component="countdown"]');
|
|
var clock = document.getElementById('clock');
|
|
|
|
if (!section || !clock) {
|
|
return;
|
|
}
|
|
|
|
if (!countdown || countdown.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
var target = formatCountdownTarget(countdown.date, countdown.time);
|
|
if (!target) {
|
|
section.style.display = 'none';
|
|
console.warn('[site-config] Invalid countdown date or time');
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
function initClock() {
|
|
if (typeof jQuery === 'undefined' || !jQuery.fn.countdown) {
|
|
console.warn('[site-config] jQuery countdown plugin not loaded');
|
|
return;
|
|
}
|
|
|
|
startCountdown(clock, target);
|
|
}
|
|
|
|
if (document.readyState === 'complete') {
|
|
initClock();
|
|
} else {
|
|
window.addEventListener('load', initClock);
|
|
}
|
|
}
|
|
|
|
function buildVideoTile(item, index) {
|
|
var tile = document.createElement('div');
|
|
tile.className = 'video-tile';
|
|
tile.setAttribute('data-video-tile', String(index));
|
|
|
|
var box = document.createElement('div');
|
|
box.className = 'video-tile-box';
|
|
|
|
var video = document.createElement('video');
|
|
video.className = 'video-tile-player stop';
|
|
video.setAttribute('playsinline', '');
|
|
video.setAttribute('loop', '');
|
|
video.setAttribute('preload', 'metadata');
|
|
|
|
var source = document.createElement('source');
|
|
source.src = item.url;
|
|
source.type = 'video/mp4';
|
|
video.appendChild(source);
|
|
|
|
var overlay = document.createElement('div');
|
|
overlay.className = 'video-tile-overlay';
|
|
|
|
var playWrap = document.createElement('div');
|
|
playWrap.className = 'video-tile-play-wrap';
|
|
|
|
var playBtn = document.createElement('button');
|
|
playBtn.type = 'button';
|
|
playBtn.className = 'video-tile-play';
|
|
playBtn.setAttribute('aria-label', 'Play video');
|
|
playBtn.innerHTML = '<i class="lni-play"></i>';
|
|
|
|
playWrap.appendChild(playBtn);
|
|
overlay.appendChild(playWrap);
|
|
box.appendChild(video);
|
|
box.appendChild(overlay);
|
|
tile.appendChild(box);
|
|
|
|
if (item.title) {
|
|
var title = document.createElement('p');
|
|
title.className = 'video-tile-title';
|
|
title.textContent = item.title;
|
|
tile.appendChild(title);
|
|
}
|
|
|
|
tile.classList.add('is-paused');
|
|
return tile;
|
|
}
|
|
|
|
function resolveVideoItems(video) {
|
|
if (Array.isArray(video.items) && video.items.length) {
|
|
return video.items.filter(function (item) {
|
|
return item && item.url;
|
|
});
|
|
}
|
|
|
|
if (video.url) {
|
|
return [{ url: video.url, title: video.title || '' }];
|
|
}
|
|
|
|
return [];
|
|
}
|
|
|
|
function applyVideo(config) {
|
|
var video = getNestedValue(config, 'components.video');
|
|
var section = document.querySelector('[data-site-component="video"]');
|
|
var list = section && section.querySelector('[data-video-list]');
|
|
|
|
if (!section || !video) {
|
|
return;
|
|
}
|
|
|
|
var items = resolveVideoItems(video);
|
|
|
|
if (video.show === false || !items.length) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-video-field="heading"]');
|
|
if (heading && video.heading) {
|
|
heading.textContent = video.heading;
|
|
}
|
|
|
|
if (!list) {
|
|
return;
|
|
}
|
|
|
|
list.innerHTML = '';
|
|
items.forEach(function (item, index) {
|
|
list.appendChild(buildVideoTile(item, index));
|
|
});
|
|
}
|
|
|
|
function padTwoDigits(num) {
|
|
return num < 10 ? '0' + num : String(num);
|
|
}
|
|
|
|
function resolveInfoBarMapsUrl(item, config) {
|
|
if (item.mapsUrl) {
|
|
return item.mapsUrl;
|
|
}
|
|
|
|
if (item.url) {
|
|
return item.url;
|
|
}
|
|
|
|
var map = getNestedValue(config, 'components.map');
|
|
if (map && map.embedUrl) {
|
|
try {
|
|
var parsed = new URL(map.embedUrl, window.location.href);
|
|
var query = parsed.searchParams.get('q');
|
|
|
|
if (query) {
|
|
return 'https://maps.google.com/maps?q=' + encodeURIComponent(query);
|
|
}
|
|
|
|
parsed.searchParams.delete('output');
|
|
return parsed.toString();
|
|
} catch (error) {
|
|
/* fall through */
|
|
}
|
|
}
|
|
|
|
if (item.value) {
|
|
return 'https://maps.google.com/maps?q=' + encodeURIComponent(item.value);
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
function addDaysToDateString(dateStr, days) {
|
|
var parts = dateStr.split('-');
|
|
if (parts.length !== 3) {
|
|
return dateStr;
|
|
}
|
|
|
|
var date = new Date(parseInt(parts[0], 10), parseInt(parts[1], 10) - 1, parseInt(parts[2], 10) + days);
|
|
return date.getFullYear() + '-' + padTwoDigits(date.getMonth() + 1) + '-' + padTwoDigits(date.getDate());
|
|
}
|
|
|
|
function formatCalendarDateToken(dateStr) {
|
|
return String(dateStr || '').replace(/-/g, '');
|
|
}
|
|
|
|
function resolveInfoBarCalendar(item, config) {
|
|
var calendar = item.calendar || {};
|
|
var hero = getNestedValue(config, 'components.hero') || {};
|
|
var meta = (config && config.meta) || {};
|
|
var schedule = getNestedValue(config, 'components.event_schedule') || {};
|
|
var scheduleDays = Array.isArray(schedule.days) ? schedule.days : [];
|
|
var locationItem = null;
|
|
var infoItems = getNestedValue(config, 'components.informationBar.items');
|
|
if (Array.isArray(infoItems)) {
|
|
for (var i = 0; i < infoItems.length; i++) {
|
|
if (infoItems[i] && infoItems[i].action === 'maps') {
|
|
locationItem = infoItems[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
var title = calendar.title || hero.event_name || meta.title || 'Event';
|
|
var start = calendar.start || (hero.countdown && hero.countdown.date) || '';
|
|
var end = calendar.end || start;
|
|
var location = calendar.location || (locationItem && locationItem.value) || '';
|
|
|
|
if (!start && scheduleDays.length) {
|
|
var firstDay = scheduleDays[0];
|
|
var lastDay = scheduleDays[scheduleDays.length - 1];
|
|
|
|
if (firstDay && firstDay.date) {
|
|
start = firstDay.date.replace(/(\w+)\s+(\d+),\s+(\d{4})/, function (_, month, day, year) {
|
|
var monthIndex = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(String(month).toLowerCase());
|
|
if (monthIndex < 0) {
|
|
return '';
|
|
}
|
|
|
|
return year + '-' + padTwoDigits(monthIndex + 1) + '-' + padTwoDigits(parseInt(day, 10));
|
|
});
|
|
}
|
|
|
|
if (lastDay && lastDay.date) {
|
|
end = lastDay.date.replace(/(\w+)\s+(\d+),\s+(\d{4})/, function (_, month, day, year) {
|
|
var monthIndex = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(String(month).toLowerCase());
|
|
if (monthIndex < 0) {
|
|
return '';
|
|
}
|
|
|
|
return year + '-' + padTwoDigits(monthIndex + 1) + '-' + padTwoDigits(parseInt(day, 10));
|
|
});
|
|
}
|
|
}
|
|
|
|
if (!start) {
|
|
return null;
|
|
}
|
|
|
|
if (!end) {
|
|
end = start;
|
|
}
|
|
|
|
return {
|
|
title: title,
|
|
start: start,
|
|
end: end,
|
|
location: location,
|
|
description: calendar.description || ''
|
|
};
|
|
}
|
|
|
|
function buildGoogleCalendarUrl(calendar) {
|
|
if (!calendar || !calendar.start) {
|
|
return '';
|
|
}
|
|
|
|
var startToken = formatCalendarDateToken(calendar.start);
|
|
var endToken = formatCalendarDateToken(addDaysToDateString(calendar.end || calendar.start, 1));
|
|
var params = [
|
|
'action=TEMPLATE',
|
|
'text=' + encodeURIComponent(calendar.title || 'Event'),
|
|
'dates=' + startToken + '/' + endToken
|
|
];
|
|
|
|
if (calendar.location) {
|
|
params.push('location=' + encodeURIComponent(calendar.location));
|
|
}
|
|
|
|
if (calendar.description) {
|
|
params.push('details=' + encodeURIComponent(calendar.description));
|
|
}
|
|
|
|
return 'https://calendar.google.com/calendar/render?' + params.join('&');
|
|
}
|
|
|
|
function bindInfoBarItemAction(itemEl, item, config) {
|
|
if (!itemEl || !item || !item.action) {
|
|
return;
|
|
}
|
|
|
|
var action = item.action;
|
|
|
|
if (action === 'maps') {
|
|
var mapsUrl = resolveInfoBarMapsUrl(item, config);
|
|
if (!mapsUrl) {
|
|
return;
|
|
}
|
|
|
|
itemEl.className += ' info-bar-item--clickable';
|
|
itemEl.setAttribute('role', 'link');
|
|
itemEl.setAttribute('tabindex', '0');
|
|
itemEl.setAttribute('aria-label', (item.label || 'Location') + ': ' + (item.value || ''));
|
|
|
|
var openMaps = function (event) {
|
|
if (event) {
|
|
event.preventDefault();
|
|
}
|
|
window.open(mapsUrl, '_blank', 'noopener,noreferrer');
|
|
};
|
|
|
|
itemEl.addEventListener('click', openMaps);
|
|
itemEl.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
openMaps(event);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (action === 'calendar') {
|
|
var calendar = resolveInfoBarCalendar(item, config);
|
|
var calendarUrl = buildGoogleCalendarUrl(calendar);
|
|
if (!calendarUrl) {
|
|
return;
|
|
}
|
|
|
|
itemEl.className += ' info-bar-item--clickable';
|
|
itemEl.setAttribute('role', 'link');
|
|
itemEl.setAttribute('tabindex', '0');
|
|
itemEl.setAttribute('aria-label', 'Add ' + (item.value || 'event') + ' to calendar');
|
|
|
|
var openCalendar = function (event) {
|
|
if (event) {
|
|
event.preventDefault();
|
|
}
|
|
window.open(calendarUrl, '_blank', 'noopener,noreferrer');
|
|
};
|
|
|
|
itemEl.addEventListener('click', openCalendar);
|
|
itemEl.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
openCalendar(event);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (action === 'register') {
|
|
var cta = item.cta || getNestedValue(config, 'components.hero.cta');
|
|
if (!cta) {
|
|
return;
|
|
}
|
|
|
|
itemEl.className += ' info-bar-item--clickable';
|
|
itemEl.setAttribute('role', 'button');
|
|
itemEl.setAttribute('tabindex', '0');
|
|
itemEl.setAttribute('aria-label', item.label || 'Register');
|
|
|
|
if (cta.target === 'modal' && window.EventUpRegistrationModal && window.EventUpRegistrationModal.open) {
|
|
var openRegistration = function (event) {
|
|
if (event) {
|
|
event.preventDefault();
|
|
}
|
|
|
|
var registrationUrl = window.EventUpRegistrationModal.resolveUrl
|
|
? window.EventUpRegistrationModal.resolveUrl(cta, config)
|
|
: cta.url;
|
|
|
|
window.EventUpRegistrationModal.open(
|
|
registrationUrl,
|
|
cta.text || item.label || 'Register'
|
|
);
|
|
};
|
|
|
|
itemEl.addEventListener('click', openRegistration);
|
|
itemEl.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
openRegistration(event);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (cta.url) {
|
|
var registerUrl = cta.url;
|
|
var openRegisterUrl = function (event) {
|
|
if (event) {
|
|
event.preventDefault();
|
|
}
|
|
|
|
if (cta.target === '_blank') {
|
|
window.open(registerUrl, '_blank', 'noopener,noreferrer');
|
|
} else {
|
|
window.location.href = registerUrl;
|
|
}
|
|
};
|
|
|
|
itemEl.addEventListener('click', openRegisterUrl);
|
|
itemEl.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
openRegisterUrl(event);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function applyInformationBar(config) {
|
|
var infoBar = getNestedValue(config, 'components.informationBar');
|
|
var section = document.querySelector('[data-site-component="information-bar"]');
|
|
var list = section && section.querySelector('[data-info-list]');
|
|
|
|
if (!section || !infoBar) {
|
|
return;
|
|
}
|
|
|
|
if (infoBar.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
if (!list || !Array.isArray(infoBar.items)) {
|
|
return;
|
|
}
|
|
|
|
list.innerHTML = '';
|
|
|
|
infoBar.items.forEach(function (item) {
|
|
if (!item || item.show === false) {
|
|
return;
|
|
}
|
|
|
|
var col = document.createElement('div');
|
|
col.className = 'col-lg-3 col-md-6 col-xs-12';
|
|
|
|
var itemEl = document.createElement('div');
|
|
itemEl.className = 'info-bar-item';
|
|
itemEl.innerHTML =
|
|
'<i class="' + (item.icon || 'lni-check-mark-circle') + ' info-bar-item__icon"></i>'
|
|
+ '<div class="info-bar-item__text">'
|
|
+ '<b class="info-bar-item__label">' + (item.label || '') + '</b>'
|
|
+ '<span class="info-bar-item__value">' + (item.value || '') + '</span>'
|
|
+ '</div>';
|
|
|
|
bindInfoBarItemAction(itemEl, item, config);
|
|
col.appendChild(itemEl);
|
|
list.appendChild(col);
|
|
});
|
|
}
|
|
|
|
function aboutMediaUrl(about, key) {
|
|
var val = about[key];
|
|
if (!val) {
|
|
return '';
|
|
}
|
|
if (typeof val === 'string') {
|
|
return val.trim();
|
|
}
|
|
if (val.url) {
|
|
return String(val.url).trim();
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function parseYoutubeEmbedUrl(url) {
|
|
if (!url || typeof url !== 'string') {
|
|
return '';
|
|
}
|
|
|
|
var trimmed = url.trim();
|
|
if (!trimmed) {
|
|
return '';
|
|
}
|
|
|
|
var match = trimmed.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);
|
|
if (match) {
|
|
return 'https://www.youtube.com/embed/' + match[1];
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
function appendYoutubeEmbedParams(embedUrl) {
|
|
var joiner = embedUrl.indexOf('?') >= 0 ? '&' : '?';
|
|
return embedUrl + joiner + 'rel=0&modestbranding=1&controls=1&fs=0&iv_load_policy=3';
|
|
}
|
|
|
|
function buildAboutVideoPlayer(videoUrl) {
|
|
var wrap = document.createElement('div');
|
|
wrap.className = 'about-media-video-wrap';
|
|
|
|
var videoEl = document.createElement('video');
|
|
videoEl.className = 'about-media-video';
|
|
videoEl.playsInline = true;
|
|
videoEl.preload = 'metadata';
|
|
videoEl.src = videoUrl;
|
|
|
|
var controls = document.createElement('div');
|
|
controls.className = 'about-media-video-controls';
|
|
|
|
var playBtn = document.createElement('button');
|
|
playBtn.type = 'button';
|
|
playBtn.className = 'about-media-video-play';
|
|
playBtn.setAttribute('aria-label', 'Play');
|
|
playBtn.innerHTML = '<i class="lni-play"></i>';
|
|
|
|
var seek = document.createElement('input');
|
|
seek.type = 'range';
|
|
seek.className = 'about-media-video-seek';
|
|
seek.min = '0';
|
|
seek.max = '0';
|
|
seek.step = '0.1';
|
|
seek.value = '0';
|
|
seek.setAttribute('aria-label', 'Seek');
|
|
|
|
controls.appendChild(playBtn);
|
|
controls.appendChild(seek);
|
|
wrap.appendChild(videoEl);
|
|
wrap.appendChild(controls);
|
|
|
|
var seeking = false;
|
|
|
|
function setPlaying(playing) {
|
|
playBtn.innerHTML = playing ? '<i class="lni-pause"></i>' : '<i class="lni-play"></i>';
|
|
playBtn.setAttribute('aria-label', playing ? 'Pause' : 'Play');
|
|
}
|
|
|
|
playBtn.addEventListener('click', function () {
|
|
if (videoEl.paused) {
|
|
videoEl.play();
|
|
} else {
|
|
videoEl.pause();
|
|
}
|
|
});
|
|
|
|
videoEl.addEventListener('play', function () {
|
|
setPlaying(true);
|
|
});
|
|
|
|
videoEl.addEventListener('pause', function () {
|
|
setPlaying(false);
|
|
});
|
|
|
|
videoEl.addEventListener('loadedmetadata', function () {
|
|
if (videoEl.duration && isFinite(videoEl.duration)) {
|
|
seek.max = String(videoEl.duration);
|
|
}
|
|
});
|
|
|
|
videoEl.addEventListener('timeupdate', function () {
|
|
if (!seeking && videoEl.duration) {
|
|
seek.value = String(videoEl.currentTime);
|
|
}
|
|
});
|
|
|
|
seek.addEventListener('input', function () {
|
|
seeking = true;
|
|
videoEl.currentTime = parseFloat(seek.value) || 0;
|
|
});
|
|
|
|
seek.addEventListener('change', function () {
|
|
seeking = false;
|
|
});
|
|
|
|
videoEl.addEventListener('click', function () {
|
|
if (videoEl.paused) {
|
|
videoEl.play();
|
|
} else {
|
|
videoEl.pause();
|
|
}
|
|
});
|
|
|
|
return wrap;
|
|
}
|
|
|
|
function applyAboutMedia(section, about) {
|
|
var mediaCol = section.querySelector('[data-about-media-col]');
|
|
var slot = section.querySelector('[data-about-media-slot]');
|
|
|
|
if (!mediaCol || !slot) {
|
|
return;
|
|
}
|
|
|
|
slot.innerHTML = '';
|
|
mediaCol.hidden = true;
|
|
|
|
var imageUrl = about.image && about.image.url ? String(about.image.url).trim() : '';
|
|
var videoUrl = aboutMediaUrl(about, 'video');
|
|
var embedUrl = parseYoutubeEmbedUrl(about.youtubeUrl || '');
|
|
|
|
if (imageUrl) {
|
|
var img = document.createElement('img');
|
|
img.className = 'img-fluid about-media-image';
|
|
img.alt = about.image && about.image.alt ? about.image.alt : '';
|
|
img.src = imageUrl;
|
|
slot.appendChild(img);
|
|
mediaCol.hidden = false;
|
|
return;
|
|
}
|
|
|
|
if (videoUrl) {
|
|
slot.appendChild(buildAboutVideoPlayer(videoUrl));
|
|
mediaCol.hidden = false;
|
|
return;
|
|
}
|
|
|
|
if (embedUrl) {
|
|
var embedWrap = document.createElement('div');
|
|
embedWrap.className = 'about-media-embed';
|
|
var iframe = document.createElement('iframe');
|
|
iframe.src = appendYoutubeEmbedParams(embedUrl);
|
|
iframe.title = 'About video';
|
|
iframe.setAttribute(
|
|
'allow',
|
|
'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture',
|
|
);
|
|
embedWrap.appendChild(iframe);
|
|
slot.appendChild(embedWrap);
|
|
mediaCol.hidden = false;
|
|
return;
|
|
}
|
|
}
|
|
|
|
function applyAbout(config) {
|
|
var about = getNestedValue(config, 'components.about');
|
|
var section = document.querySelector('[data-site-component="about"]');
|
|
|
|
if (!section || !about) {
|
|
return;
|
|
}
|
|
|
|
if (about.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-about-field="heading"]');
|
|
if (heading && about.heading) {
|
|
heading.textContent = about.heading;
|
|
}
|
|
|
|
var content = section.querySelector('[data-about-content]');
|
|
if (content && about.content) {
|
|
content.innerHTML = about.content;
|
|
}
|
|
|
|
applyAboutMedia(section, about);
|
|
|
|
var list = section.querySelector('[data-about-list]');
|
|
if (list && Array.isArray(about.highlights)) {
|
|
list.innerHTML = '';
|
|
|
|
if (about.highlights.length === 0) {
|
|
list.style.display = 'none';
|
|
} else {
|
|
list.style.display = '';
|
|
about.highlights.forEach(function (item) {
|
|
if (!item) {
|
|
return;
|
|
}
|
|
var li = document.createElement('li');
|
|
li.innerHTML = '<i class="lni-check-mark-circle"></i>' + item;
|
|
list.appendChild(li);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function applyAboutCrest(config) {
|
|
var aboutCrest = getNestedValue(config, 'components.about_crest');
|
|
var section = document.querySelector('[data-site-component="about_crest"]');
|
|
|
|
if (!section || !aboutCrest) {
|
|
return;
|
|
}
|
|
|
|
if (aboutCrest.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-about-crest-field="heading"]');
|
|
if (heading && aboutCrest.heading) {
|
|
heading.textContent = aboutCrest.heading;
|
|
}
|
|
|
|
var content = section.querySelector('[data-about-crest-content]');
|
|
if (content && aboutCrest.content) {
|
|
content.innerHTML = aboutCrest.content;
|
|
}
|
|
|
|
var ctaWrap = section.querySelector('[data-about-crest-cta]');
|
|
var ctaLink = section.querySelector('[data-about-crest-cta-link]');
|
|
var cta = aboutCrest.cta;
|
|
|
|
if (ctaWrap && cta && cta.url) {
|
|
ctaWrap.hidden = false;
|
|
if (ctaLink) {
|
|
if (cta.text) {
|
|
ctaLink.textContent = cta.text;
|
|
}
|
|
ctaLink.href = cta.url;
|
|
if (cta.target === '_blank') {
|
|
ctaLink.target = '_blank';
|
|
ctaLink.rel = 'noopener noreferrer';
|
|
}
|
|
}
|
|
} else if (ctaWrap) {
|
|
ctaWrap.hidden = true;
|
|
}
|
|
}
|
|
|
|
function formatHighlightNumber(index) {
|
|
var num = index + 1;
|
|
return num < 10 ? '0' + num : String(num);
|
|
}
|
|
|
|
function applyEventHighlights(config) {
|
|
var highlights = getNestedValue(config, 'components.event_highlights');
|
|
var section = document.querySelector('[data-site-component="event_highlights"]');
|
|
|
|
if (!section || !highlights) {
|
|
return;
|
|
}
|
|
|
|
if (highlights.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-event-highlights-field="heading"]');
|
|
if (heading && highlights.heading) {
|
|
heading.textContent = highlights.heading;
|
|
}
|
|
|
|
var subtitle = section.querySelector('[data-event-highlights-subtitle]');
|
|
if (subtitle) {
|
|
if (highlights.subtitle) {
|
|
subtitle.innerHTML = highlights.subtitle;
|
|
subtitle.style.display = '';
|
|
} else {
|
|
subtitle.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
var list = section.querySelector('[data-event-highlights-list]');
|
|
if (!list || !Array.isArray(highlights.items)) {
|
|
return;
|
|
}
|
|
|
|
list.innerHTML = '';
|
|
|
|
var visibleIndex = 0;
|
|
highlights.items.forEach(function (item) {
|
|
if (!item || item.show === false) {
|
|
return;
|
|
}
|
|
|
|
var col = document.createElement('div');
|
|
col.className = 'col-lg-4 col-md-6 col-xs-12';
|
|
col.innerHTML =
|
|
'<div class="single-intro-text mb-70">'
|
|
+ '<i class="' + (item.icon || 'lni-check-mark-circle') + '"></i>'
|
|
+ '<h3>' + (item.title || '') + '</h3>'
|
|
+ '<p>' + (item.description || '') + '</p>'
|
|
+ '<span class="count-number">' + formatHighlightNumber(visibleIndex) + '</span>'
|
|
+ '</div>';
|
|
list.appendChild(col);
|
|
visibleIndex += 1;
|
|
});
|
|
}
|
|
|
|
function getStatsColClass(itemCount) {
|
|
if (itemCount <= 1) {
|
|
return 'col-lg-12';
|
|
}
|
|
if (itemCount === 2) {
|
|
return 'col-lg-6';
|
|
}
|
|
if (itemCount === 3) {
|
|
return 'col-lg-4';
|
|
}
|
|
return 'col-lg-3';
|
|
}
|
|
|
|
function parseStatValue(value) {
|
|
if (value == null || value === '') {
|
|
return 0;
|
|
}
|
|
|
|
var parsed = parseInt(String(value).replace(/,/g, ''), 10);
|
|
return isNaN(parsed) ? 0 : parsed;
|
|
}
|
|
|
|
function animateStatCounter(element, targetValue) {
|
|
var target = parseStatValue(targetValue);
|
|
var duration = 1500;
|
|
var startTime = null;
|
|
|
|
element.textContent = '0';
|
|
|
|
function step(timestamp) {
|
|
if (!startTime) {
|
|
startTime = timestamp;
|
|
}
|
|
|
|
var progress = Math.min((timestamp - startTime) / duration, 1);
|
|
element.textContent = String(Math.floor(progress * target));
|
|
|
|
if (progress < 1) {
|
|
window.requestAnimationFrame(step);
|
|
} else {
|
|
element.textContent = String(target);
|
|
}
|
|
}
|
|
|
|
if (window.requestAnimationFrame) {
|
|
window.requestAnimationFrame(step);
|
|
} else {
|
|
element.textContent = String(target);
|
|
}
|
|
}
|
|
|
|
function initCounterUp(section) {
|
|
var counters = section.querySelectorAll('.counterUp');
|
|
|
|
counters.forEach(function (counter) {
|
|
var target = counter.getAttribute('data-count-to');
|
|
if (target == null) {
|
|
target = counter.textContent;
|
|
}
|
|
|
|
if (typeof jQuery !== 'undefined' && jQuery.fn.waypoint && jQuery(counter).data('waypoint')) {
|
|
jQuery(counter).waypoint('destroy');
|
|
}
|
|
|
|
animateStatCounter(counter, target);
|
|
});
|
|
}
|
|
|
|
function applyEventStats(config) {
|
|
var stats = getNestedValue(config, 'components.event_stats');
|
|
var section = document.querySelector('[data-site-component="event_stats"]');
|
|
var list = section && section.querySelector('[data-event-stats-list]');
|
|
|
|
if (!section || !stats) {
|
|
return;
|
|
}
|
|
|
|
if (stats.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
if (!list || !Array.isArray(stats.items)) {
|
|
return;
|
|
}
|
|
|
|
var visibleItems = stats.items.filter(function (item) {
|
|
return item && item.show !== false;
|
|
});
|
|
|
|
list.innerHTML = '';
|
|
var colClass = getStatsColClass(visibleItems.length);
|
|
|
|
visibleItems.forEach(function (item) {
|
|
var col = document.createElement('div');
|
|
col.className = colClass + ' col-md-6 col-xs-12 work-counter-widget';
|
|
col.innerHTML =
|
|
'<div class="counter">'
|
|
+ '<div class="icon"><i class="' + (item.icon || 'lni-check-mark-circle') + '"></i></div>'
|
|
+ '<div class="counter-content">'
|
|
+ '<div class="counterUp" data-count-to="' + parseStatValue(item.value) + '">' + parseStatValue(item.value) + '</div>'
|
|
+ '<p>' + (item.label || '') + '</p>'
|
|
+ '</div>'
|
|
+ '</div>';
|
|
list.appendChild(col);
|
|
});
|
|
|
|
initCounterUp(section);
|
|
}
|
|
|
|
function renderScheduleSession(session) {
|
|
var typeHtml = session.type
|
|
? '<span class="session-type">' + session.type + '</span>'
|
|
: '';
|
|
|
|
return '<div class="card schedule-session-card">'
|
|
+ '<div class="schedule-session-row">'
|
|
+ '<span class="schedule-session-time">' + (session.time || '') + '</span>'
|
|
+ '<span class="schedule-session-sep" aria-hidden="true">·</span>'
|
|
+ '<div class="schedule-session-body">'
|
|
+ '<h4>' + (session.title || '') + '</h4>'
|
|
+ typeHtml
|
|
+ '</div>'
|
|
+ '</div>'
|
|
+ '</div>';
|
|
}
|
|
|
|
function applyEventSchedule(config) {
|
|
var schedule = getNestedValue(config, 'components.event_schedule');
|
|
var section = document.querySelector('[data-site-component="event_schedule"]');
|
|
|
|
if (!section || !schedule) {
|
|
return;
|
|
}
|
|
|
|
if (schedule.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-schedule-field="heading"]');
|
|
if (heading && schedule.heading) {
|
|
heading.textContent = schedule.heading;
|
|
}
|
|
|
|
var subtitle = section.querySelector('[data-schedule-subtitle]');
|
|
if (subtitle) {
|
|
if (schedule.subtitle) {
|
|
subtitle.innerHTML = schedule.subtitle;
|
|
subtitle.style.display = '';
|
|
} else {
|
|
subtitle.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
var singleDateWrap = section.querySelector('[data-schedule-single-date-wrap]');
|
|
var singleDateEl = section.querySelector('[data-schedule-single-date]');
|
|
var tabsWrap = section.querySelector('[data-schedule-tabs-wrap]');
|
|
var tabsEl = section.querySelector('[data-schedule-tabs]');
|
|
var contentEl = section.querySelector('[data-schedule-content]');
|
|
|
|
if (!contentEl || !Array.isArray(schedule.days)) {
|
|
return;
|
|
}
|
|
|
|
var days = schedule.days.filter(function (day) {
|
|
return day && day.show !== false;
|
|
});
|
|
|
|
var sessionsHtml = function (day) {
|
|
return (day.sessions || []).filter(function (session) {
|
|
return session && session.show !== false;
|
|
}).map(renderScheduleSession).join('');
|
|
};
|
|
|
|
if (days.length === 1) {
|
|
if (singleDateWrap) {
|
|
singleDateWrap.classList.remove('is-hidden');
|
|
}
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.add('is-hidden');
|
|
}
|
|
if (singleDateEl) {
|
|
singleDateEl.textContent = days[0].date || days[0].label || '';
|
|
}
|
|
contentEl.innerHTML =
|
|
'<div class="tab-pane fade show active">'
|
|
+ '<div class="schedule-day-sessions">' + sessionsHtml(days[0]) + '</div>'
|
|
+ '</div>';
|
|
} else if (days.length > 1) {
|
|
if (singleDateWrap) {
|
|
singleDateWrap.classList.add('is-hidden');
|
|
}
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.remove('is-hidden');
|
|
}
|
|
if (tabsEl) {
|
|
tabsEl.innerHTML = '';
|
|
}
|
|
contentEl.innerHTML = '';
|
|
|
|
days.forEach(function (day, index) {
|
|
var tabId = 'schedule-day-' + index;
|
|
var isActive = index === 0;
|
|
|
|
if (tabsEl) {
|
|
var li = document.createElement('li');
|
|
li.className = 'nav-item';
|
|
li.innerHTML =
|
|
'<a class="nav-link' + (isActive ? ' active' : '') + '" id="' + tabId + '-tab" data-toggle="tab" href="#' + tabId + '" role="tab">'
|
|
+ '<div class="item-text">'
|
|
+ '<h4>' + (day.label || 'Day ' + (index + 1)) + '</h4>'
|
|
+ '<h5>' + (day.date || '') + '</h5>'
|
|
+ '</div>'
|
|
+ '</a>';
|
|
tabsEl.appendChild(li);
|
|
}
|
|
|
|
var pane = document.createElement('div');
|
|
pane.className = 'tab-pane fade' + (isActive ? ' show active' : '');
|
|
pane.id = tabId;
|
|
pane.setAttribute('role', 'tabpanel');
|
|
pane.innerHTML = '<div class="schedule-day-sessions">' + sessionsHtml(day) + '</div>';
|
|
contentEl.appendChild(pane);
|
|
});
|
|
} else {
|
|
if (singleDateWrap) {
|
|
singleDateWrap.classList.add('is-hidden');
|
|
}
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.add('is-hidden');
|
|
}
|
|
contentEl.innerHTML = '';
|
|
}
|
|
}
|
|
|
|
function applySectionMeta(section, config, fieldAttr, subtitleAttr) {
|
|
var hideHeading = config.hideHeading === true
|
|
|| (config.heading === '' && config.subtitle === '');
|
|
|
|
var titleHeader = section.querySelector('.section-title-header');
|
|
if (titleHeader && hideHeading) {
|
|
titleHeader.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
if (titleHeader) {
|
|
titleHeader.style.display = '';
|
|
}
|
|
|
|
if (config.heading) {
|
|
var heading = section.querySelector('[' + fieldAttr + '="heading"]');
|
|
if (heading) {
|
|
heading.textContent = config.heading;
|
|
}
|
|
} else {
|
|
var headingEl = section.querySelector('[' + fieldAttr + '="heading"]');
|
|
if (headingEl && hideHeading) {
|
|
headingEl.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
if (subtitleAttr) {
|
|
var subtitle = section.querySelector('[' + subtitleAttr + ']');
|
|
if (subtitle) {
|
|
if (config.subtitle) {
|
|
subtitle.innerHTML = config.subtitle;
|
|
subtitle.style.display = '';
|
|
} else {
|
|
subtitle.style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function renderSpeakerItem(item, index) {
|
|
var socialHtml = '';
|
|
if (item.social && item.social.length) {
|
|
socialHtml = '<div class="team-overlay"><div class="overlay-social-icon text-center"><ul class="social-icons">'
|
|
+ item.social.map(function (social) {
|
|
return '<li><a href="' + (social.url || '#') + '" target="_blank" rel="noopener noreferrer"><i class="' + social.icon + '" aria-hidden="true"></i></a></li>';
|
|
}).join('')
|
|
+ '</ul></div></div>';
|
|
}
|
|
|
|
return '<div class="col-lg-3 col-md-6 col-xs-12">'
|
|
+ '<div class="team-item wow fadeInUp" data-wow-delay="' + (0.2 + index * 0.2) + 's">'
|
|
+ '<div class="team-img">'
|
|
+ '<img class="img-fluid" src="' + (item.image || '') + '" alt="' + (item.name || '') + '">'
|
|
+ socialHtml
|
|
+ '</div>'
|
|
+ '<div class="info-text">'
|
|
+ '<h3><a href="' + (item.url || '#') + '">' + (item.name || '') + '</a></h3>'
|
|
+ '<p>' + (item.role || '') + '</p>'
|
|
+ '</div></div></div>';
|
|
}
|
|
|
|
function renderSpeakerItems(items) {
|
|
return items.filter(function (item) {
|
|
return item && item.show !== false;
|
|
}).map(function (item, index) {
|
|
return renderSpeakerItem(item, index);
|
|
}).join('');
|
|
}
|
|
|
|
function applySpeakers(config) {
|
|
var speakers = getNestedValue(config, 'components.speakers');
|
|
var section = document.querySelector('[data-site-component="speakers"]');
|
|
var tabsWrap = section && section.querySelector('[data-speakers-tabs-wrap]');
|
|
var tabsEl = section && section.querySelector('[data-speakers-tabs]');
|
|
var contentEl = section && section.querySelector('[data-speakers-content]');
|
|
|
|
if (!section || !speakers) {
|
|
return;
|
|
}
|
|
|
|
if (speakers.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
applySectionMeta(section, speakers, 'data-speakers-field', 'data-speakers-subtitle');
|
|
|
|
if (!contentEl) {
|
|
return;
|
|
}
|
|
|
|
var tabs = [];
|
|
|
|
if (Array.isArray(speakers.tabs)) {
|
|
tabs = speakers.tabs.filter(function (tab) {
|
|
return tab && tab.show !== false;
|
|
});
|
|
} else if (Array.isArray(speakers.items)) {
|
|
tabs = [{ label: 'Speakers', items: speakers.items }];
|
|
}
|
|
|
|
tabs = tabs.filter(function (tab) {
|
|
return Array.isArray(tab.items) && tab.items.some(function (item) {
|
|
return item && item.show !== false;
|
|
});
|
|
});
|
|
|
|
if (tabs.length === 1) {
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.add('is-hidden');
|
|
}
|
|
if (tabsEl) {
|
|
tabsEl.innerHTML = '';
|
|
}
|
|
contentEl.innerHTML =
|
|
'<div class="row justify-content-bt speakers-panel">'
|
|
+ renderSpeakerItems(tabs[0].items)
|
|
+ '</div>';
|
|
} else if (tabs.length > 1) {
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.remove('is-hidden');
|
|
}
|
|
if (tabsEl) {
|
|
tabsEl.innerHTML = '';
|
|
}
|
|
contentEl.innerHTML = '';
|
|
|
|
tabs.forEach(function (tab, index) {
|
|
var tabId = 'speakers-tab-' + index;
|
|
var isActive = index === 0;
|
|
|
|
if (tabsEl) {
|
|
var li = document.createElement('li');
|
|
li.className = 'nav-item';
|
|
li.innerHTML =
|
|
'<a class="nav-link' + (isActive ? ' active' : '') + '" id="' + tabId + '-tab" data-toggle="tab" href="#' + tabId + '" role="tab">'
|
|
+ (tab.label || 'Tab ' + (index + 1))
|
|
+ '</a>';
|
|
tabsEl.appendChild(li);
|
|
}
|
|
|
|
var pane = document.createElement('div');
|
|
pane.className = 'tab-pane fade' + (isActive ? ' show active' : '');
|
|
pane.id = tabId;
|
|
pane.setAttribute('role', 'tabpanel');
|
|
pane.innerHTML =
|
|
'<div class="row justify-content-bt speakers-panel">'
|
|
+ renderSpeakerItems(tab.items)
|
|
+ '</div>';
|
|
contentEl.appendChild(pane);
|
|
});
|
|
} else {
|
|
if (tabsWrap) {
|
|
tabsWrap.classList.add('is-hidden');
|
|
}
|
|
if (tabsEl) {
|
|
tabsEl.innerHTML = '';
|
|
}
|
|
contentEl.innerHTML = '';
|
|
}
|
|
}
|
|
|
|
function applyLatestNews(config) {
|
|
var news = getNestedValue(config, 'components.latest_news');
|
|
var section = document.querySelector('[data-site-component="latest_news"]');
|
|
var list = section && section.querySelector('[data-news-list]');
|
|
|
|
if (!section || !news) {
|
|
return;
|
|
}
|
|
|
|
if (news.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
applySectionMeta(section, news, 'data-news-field', 'data-news-subtitle');
|
|
|
|
if (list && Array.isArray(news.items)) {
|
|
list.innerHTML = news.items.filter(function (item) {
|
|
return item && item.show !== false;
|
|
}).map(function (item) {
|
|
return '<div class="col-lg-4 col-md-6 col-xs-12"><div class="blog-item">'
|
|
+ '<div class="blog-image"><a href="' + (item.url || '#') + '">'
|
|
+ '<img class="img-fluid" src="' + (item.image || '') + '" alt="' + (item.title || '') + '">'
|
|
+ '</a></div><div class="descr">'
|
|
+ '<div class="icon"><i class="' + (item.icon || 'lni-arrow-right') + '"></i></div>'
|
|
+ '<h3 class="title"><a href="' + (item.url || '#') + '">' + (item.title || '') + '</a></h3>'
|
|
+ '<p>' + (item.description || '') + '</p>'
|
|
+ '</div><div class="meta-tags">'
|
|
+ '<span class="date"><i class="lni-calendar"></i> ' + (item.date || '') + '</span>'
|
|
+ '</div></div></div>';
|
|
}).join('');
|
|
}
|
|
}
|
|
|
|
function renderSponsorItem(item) {
|
|
var alt = item.alt || '';
|
|
var imageHtml = '<img src="' + (item.image || '') + '" alt="' + alt + '">';
|
|
|
|
if (item.url) {
|
|
return '<a href="' + item.url + '" class="sponsor-item">' + imageHtml + '</a>';
|
|
}
|
|
|
|
return '<span class="sponsor-item">' + imageHtml + '</span>';
|
|
}
|
|
|
|
function renderSponsorGroup(group, sponsorsConfig) {
|
|
if (!group || group.show === false) {
|
|
return '';
|
|
}
|
|
|
|
var items = (group.items || []).filter(function (item) {
|
|
return item && item.show !== false;
|
|
});
|
|
|
|
if (!items.length) {
|
|
return '';
|
|
}
|
|
|
|
var tier = group.tier || 'other';
|
|
var hideGroupTitles = sponsorsConfig && sponsorsConfig.hideGroupTitles === true;
|
|
var titleHtml = (!hideGroupTitles && group.title)
|
|
? '<h3 class="sponsors-group-title">' + group.title + '</h3>'
|
|
: '';
|
|
|
|
return '<div class="sponsors-group sponsors-group-' + tier + '">'
|
|
+ titleHtml
|
|
+ '<div class="sponsors-logo sponsors-logo-' + tier + '">'
|
|
+ items.map(renderSponsorItem).join('')
|
|
+ '</div>'
|
|
+ '</div>';
|
|
}
|
|
|
|
function applySponsors(config) {
|
|
var sponsors = getNestedValue(config, 'components.sponsors');
|
|
var section = document.querySelector('[data-site-component="sponsors"]');
|
|
var list = section && section.querySelector('[data-sponsors-list]');
|
|
|
|
if (!section || !sponsors) {
|
|
return;
|
|
}
|
|
|
|
if (sponsors.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
applySectionMeta(section, sponsors, 'data-sponsors-field', 'data-sponsors-subtitle');
|
|
|
|
if (!list) {
|
|
return;
|
|
}
|
|
|
|
var groups = [];
|
|
|
|
if (Array.isArray(sponsors.groups)) {
|
|
groups = sponsors.groups;
|
|
} else if (Array.isArray(sponsors.items)) {
|
|
groups = [{ title: '', tier: 'other', items: sponsors.items }];
|
|
}
|
|
|
|
list.innerHTML = groups.map(function (group) {
|
|
return renderSponsorGroup(group, sponsors);
|
|
}).join('');
|
|
}
|
|
|
|
function applyMap(config) {
|
|
var map = getNestedValue(config, 'components.map');
|
|
var section = document.querySelector('[data-site-component="map"]');
|
|
var embed = section && section.querySelector('[data-map-embed]');
|
|
|
|
if (!section || !map) {
|
|
return;
|
|
}
|
|
|
|
if (map.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
if (embed && map.embedUrl) {
|
|
embed.src = map.embedUrl;
|
|
}
|
|
|
|
if (embed && map.height) {
|
|
embed.style.height = typeof map.height === 'number' ? map.height + 'px' : map.height;
|
|
}
|
|
}
|
|
|
|
function applyContact(config) {
|
|
var contact = getNestedValue(config, 'components.contact');
|
|
var section = document.querySelector('[data-site-component="contact"]');
|
|
|
|
if (!section || !contact) {
|
|
return;
|
|
}
|
|
|
|
if (contact.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var heading = section.querySelector('[data-contact-field="heading"]');
|
|
if (heading && contact.heading) {
|
|
heading.textContent = contact.heading;
|
|
}
|
|
|
|
var subtitle = section.querySelector('[data-contact-field="subtitle"]');
|
|
if (subtitle) {
|
|
if (contact.subtitle) {
|
|
subtitle.innerHTML = contact.subtitle;
|
|
subtitle.style.display = '';
|
|
} else {
|
|
subtitle.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
var detailsWrap = section.querySelector('[data-contact-details]');
|
|
var phonesList = section.querySelector('[data-contact-phones]');
|
|
var addressEl = section.querySelector('[data-contact-address]');
|
|
var phones = Array.isArray(contact.phones) ? contact.phones : [];
|
|
var hasDetails = phones.length > 0 || contact.address;
|
|
|
|
if (detailsWrap) {
|
|
if (!hasDetails) {
|
|
detailsWrap.hidden = true;
|
|
} else {
|
|
detailsWrap.hidden = false;
|
|
}
|
|
}
|
|
|
|
if (phonesList) {
|
|
phonesList.innerHTML = phones.map(function (phone) {
|
|
if (!phone || !phone.number) {
|
|
return '';
|
|
}
|
|
|
|
var tel = phone.tel || phone.number.replace(/[^\d+]/g, '');
|
|
var label = phone.label ? '<span class="contact-phone-label">' + phone.label + '</span> ' : '';
|
|
|
|
return '<li>'
|
|
+ label
|
|
+ '<a href="tel:' + tel + '">' + phone.number + '</a>'
|
|
+ '</li>';
|
|
}).join('');
|
|
}
|
|
|
|
if (addressEl) {
|
|
if (contact.address) {
|
|
addressEl.textContent = contact.address;
|
|
addressEl.style.display = '';
|
|
} else {
|
|
addressEl.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
if (window.EventUpContactForm && window.EventUpContactForm.init) {
|
|
window.EventUpContactForm.init(contact, config);
|
|
}
|
|
}
|
|
|
|
function applyFeedback(config) {
|
|
var feedback = getNestedValue(config, 'components.feedback');
|
|
|
|
if (!feedback) {
|
|
return;
|
|
}
|
|
|
|
if (window.EventUpFeedbackFab && window.EventUpFeedbackFab.init) {
|
|
window.EventUpFeedbackFab.init(feedback, config);
|
|
}
|
|
}
|
|
|
|
function applyFooter(config) {
|
|
var footer = getNestedValue(config, 'components.footer');
|
|
var section = document.querySelector('[data-site-component="footer"]');
|
|
|
|
if (!section) {
|
|
return;
|
|
}
|
|
|
|
if (!footer || footer.show === false) {
|
|
section.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
section.style.display = '';
|
|
|
|
var logoImg = section.querySelector('[data-footer-logo]');
|
|
if (logoImg && footer.logo) {
|
|
if (footer.logo.url) {
|
|
logoImg.src = footer.logo.url;
|
|
}
|
|
if (footer.logo.alt) {
|
|
logoImg.alt = footer.logo.alt;
|
|
}
|
|
if (footer.logo.width) {
|
|
logoImg.width = footer.logo.width;
|
|
}
|
|
}
|
|
|
|
var tagline = section.querySelector('[data-footer-tagline]');
|
|
if (tagline) {
|
|
if (footer.tagline) {
|
|
tagline.textContent = footer.tagline;
|
|
tagline.style.display = '';
|
|
} else {
|
|
tagline.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
var socialWrap = section.querySelector('[data-footer-social-wrap]');
|
|
var socialHeading = section.querySelector('[data-footer-social-heading]');
|
|
var socialList = section.querySelector('[data-footer-social-list]');
|
|
var social = footer.social || {};
|
|
|
|
if (socialWrap) {
|
|
if (social.show === false || !social.links || !social.links.length) {
|
|
socialWrap.style.display = 'none';
|
|
} else {
|
|
socialWrap.style.display = '';
|
|
|
|
if (socialHeading) {
|
|
socialHeading.textContent = social.heading || 'Follow us';
|
|
}
|
|
|
|
if (socialList) {
|
|
socialList.innerHTML = social.links.map(function (item) {
|
|
var label = item.label || 'Social link';
|
|
return '<li><a href="' + (item.url || '#') + '" target="_blank" rel="noopener noreferrer" aria-label="' + label + '"><i class="' + (item.icon || 'lni-link') + '" aria-hidden="true"></i></a></li>';
|
|
}).join('');
|
|
}
|
|
}
|
|
}
|
|
|
|
var linksWrap = section.querySelector('[data-footer-links-wrap]');
|
|
var linksHeading = section.querySelector('[data-footer-links-heading]');
|
|
var linksList = section.querySelector('[data-footer-link-list]');
|
|
var links = footer.links || [];
|
|
|
|
if (linksWrap) {
|
|
if (!links.length) {
|
|
linksWrap.style.display = 'none';
|
|
} else {
|
|
linksWrap.style.display = '';
|
|
|
|
if (linksHeading) {
|
|
if (footer.linksHeading) {
|
|
linksHeading.textContent = footer.linksHeading;
|
|
linksHeading.style.display = '';
|
|
} else {
|
|
linksHeading.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
if (linksList) {
|
|
linksList.innerHTML = links.map(function (item) {
|
|
return '<li><a href="' + (item.url || '#') + '">' + (item.text || '') + '</a></li>';
|
|
}).join('');
|
|
|
|
var linkEls = linksList.querySelectorAll('a');
|
|
links.forEach(function (item, index) {
|
|
var linkEl = linkEls[index];
|
|
if (!linkEl) {
|
|
return;
|
|
}
|
|
|
|
if (item.target === 'modal') {
|
|
bindCtaLink(linkEl, item, config);
|
|
return;
|
|
}
|
|
|
|
if (item.url) {
|
|
linkEl.href = item.url;
|
|
}
|
|
|
|
if (item.target === '_blank') {
|
|
linkEl.target = '_blank';
|
|
linkEl.rel = 'noopener noreferrer';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function applyMarketingPopup(config) {
|
|
var popup = getNestedValue(config, 'components.marketing_popup');
|
|
|
|
if (window.EventUpMarketingPopup && window.EventUpMarketingPopup.init) {
|
|
window.EventUpMarketingPopup.init(popup, config);
|
|
}
|
|
}
|
|
|
|
function applyConfig(config) {
|
|
applyTheme(config);
|
|
applyMeta(config);
|
|
applyLogo(config);
|
|
applyHero(config);
|
|
applyNavbarCta(config);
|
|
applyCountdown(config);
|
|
applyAbout(config);
|
|
applyAboutCrest(config);
|
|
applyVideo(config);
|
|
applyInformationBar(config);
|
|
applyEventHighlights(config);
|
|
applyEventStats(config);
|
|
applyEventSchedule(config);
|
|
applySpeakers(config);
|
|
applyLatestNews(config);
|
|
applySponsors(config);
|
|
applyMap(config);
|
|
applyContact(config);
|
|
applyFeedback(config);
|
|
applyFooter(config);
|
|
applyMarketingPopup(config);
|
|
document.documentElement.classList.add('site-config-loaded');
|
|
document.dispatchEvent(new CustomEvent('site-config-loaded'));
|
|
|
|
if (typeof window.updateNavbarSpacer === 'function') {
|
|
window.updateNavbarSpacer();
|
|
}
|
|
}
|
|
|
|
function init() {
|
|
fetch(CONFIG_URL, { cache: 'no-store' })
|
|
.then(function (response) {
|
|
if (!response.ok) {
|
|
throw new Error('Failed to load site config');
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(applyConfig)
|
|
.catch(function (error) {
|
|
console.warn('[site-config]', error.message);
|
|
document.documentElement.classList.add('site-config-error');
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|