From 69f85cbf17c5acb8fb9b38772139c34eea96a772 Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Wed, 25 Oct 2023 18:20:13 +0300 Subject: Improve accessibility of dropdown menus Now the opened menus can be closed with Esc key, so we conform to the dismissible success criterion in WCAG 2.1: https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus.html To simplify things, now the navigation lists are populated upon page load in all cases. Change-Id: I0a7daaea122d3e03de36c322ccb012c546b271e0 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/158429 Tested-by: Jenkins Reviewed-by: Olivier Hallot --- help3xsl/help2.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'help3xsl/help2.js') diff --git a/help3xsl/help2.js b/help3xsl/help2.js index df11cb5210..684136245d 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -175,7 +175,7 @@ function existingLang(lang) { function setupModules(lang) { var modulesNav = document.getElementById('modules-nav'); if (!modulesNav.classList.contains('loaded')) { - var html = + let html = '
%PRODUCTNAME
' + '
Writer
' + '
Calc
' + @@ -190,10 +190,12 @@ function setupModules(lang) { } } -function setupLanguages(page) { - var langNav = document.getElementById('langs-nav'); +function setupLanguages(url) { + let langNav = document.getElementById('langs-nav'); + if (!langNav) return; + let page = url.substring(url.search('/text/')); if (!langNav.classList.contains('loaded')) { - var html = ''; + let html = ''; languagesSet.forEach(function(lang) { html += '' + ((lang in languageNames)? languageNames[lang]: lang) + ''; }); @@ -240,18 +242,19 @@ if(missingElement != null){missingElement.innerHTML = helpID;} debugInfo(getParameterByName("Debug")); -// Mobile devices need the modules and langs on page load +// Mobile devices need the modules and langs displayed on page load if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 960) { - let e = new Event('click'); - let modulesBtn = document.getElementById('modules'); - let langsBtn = document.getElementById('langs'); let modules = document.getElementById('modules-nav'); let langs = document.getElementById('langs-nav'); - modules.setAttribute('data-a11y-toggle-open', ''); - modulesBtn.dispatchEvent(e); + modules.removeAttribute('hidden'); if (langs) { - langs.setAttribute('data-a11y-toggle-open', ''); - langsBtn.dispatchEvent(e); + langs.removeAttribute('hidden'); } } + +const href = window.location.href; +const lang = existingLang(getParameterByName("Language", href) || navigator.language); +setupModules(lang); +setupLanguages(href); + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit