forked from sumeetjain/jquery-markdown-footnotes
-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.markdownFootnotes.js
36 lines (28 loc) · 1.22 KB
/
jquery.markdownFootnotes.js
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
28
29
30
31
32
33
34
35
36
$(function() {
// Different implementations of Markdown do footnotes in different ways. The default in this file is for MultiMarkdown. If it doesn't work, try using the commented lines instead of the line directly below each instance.
// $("a[rel=footnote]").each(function(){
$("a[class=footnote]").each(function(){
var link = $(this);
var token = link.attr('href').substr(1);
var footnoteContent = $(document.getElementById(token)).html();
$('body').append('<div id="overlay-' + token + '" class="footnoteContent">' + footnoteContent + '</div>');
link.click(function(){
var $currentFootnote = $(document.getElementById('overlay-' + token));
// If the footnote is already displayed, hide it instead
if ($currentFootnote.is(':visible')) {
$currentFootnote.slideUp('fast');
} else {
$('.footnoteContent').hide();
$currentFootnote.slideDown('fast');
}
return false;
});
});
// $('.footnoteContent a[rev=footnote]').remove();
$('.footnoteContent a[class=reversefootnote]').remove();
$('.footnoteContent').prepend('<a href="#" class="closeFootnote">×</a>');
$('.closeFootnote').click(function(){
$(this).closest('.footnoteContent').slideUp('fast');
return false;
});
});