- theme.scss and figures draw with the extension's --calc-… tokens; light/dark pair plus the high-contrast button; a11y highlight style for html - figure labels split so none leaves its viewBox in any language - _quarto-fr.yml: French cross-reference prefixes - notes extension synced to 2.8.18 - conv/: Parts IV, V and VI logged, pasted terminal output redacted Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
71 lines
2.6 KiB
JavaScript
71 lines
2.6 KiB
JavaScript
// calc-notes — open every note before printing, restore afterwards
|
|
(function () {
|
|
window.addEventListener("beforeprint", function () {
|
|
document.querySelectorAll("details.calc-note").forEach(function (d) {
|
|
d.dataset.calcWasOpen = d.open ? "1" : "0";
|
|
d.open = true;
|
|
});
|
|
});
|
|
window.addEventListener("afterprint", function () {
|
|
document.querySelectorAll("details.calc-note").forEach(function (d) {
|
|
d.open = d.dataset.calcWasOpen === "1";
|
|
delete d.dataset.calcWasOpen;
|
|
});
|
|
});
|
|
})();
|
|
|
|
// --- high contrast: a switch of its own, beside Quarto's light/dark one ----
|
|
// The class is already set before the first paint by the script calc-notes.lua
|
|
// puts in the head; this only builds the control and remembers a choice.
|
|
// Precedence: what the reader picked here, then `high-contrast: true` in the
|
|
// book, then the reader's system setting.
|
|
(function () {
|
|
var KEY = "notes-contrast";
|
|
var root = document.documentElement;
|
|
|
|
var LABELS = {
|
|
de: { on: "Hoher Kontrast aus", off: "Hoher Kontrast ein" },
|
|
fr: { on: "Désactiver le contraste élevé", off: "Activer le contraste élevé" },
|
|
en: { on: "Turn high contrast off", off: "Turn high contrast on" }
|
|
};
|
|
var lang = (root.lang || "en").slice(0, 2).toLowerCase();
|
|
var L = LABELS[lang] || LABELS.en;
|
|
|
|
function store(v) {
|
|
try { localStorage.setItem(KEY, v ? "more" : "normal"); } catch (e) {}
|
|
}
|
|
|
|
function paint() {
|
|
var on = root.classList.contains("hc");
|
|
document.querySelectorAll(".notes-contrast-toggle").forEach(function (b) {
|
|
b.setAttribute("aria-pressed", String(on));
|
|
b.setAttribute("title", on ? L.on : L.off);
|
|
b.setAttribute("aria-label", on ? L.on : L.off);
|
|
});
|
|
}
|
|
|
|
function build() {
|
|
var anchors = document.querySelectorAll(".quarto-color-scheme-toggle");
|
|
if (anchors.length === 0) return; // a page without Quarto's own tools
|
|
anchors.forEach(function (a) {
|
|
var b = document.createElement("button");
|
|
b.type = "button";
|
|
b.className = "quarto-navigation-tool px-1 notes-contrast-toggle";
|
|
// bootstrap-icons ships with these books; the glyph is the fallback
|
|
b.innerHTML = '<i class="bi bi-circle-half" aria-hidden="true"></i>';
|
|
b.addEventListener("click", function () {
|
|
var on = !root.classList.contains("hc");
|
|
root.classList.toggle("hc", on);
|
|
store(on);
|
|
paint();
|
|
});
|
|
a.parentNode.insertBefore(b, a.nextSibling);
|
|
});
|
|
paint();
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", build);
|
|
} else { build(); }
|
|
})();
|