Deploy
This commit is contained in:
1 parent
8bbcf8ecd9
commit
45dd65b48e
116 files changed
+20457
-1164
No files matched your search
@@ -0,0 +1,70 @@
|
||||
// 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(); }
|
||||
})();
|
||||
Reference in new issue
Block a user