kubenix/docs/layouts/partials/docs/inject/body.html
2022-08-28 15:22:43 -04:00

24 lines
No EOL
819 B
HTML

<script>
window.onload = function(){
// open details of option in URL fragment
document.getElementById(decodeURI(window.location.hash.substring(1)))?.setAttribute("open", "");
var options = document.getElementsByTagName('details');
for(var i = 0; i < options.length; i++) {
options[i].getElementsByTagName("summary")[0].onclick = function() {
// set URL fragment to option id
window.location.hash = this.parentElement.id;
// is current panel open, return immediately as it's just being closed
if (this.parentElement.hasAttribute("open")) return;
// collapse all other options
for(var j = 0; j < options.length; j++) {
options[j].removeAttribute("open");
}
};
}
};
</script>