Debian Codegraph @

inst/includes/javascripts/custom.js

raw symbols SCIP
1 // creating nav bar and restructuring document
2 $(document).ready(function() {
3
4 var $b = $('body'),
5 $h = $('#header'),
6 panderUrl = 'https://rapporter.github.io/pander/';
7
8 // add container div
9 var $container = $('<div/>', {
10 class: "container"
11 }).prependTo($b);
12
13 // add sidebar
14 var $sidebar = $('<div/>', {
15 class: 'three columns sidebar'
16 }).appendTo($container);
17
18 // add content div
19 var $content = $('<div/>', {
20 class: 'twelve columns content offset-by-three content'
21 }).appendTo($container);
22
23 // all but container -> goto content div
24 $b.children().not($container).appendTo($content);
25
26 var $nav = $('<nav/>').prependTo($sidebar); // add nav to sidebar
27
28 // add logo div
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 // add ul for sidebar menu
39 var $ul = $('<ul/>').appendTo($nav);
40 var $header = $('<header/>').prependTo($content); // add header to content div
41 // move #header contents to header and remove element
42 $h.children().appendTo('header');
43 $h.remove();
44
45 $header.after('<hr class="large" />');
46
47 // get all headings
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 // insert anchor links before headings
56 $('<a/>', {
57 id: linkId
58 }).insertBefore($val);
59
60 // insert navigation items
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 // wrap each table in a container div
68 $content.find('table').wrap('<div class="table-container" />');
69 // add math container
70 $content.find('span.math').parent().wrap('<div class="math-container" />');
71
72 // handling img captions
73 $('img[alt]').jcaption();
74
75 // add title tags to imgs
76 $('img').each(function() {$(this).attr('title', $(this).attr('alt'))});
77
78 // add border to imgs without caption and center
79 $('.content a > img:not([alt])').addClass('image_without_caption');
80 $('img').closest('p').css('text-align', 'center');
81
82 // slimbox2
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 // add title tags to imgs
94 $('.content a > div.caption').each(function() {$(this).attr('title', $(this).children(':first-child').attr('alt'))});
95
96 // slimbox2
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 });