blob: e3b844a2a073aa01566a1acc66e7238b617ff1a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
document.addEventListener('DOMContentLoaded', function () {
// 'Back to top' logic
const intersectionObserver = new IntersectionObserver(function(entries) {
const topBtn = document.querySelector('.top-of-site-link');
if (topBtn === null) return;
topBtn.dataset.visible = entries[0].boundingClientRect.y < 0;
});
const topAnchor = document.querySelector('#top-of-site-anchor');
if (topAnchor !== null) {
intersectionObserver.observe(topAnchor);
}
// Annotation support
const hypothesisContainer = document.querySelector('.hypothesis-container');
if (hypothesisContainer !== null) {
hypothesisContainer.addEventListener('click', (e) => {
e.preventDefault();
let script = document.createElement('script');
script.setAttribute('src', 'https://cdn.hypothes.is/hypothesis');
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
});
}
const hypothesisLink = document.querySelector('#hypothesis-link');
if (hypothesisLink !== null) {
hypothesisContainer.addEventListener('click', (e) => {
e.preventDefault();
});
}
});
|