forked from PeerJ/paper-now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
article.js
69 lines (53 loc) · 1.66 KB
/
article.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// inline markdown
$(function() {
var md = window.markdownit();
$('[markdown]').each(function() {
this.innerHTML = md.renderInline(this.textContent);
this.removeAttribute('markdown');
})
});
// references
$(function() {
var referenceLinks = {};
var referencesList = $('#references > ul');
var references = referencesList.find('li');
references.each(function(i) {
$(this).find('a[href]').each(function() {
referenceLinks[this.href] = i;
});
});
// start from the bottom, so the reference list gets re-ordered correctly
var links = $('#main a').get().reverse();
$(links).each(function() {
if (typeof referenceLinks[this.href] == 'undefined') {
return;
}
var referenceIndex = referenceLinks[this.href];
var reference = references.eq(referenceIndex);
// move the reference to the top of the list
referencesList.prepend(reference);
$(this)/*.wrap('<sup/>')*/.popover({
trigger: 'hover',
html: true,
container: 'body',
content: function() {
return reference.html();
}
});
this.elementHeight;
});
});
// sidebar embeds
$(function() {
$('#sidebar iframe').each(function() {
var node = $(this);
var parent = node.parent();
var ratio = parent.width() / node.width();
node.css({
transform: 'scale(' + ratio + ')',
transformOrigin: 'top left'
});
parent.height(parent.height() * ratio).css('position', 'relative');
node.css('position', 'absolute');
});
});