diff --git a/web/static/js/bulma.js b/web/static/js/bulma.js index 5558eeb..bd2d65a 100644 --- a/web/static/js/bulma.js +++ b/web/static/js/bulma.js @@ -1,4 +1,4 @@ -// Hamburger menu script for mobile. +// Bulma CSS fixes and features for nonshy. document.addEventListener('DOMContentLoaded', () => { // Make all off-site hyperlinks open in a new tab. @@ -84,6 +84,19 @@ document.addEventListener('DOMContentLoaded', () => { // Dropdown menus. (document.querySelectorAll(".dropdown") || []).forEach(node => { + // If this dropdown is near the bottom of the page, make it open upwards. + if (!node.classList.contains("is-up") && !node.classList.contains("is-right")) { + let offsetTop = node.offsetTop, + body = document.body, + html = document.documentElement, + pageHeight = Math.max(body.scrollHeight, body.offsetHeight, + html.clientHeight, html.scrollHeight, html.offsetHeight, + ); + if (pageHeight - offsetTop < 450) { + node.classList.add("is-up"); + } + } + const button = node.querySelector("button"); button.addEventListener("click", (e) => { node.classList.toggle("is-active");