/* The logo button in the top bar. Dr. KC presses it mid-pitch to establish NEUON's credentials, so it has to work from any scroll position on any page, and close again without losing his place. */ (function () { var btn = document.getElementById('brandBtn'); var panel = document.getElementById('certPanel'); if (!btn || !panel) return; var closeBtn = document.getElementById('certClose'); var lastFocus = null; /* The logo disc is not at the centre of the viewport — the pill carries a search button on one side and none on the other. So the circle and its radar waves are anchored to where the disc actually is, measured live. */ function anchor() { // measure the blue circle itself, not the button box — the circle hangs // below the bar, so the two have different centres var target = btn.querySelector('.nav__disc') || btn; var r = target.getBoundingClientRect(); panel.style.setProperty('--cert-x', (r.left + r.width / 2) + 'px'); panel.style.setProperty('--cert-y', (r.top + r.height / 2) + 'px'); } function open() { lastFocus = document.activeElement; btn.setAttribute('aria-expanded', 'true'); btn.classList.add('is-open'); // locking the body removes the scrollbar, which widens the page and shifts // the centred nav — so lock FIRST, then measure where the disc ended up document.body.style.overflow = 'hidden'; anchor(); panel.hidden = false; if (closeBtn) closeBtn.focus(); } function close() { panel.hidden = true; btn.setAttribute('aria-expanded', 'false'); btn.classList.remove('is-open'); document.body.style.overflow = ''; if (lastFocus) lastFocus.focus(); } btn.addEventListener('click', function () { panel.hidden ? open() : close(); }); /* THE OTHER WAY IN. "See our certifications" at the foot of Our Commitment names exactly what is behind the logo, and used to send people to another page to look for it. It opens the circle instead, where they are. */ document.querySelectorAll('[data-certdoor]').forEach(function (a) { a.addEventListener('click', function (e) { e.preventDefault(); if (panel.hidden) open(); }); }); if (closeBtn) closeBtn.addEventListener('click', close); /* A LINK OUT OF THE DOME CLOSES THE DOME. "About Us" leaves for the founders and the page reloads, so this changes nothing there — but `open()` locked `body { overflow:hidden }`, and any link that turns out NOT to navigate (a same-page hash, a blocked navigation, the visitor coming back to a restored page) would otherwise leave the screen covered and the body locked, with no way out but Escape. Closing first costs nothing. The scrolling is not ours to do: anchor.js handles the one case the browser cannot, which is a hash pressed with no page load. Arriving from here there IS a page load, so the browser lands it by itself. */ panel.querySelectorAll('a[href]').forEach(function (a) { a.addEventListener('click', close); }); // click the dimmed backdrop, not the circle itself panel.addEventListener('click', function (e) { if (e.target === panel || e.target.classList.contains('certwrap__scrim')) close(); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && !panel.hidden) close(); }); addEventListener('resize', function () { if (!panel.hidden) anchor(); }); /* The credentials ring keeps turning on its own. Clicking a logo brings that one to the centre and holds it there, so Dr. KC can park on a certificate while he talks about it; clicking it again lets the ring go. */ var ring = document.getElementById('orbitCert'); if (ring) { var held = null; ring.querySelectorAll('.orbit__node').forEach(function (node) { node.addEventListener('click', function (e) { var orbit = ring._orbit; if (!orbit) return; // a logo with a real link should still follow it when it is centred if (node.classList.contains('is-front') && e.target.closest('a')) return; e.preventDefault(); if (held === node) { // second click — release it node.classList.remove('is-held'); orbit.unpin(); held = null; return; } if (held) { held.classList.remove('is-held'); orbit.unpin(); } orbit.bringToFront(orbit.nodes.indexOf(node)); orbit.pin(); node.classList.add('is-held'); held = node; }); }); // closing the dome lets the ring go again panel.addEventListener('click', function (e) { if ((e.target === panel || e.target.classList.contains('certwrap__scrim')) && held) { held.classList.remove('is-held'); if (ring._orbit) ring._orbit.unpin(); held = null; } }); } })();