Remove jquery-3.7.1.min.js (162 KB) and countdown.js plugin. Rewrite main.js, back-to-top.js, agenda.js in vanilla JS. Replace jQuery countdown init with inline vanilla countdown.
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
document.addEventListener("DOMContentLoaded", function () {
|
|
var tabs = Array.prototype.slice.call(
|
|
document.querySelectorAll('[role="tab"]')
|
|
);
|
|
var panels = Array.prototype.slice.call(
|
|
document.querySelectorAll('[role="tabpanel"]')
|
|
);
|
|
|
|
if (tabs.length === 0) return;
|
|
|
|
function activateTab(tab, isClick) {
|
|
tabs.forEach(function (t) {
|
|
var sel = t === tab;
|
|
t.setAttribute("aria-selected", String(sel));
|
|
var panelId = t.getAttribute("aria-controls");
|
|
var panel = document.getElementById(panelId);
|
|
if (panel) panel.setAttribute("aria-hidden", String(!sel));
|
|
});
|
|
tab.focus({ preventScroll: true });
|
|
if (isClick) {
|
|
var panelId = tab.getAttribute("aria-controls");
|
|
var panel = document.getElementById(panelId);
|
|
if (panel) {
|
|
var rect = panel.getBoundingClientRect();
|
|
window.scrollTo({
|
|
top: rect.top + window.pageYOffset - 80,
|
|
behavior: "smooth",
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
tabs.forEach(function (tab, index) {
|
|
tab.addEventListener("click", function () {
|
|
activateTab(tab, true);
|
|
});
|
|
tab.addEventListener("keydown", function (e) {
|
|
if (e.key === "ArrowRight") {
|
|
tabs[(index + 1) % tabs.length].click();
|
|
} else if (e.key === "ArrowLeft") {
|
|
tabs[(index - 1 + tabs.length) % tabs.length].click();
|
|
}
|
|
});
|
|
});
|
|
|
|
var initial = document.getElementById("tab-friday") || tabs[0];
|
|
if (initial) activateTab(initial, false);
|
|
}); |