summaryrefslogtreecommitdiff
path: root/help3xsl
diff options
context:
space:
mode:
authorIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2021-11-04 19:35:08 +0200
committerOlivier Hallot <olivier.hallot@libreoffice.org>2021-11-05 23:38:35 +0100
commitea8bee81962bf4a1fa053578c3a21cf55715d483 (patch)
tree8f0de4d032a62fe5a96958d86463a91377ae31db /help3xsl
parent03457ee108d22cf4eabf657de3c67968c8f93f36 (diff)
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 <ross.johnson@homemail.com.au> Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'help3xsl')
-rw-r--r--help3xsl/help.js11
1 files changed, 11 insertions, 0 deletions
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: */