Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions layouts/partials/hooks/body-end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- /* Overrides themes/docsy/layouts/partials/hooks/body-end.html, called at the end
of the theme's scripts.html — which every one of our baseof templates loads.
The theme's own body-end only carries the Algolia docsearch placeholder, kept
verbatim below so overriding it loses nothing. */ -}}
{{ with .Site.Params.algolia_docsearch }}
<!-- scripts for algolia docsearch -->
{{ end }}

{{- /* Dismiss floating <details> dropdowns.

A native <details> stays open until its own summary is clicked again, so
clicking anywhere else left the panel hanging over the page. Close them on an
outside click and on Escape, and let opening one close the others so only a
single panel is ever up.

Scoped to the floating dropdowns by class. .dl-archived is deliberately not in
the list: it is an inline accordion rather than a floating panel, and should
stay where the reader put it. */ -}}
<script>
(function () {
var SEL = 'details.docs-ver, details.dl-more, details.topic-filter';

function closeAll(except) {
document.querySelectorAll(SEL).forEach(function (d) {
if (d !== except && d.open) { d.open = false; }
});
}

// Click: a click inside a dropdown keeps that one open and closes the rest;
// a click anywhere else closes all of them.
document.addEventListener('click', function (e) {
var target = e.target instanceof Element ? e.target.closest(SEL) : null;
closeAll(target);
});

document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' || e.key === 'Esc') { closeAll(null); }
});
})();
</script>