-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.markdownFootnotes.js
50 lines (42 loc) · 1.51 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$(function() {
// To edit the display of the footnote
var footnoteContentCSS = {
'background': '#000',
'opacity': '.9',
'color': '#fff',
'-webkit-box-shadow': '0px 0px 5px #000',
'-moz-box-shadow': '0px 0px 5px #000'
}
// To edit the display of the link that closes the footnote
var closeFootnoteCSS = {
'text-transform': 'uppercase',
'text-decoration': 'none',
'font-size': '9px',
'float': 'right',
'color': '#666',
'font-family': 'Helvetica, sans-serif'
}
$("a[rel=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" style="display: none; position: fixed; bottom: 0; left: 50%; padding: 2%; width: 80%; margin-left: -42%;">' + 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').prepend('<a href="#" class="closeFootnote">Close</a>').css(footnoteContentCSS);
$('.closeFootnote').click(function(){
$(this).closest('.footnoteContent').slideUp('fast');
return false;
}).css(closeFootnoteCSS);
});