From ea8bee81962bf4a1fa053578c3a21cf55715d483 Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Thu, 4 Nov 2021 19:35:08 +0200 Subject: Close navigation menus when clicking outside them Change-Id: I6d567d7978ed5997b4ca9bf865e9e54d6c67a3a0 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/124718 Tested-by: Jenkins Reviewed-by: Ross Johnson Reviewed-by: Olivier Hallot --- help3xsl/help.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/help3xsl/help.js b/help3xsl/help.js index c67581d7bf..6adbf2e17a 100644 --- a/help3xsl/help.js +++ b/help3xsl/help.js @@ -233,4 +233,15 @@ if (typeof linkIndex !== "undefined") { } current.classList.add('contents-current'); } +// close navigation menus when clicking anywhere on the page +// (ignoring menu button clicks and mobile browsing) +document.addEventListener('click', function(event) { + let a11yButton = event.target.getAttribute("data-a11y-toggle"); + let vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); + if (!a11yButton && vw >= 960) { + document.querySelectorAll("[data-a11y-toggle] + nav").forEach((el) => { + el.setAttribute("aria-hidden", true); + }); + } +}); /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit