MediaWiki:Common.js
From The Radical Buddhism Project
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* =====================================================================
FOOTNOTE POPUPS
===================================================================== */
$(function() {
$('.reference').each(function() {
var $refLink = $(this);
var targetId = $refLink.find('a').attr('href');
if (targetId && targetId.indexOf('#') === 0) {
var $footnoteElement = $(decodeURIComponent(targetId));
if ($footnoteElement.length) {
// Extracts the raw text content of the citation, stripping the default backlink arrow
var footnoteText = $footnoteElement.find('.mw-reference-text').html() || $footnoteElement.text();
// Construct the floating tip container box
var $popup = $('<div class="custom-ref-popup"></div>').html(footnoteText).hide().appendTo('body');
$refLink.hover(
function(e) {
$popup.css({
top: (e.pageY + 15) + 'px',
left: Math.min(e.pageX + 10, $(window).width() - 320) + 'px'
}).fadeIn(100);
},
function() {
$popup.fadeOut(100);
}
);
// Track mouse movement for smooth baseline hover positioning
$refLink.mousemove(function(e) {
$popup.css({
top: (e.pageY + 15) + 'px',
left: Math.min(e.pageX + 10, $(window).width() - 320) + 'px'
});
});
}
}
});
});
