emacs.d/clones/lisp/docs.racket-lang.org/guide/figure.js

28 lines
873 B
JavaScript
Raw Normal View History

2022-08-15 11:06:56 +02:00
AddOnLoad(function () {
/* Lift figure targets to the start of the figure's blockquote,
so that clicking on a target reference shows the figure
content, instead of scrolling the figure caption to the
top of the page. */
var targets = document.getElementsByTagName("a");
for (var i = 0; i < targets.length; i++) {
var a = targets[i];
var n = a.attributes["x-target-lift"];
if (n) {
var s = n.value;
var p = a.parentNode;
while (p && (p.className != s)) {
p = p.parentNode;
}
if (p) {
var cs = p.children;
a.parentNode.removeChild(a);
if (cs.length > 0)
p.insertBefore(a, cs[0]);
else
p.appendChild(a);
}
}
}
});