diff options
Diffstat (limited to 'lib/scripts/page.js')
-rw-r--r-- | lib/scripts/page.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/scripts/page.js b/lib/scripts/page.js index a179ae2a8..aadff8ecf 100644 --- a/lib/scripts/page.js +++ b/lib/scripts/page.js @@ -83,23 +83,26 @@ dw_page = { * * @author Andreas Gohr <andi@splitbrain.org> * @author Chris Smith <chris@jalakai.co.uk> + * @author Anika Henke <anika@selfthinker.org> */ footnoteDisplay: function () { - var content = jQuery(jQuery(this).attr('href')) // Footnote text anchor - .closest('div.fn').html(); + var $content = jQuery(jQuery(this).attr('href')) // Footnote text anchor + .parent().siblings('.content').clone(); - if (content === null){ + if (!$content) { return; } - // strip the leading content anchors and their comma separators - content = content.replace(/((^|\s*,\s*)<sup>.*?<\/sup>)+\s*/gi, ''); - // prefix ids on any elements with "insitu__" to ensure they remain unique - content = content.replace(/\bid=(['"])([^"']+)\1/gi,'id="insitu__$2'); + jQuery('[id]', $content).each(function(){ + var id = jQuery(this).attr('id'); + jQuery(this).attr('id', 'insitu__' + id); + }); + var content = $content.html().trim(); // now put the content into the wrapper - dw_page.insituPopup(this, 'insitu__fn').html(content).show().attr('aria-hidden', 'false'); + dw_page.insituPopup(this, 'insitu__fn').html(content) + .show().attr('aria-hidden', 'false'); }, /** |