From 861249080ba846e6697bde0cec52c7487da039cf Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 14 Jan 2021 15:45:30 -0800 Subject: [PATCH] Moves toggle menu javascript out of html --- bookwyrm/static/js/shared.js | 7 ++++++- bookwyrm/templates/layout.html | 4 ++-- bookwyrm/templates/snippets/shelf_selector.html | 2 +- bookwyrm/templates/snippets/shelve_button.html | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index 3cb85d110..de6d44f99 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -17,6 +17,10 @@ window.onload = function() { .forEach(t => t.onclick = tabChangeNested); Array.from(document.getElementsByClassName('tab-change')) .forEach(t => t.onclick = tabChange); + + // handle aria settings on menus + Array.from(document.getElementsByClassName('pulldown-menu')) + .forEach(t => t.onclick = toggleMenu); }; function toggleAction(e) { @@ -71,7 +75,8 @@ function handleTabChange(target, parentElement) { target.className = 'is-active'; } -function toggleMenu(el) { +function toggleMenu(e) { + var el = e.target.closest('.pulldown-menu'); el.setAttribute('aria-expanded', el.getAttribute('aria-expanded') == 'false'); } diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index e625343b3..7a09f60dd 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -41,7 +41,7 @@ -