PointsOfOrder/_static/custom.js

27 lines
881 B
JavaScript

function initFootnotes() {
var elPreview = document.getElementById('footnote-preview');
function mouseoverFootnote(evt) {
var fnText = document.querySelector(evt.target.getAttribute('href') + ' p').innerHTML;
elPreview.innerHTML = fnText;
elPreview.style.display = 'block';
elPreview.style.top = (evt.target.getBoundingClientRect().top + 16) + 'px';
elPreview.style.left = evt.target.getBoundingClientRect().left + 'px';
}
function mouseoutFootnote(evt) {
elPreview.style.display = 'none';
}
document.querySelectorAll('a.footnote-reference').forEach(function(el) {
el.addEventListener('mouseenter', mouseoverFootnote);
el.addEventListener('mouseleave', mouseoutFootnote);
});
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
initFootnotes();
} else {
document.addEventListener('DOMContentLoaded', initFootnotes);
}