js: add class to keep track of details opening status (#83376)

This commit is contained in:
Frédéric Péters 2023-11-12 13:08:15 +01:00
parent 9dd8021f68
commit 7578b0a0cf
1 changed files with 9 additions and 0 deletions

View File

@ -481,6 +481,15 @@ var gadjo_js = gadjo_js || {};
sessionStorage['gadjo-foldable-id-' + $parent[0].id + '-' + window.location.pathname] = ! $parent.is('.gadjo-folded');
}
});
document.querySelectorAll('details.gadjo-remember-open-status').forEach(
el => {
const key = 'gadjo-foldable-id-' + el.id + '-' + window.location.pathname
if (sessionStorage[key] !== undefined) el.open = (sessionStorage[key] === "true")
el.addEventListener('toggle', (e) => sessionStorage[key] = el.open)
}
)
});
$(function () { /* foldable sections */
$('.section.foldable > h2, .section.foldable > h3').on('click', function() {