$(document).ready(function() {
// Use attr() to add an id, rel, and title.
$('div.chapter a[href*="wikipedia"]').attr({
rel: 'external',
title: function() {
return 'Learn more about ' + $(this).text() + ' at Wikipedia.';
},
id: function(index, oldValue) {
return 'wikilink-' + index;
}
});
// Add "back to top" links.
$('back to top').insertAfter('div.chapter p');
$('').prependTo('body');
// Create footnotes.
var $notes = $('
').insertBefore('#footer');
$('span.footnote').each(function(index) {
$(this)
.before([
'',
'',
index + 1,
''
].join(''))
.appendTo($notes)
.append([
' (context)'
].join(''))
.wrap('');
});
// Style pull quotes.
$('span.pull-quote').each(function(index) {
var $parentParagraph = $(this).parent('p');
$parentParagraph.css('position', 'relative');
var $clonedCopy = $(this).clone();
$clonedCopy
.addClass('pulled')
.find('span.drop')
.html('…')
.end()
.text($clonedCopy.text())
.prependTo($parentParagraph);
});
});