Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP Theme: Support multiple closeable admonitions #4225

Merged
merged 1 commit into from
Jan 24, 2025
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
14 changes: 6 additions & 8 deletions pep_sphinx_extensions/pep_theme/static/sticky_banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ document.addEventListener("DOMContentLoaded", () => {

function adjustBannerMargin() {
const text = document.createTextNode(
":target { scroll-margin-top: " + stickyBanner.offsetHeight + "px; }"
`:target { scroll-margin-top: ${stickyBanner.offsetHeight}px; }`,
);
node.replaceChildren(text);
}

const closeButton = document.querySelector('.close-button');
if (closeButton) {
closeButton.addEventListener('click', () => {
const stickyBanner = document.querySelector('.sticky-banner');
if (stickyBanner) {
stickyBanner.style.display = 'none';
}
for (const closeButton of document.getElementsByClassName("close-button")) {
closeButton.addEventListener("click", () => {
// search the button's ancestors for a ``sticky-banner`` element.
const stickyBanner = closeButton.closest(".sticky-banner");
if (stickyBanner) stickyBanner.remove();
});
}

Expand Down
Loading