diff --git a/_static/custom.js b/_static/custom.js new file mode 100644 index 0000000..f07c392 --- /dev/null +++ b/_static/custom.js @@ -0,0 +1,26 @@ +function initFootnotes() { + var elPreview = document.getElementById('footnote-preview'); + + function mouseoverFootnote(evt) { + var fnText = document.querySelector(evt.target.getAttribute('href')).nextElementSibling.children[0].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); +} diff --git a/_static/custom_html.css b/_static/custom_html.css index 222a55e..119d3cc 100644 --- a/_static/custom_html.css +++ b/_static/custom_html.css @@ -75,6 +75,17 @@ dl.footnote dt:hover span.fn-backref { display: inline; } +#footnote-preview { + position: fixed; + display: none; + color: #3E4349; + background-color: white; + z-index: 999; + border: 1px solid #999; + border-radius: 4px; + padding: 2px; +} + /* Sidebar */ div.sphinxsidebarwrapper p.caption { diff --git a/conf.py b/conf.py index ec4ae24..ef2c42e 100644 --- a/conf.py +++ b/conf.py @@ -67,6 +67,7 @@ html_sidebars = {'*': ['about.html', 'navigation.html', 'searchbox.html']} html_static_path = ['_static'] html_css_files = ['custom_html.css'] # custom.css automatically included by alabaster +html_js_files = ['custom.js'] html_extra_path = ['epub-cover.xhtml', 'epub-copyright.xhtml'] @@ -98,4 +99,4 @@ epub_cover = ('_static/cover.jpg', '') epub_pre_files = [('epub-cover.xhtml', ''), ('epub-copyright.xhtml', '')] epub_css_files = ['custom.css', 'custom_epub.css'] epub_show_urls = 'no' -epub_exclude_files = ['_static/file.png', '_static/minus.png', '_static/plus.png', '_static/custom_html.css'] +epub_exclude_files = ['_static/file.png', '_static/minus.png', '_static/plus.png', '_static/custom_html.css', '_static/custom.js'] diff --git a/potheme_html/layout.html b/potheme_html/layout.html index 0ebd7a7..cd380d2 100644 --- a/potheme_html/layout.html +++ b/potheme_html/layout.html @@ -5,6 +5,8 @@
{# Fix interaction with floating .sphinxsidebar #} +
+