| 1 |
|
| 2 |
$(document).ready(function() { |
| 3 |
|
| 4 |
var $b = $('body'), |
| 5 |
$h = $('#header'), |
| 6 |
panderUrl = 'https://rapporter.github.io/pander/'; |
| 7 |
|
| 8 |
|
| 9 |
var $container = $('<div/>', { |
| 10 |
class: "container" |
| 11 |
}).prependTo($b); |
| 12 |
|
| 13 |
|
| 14 |
var $sidebar = $('<div/>', { |
| 15 |
class: 'three columns sidebar' |
| 16 |
}).appendTo($container); |
| 17 |
|
| 18 |
|
| 19 |
var $content = $('<div/>', { |
| 20 |
class: 'twelve columns content offset-by-three content' |
| 21 |
}).appendTo($container); |
| 22 |
|
| 23 |
|
| 24 |
$b.children().not($container).appendTo($content); |
| 25 |
|
| 26 |
var $nav = $('<nav/>').prependTo($sidebar); |
| 27 |
|
| 28 |
|
| 29 |
var $logo = $('<div/>', { |
| 30 |
id: 'logo', |
| 31 |
html: $('<a/>', { |
| 32 |
href: panderUrl, |
| 33 |
target: '_blank', |
| 34 |
text: 'Table of Contents' |
| 35 |
}) |
| 36 |
}).prependTo($nav); |
| 37 |
|
| 38 |
|
| 39 |
var $ul = $('<ul/>').appendTo($nav); |
| 40 |
var $header = $('<header/>').prependTo($content); |
| 41 |
|
| 42 |
$h.children().appendTo('header'); |
| 43 |
$h.remove(); |
| 44 |
|
| 45 |
$header.after('<hr class="large" />'); |
| 46 |
|
| 47 |
|
| 48 |
var $head = $content.children().not('header').filter(':header').not('.exclude_from_toc'); |
| 49 |
|
| 50 |
$head.each(function(i, val){ |
| 51 |
|
| 52 |
var linkId = val.id, |
| 53 |
$val = $(val); |
| 54 |
|
| 55 |
|
| 56 |
$('<a/>', { |
| 57 |
id: linkId |
| 58 |
}).insertBefore($val); |
| 59 |
|
| 60 |
|
| 61 |
$('<li/>', { |
| 62 |
class: 'nnav-' + (parseInt($val.get(0).nodeName.replace('H', '')) + 1), |
| 63 |
html: $('<a>').attr({ href: '#' + linkId}).text($val.text()) |
| 64 |
}).appendTo('nav > ul'); |
| 65 |
}); |
| 66 |
|
| 67 |
|
| 68 |
$content.find('table').wrap('<div class="table-container" />'); |
| 69 |
|
| 70 |
$content.find('span.math').parent().wrap('<div class="math-container" />'); |
| 71 |
|
| 72 |
|
| 73 |
$('img[alt]').jcaption(); |
| 74 |
|
| 75 |
|
| 76 |
$('img').each(function() {$(this).attr('title', $(this).attr('alt'))}); |
| 77 |
|
| 78 |
|
| 79 |
$('.content a > img:not([alt])').addClass('image_without_caption'); |
| 80 |
$('img').closest('p').css('text-align', 'center'); |
| 81 |
|
| 82 |
|
| 83 |
$('.content a > img:not([alt])').slimbox({ |
| 84 |
counterText: "Plot: {x} of {y}" |
| 85 |
}, function(el) { |
| 86 |
return [el.parentNode.href, el.title]; |
| 87 |
}); |
| 88 |
|
| 89 |
}); |
| 90 |
|
| 91 |
$(window).load(function() { |
| 92 |
|
| 93 |
|
| 94 |
$('.content a > div.caption').each(function() {$(this).attr('title', $(this).children(':first-child').attr('alt'))}); |
| 95 |
|
| 96 |
|
| 97 |
$('.content a > div.caption').slimbox({ |
| 98 |
counterText: "Plot: {x} of {y}" |
| 99 |
}, function(el) { |
| 100 |
return [el.parentNode.href, el.title]; |
| 101 |
}); |
| 102 |
|
| 103 |
}); |