blob: 146ab58e9b79da5a2d07e1c2ab730573bbf48a26 (
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
|
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);
});
}
});
|