Files
archived-hipudding-teslamate/assets/js/main.js
2020-12-29 20:32:20 +01:00

35 lines
1.1 KiB
JavaScript

document.querySelector(".navbar-burger").addEventListener("click", function () {
const $target = document.getElementById(this.dataset.target);
$target.classList.toggle("is-active");
this.classList.toggle("is-active");
});
for (const navDropdown of document.querySelectorAll(
".navbar-item.has-dropdown"
)) {
navDropdown.addEventListener("click", function () {
if (document.querySelector(".navbar-menu.is-active")) {
this.classList.toggle("active");
}
});
}
// Open Statistics dashboard with the browser time zone
const statistics = document.querySelector("a[data-uid='1EZnXszMk']");
const tz = Intl && Intl.DateTimeFormat().resolvedOptions().timeZone;
if (statistics && tz)
statistics.href = `${statistics.href}?var-timezone=${decodeURIComponent(tz)}`;
// Fix sticky hover on iOS
document.addEventListener("click", () => 0);
// Address dynamic viewport units on mobile
function setCustomVh() {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
}
window.addEventListener("resize", setCustomVh);
setCustomVh();