help3xsl/help.js | 11 +++++++++++
1 file changed, 11 insertions(+)
New commits:
commit ea8bee81962bf4a1fa053578c3a21cf55715d483
Author: Ilmari Lauhakangas <[email protected]>
AuthorDate: Thu Nov 4 19:35:08 2021 +0200
Commit: Olivier Hallot <[email protected]>
CommitDate: Fri Nov 5 23:38:35 2021 +0100
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 <[email protected]>
Reviewed-by: Olivier Hallot <[email protected]>
diff --git a/help3xsl/help.js b/help3xsl/help.js
index c67581d7b..6adbf2e17 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: */