Close all other navbar dropdowns when different one opens (fixes #59)
This commit is contained in:
18
static/details.js
Normal file
18
static/details.js
Normal file
@ -0,0 +1,18 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const nav = document.getElementById("site-nav");
|
||||
const details = nav.querySelectorAll("details");
|
||||
|
||||
details.forEach((detail) => {
|
||||
detail.addEventListener("toggle", () => {
|
||||
if (detail.open) setTargetDetail(detail);
|
||||
});
|
||||
});
|
||||
|
||||
function setTargetDetail(targetDetail) {
|
||||
details.forEach((detail) => {
|
||||
if (detail !== targetDetail) {
|
||||
detail.open = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -100,6 +100,10 @@
|
||||
{%- set scripts = scripts | concat(with=["theme-switcher.js"]) %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if config.show_theme_switcher or config.languages | length > 0 %}
|
||||
{%- set scripts = scripts | concat(with=["details.js"]) %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if config.extra.scripts %}
|
||||
{%- set scripts = scripts | concat(with=config.extra.scripts) %}
|
||||
{%- endif %}
|
||||
|
Reference in New Issue
Block a user