mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
8a4639bc43
commit
2f7731e9e5
10 changed files with 166 additions and 14 deletions
|
|
@ -60,19 +60,19 @@
|
|||
<footer class="ft">{% block footer %}{% include "_footer.html" %}{% endblock %}</footer>
|
||||
|
||||
<script>
|
||||
var menuDetails = document.querySelector('.nav-menu');
|
||||
document.body.addEventListener('click', (ev) => {
|
||||
/* was this click outside the menu? */
|
||||
if (menuDetails.getAttribute('open') !== "") {
|
||||
return;
|
||||
}
|
||||
/* Close any open details elements that this click is outside of */
|
||||
var target = ev.target;
|
||||
while (target && target != menuDetails) {
|
||||
var detailsClickedWithin = null;
|
||||
while (target && target.tagName != 'DETAILS') {
|
||||
target = target.parentNode;
|
||||
}
|
||||
if (!target) {
|
||||
menuDetails.removeAttribute('open');
|
||||
if (target && target.tagName == 'DETAILS') {
|
||||
detailsClickedWithin = target;
|
||||
}
|
||||
Array.from(document.getElementsByTagName('details')).filter(
|
||||
(details) => details.open && details != detailsClickedWithin
|
||||
).forEach(details => details.open = false);
|
||||
});
|
||||
</script>
|
||||
{% for body_script in body_scripts %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue