|
1 | | -$(function() { |
2 | | - // build side menu |
3 | | - var html = ''; |
4 | | - |
5 | | - $('.bs-docs-section').each(function() { |
6 | | - var h1 = $(this).find('h1[id]').first(), |
7 | | - h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])'); |
8 | | - |
9 | | - if (h1.length) { |
10 | | - html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>'; |
11 | | - |
12 | | - if (h23.length) { |
13 | | - html += '<ul class="nav">'; |
14 | | - h23.each(function() { |
15 | | - html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>'; |
16 | | - }); |
17 | | - html += '</ul>'; |
| 1 | +var jekyllBootstrapDoc = { |
| 2 | + buildSideMenu: function() { |
| 3 | + var html = ''; |
| 4 | + |
| 5 | + $('.bs-docs-section').each(function() { |
| 6 | + var h1 = $(this).find('h1[id]').first(), |
| 7 | + h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])'); |
| 8 | + |
| 9 | + if (h1.length) { |
| 10 | + html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>'; |
| 11 | + |
| 12 | + if (h23.length) { |
| 13 | + html += '<ul class="nav">'; |
| 14 | + h23.each(function() { |
| 15 | + html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>'; |
| 16 | + }); |
| 17 | + html += '</ul>'; |
| 18 | + } |
| 19 | + |
| 20 | + html += '</li>'; |
18 | 21 | } |
| 22 | + }); |
19 | 23 |
|
20 | | - html += '</li>'; |
| 24 | + if (html == '') { |
| 25 | + $('[role=complementary]').hide(); |
| 26 | + $('[role=main]').removeClass('col-md-9').addClass('col-md-12'); |
| 27 | + } |
| 28 | + else { |
| 29 | + $('[role=complementary]').show(); |
| 30 | + $('[role=main]').removeClass('col-md-12').addClass('col-md-9'); |
| 31 | + $('.bs-docs-sidenav').html(html); |
21 | 32 | } |
22 | | - }); |
| 33 | + }, |
23 | 34 |
|
24 | | - if (html == '') { |
25 | | - $('[role=complementary]').hide(); |
26 | | - $('[role=main]').toggleClass('col-md-9 col-md-12'); |
27 | | - } |
28 | | - else { |
29 | | - $('.bs-docs-sidenav').html(html); |
30 | | - } |
| 35 | + addHeadingAnchors: function() { |
| 36 | + $('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() { |
| 37 | + if ($(this).children('.anchor-link').length === 0) { |
| 38 | + $(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>'); |
| 39 | + } |
| 40 | + }); |
| 41 | + }, |
31 | 42 |
|
32 | | - // add heading anchors |
33 | | - $('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() { |
34 | | - $(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>'); |
35 | | - }); |
36 | | - |
37 | | - // enable bootbox |
38 | | - $('[data-bootbox]').on('click', function() { |
39 | | - var $target = $('#' + $(this).data('bootbox')); |
40 | | - bootbox.alert({ |
41 | | - title: $target.attr('title'), |
42 | | - message: $target.html(), |
43 | | - size: $(this).data('bootbox-size') |
| 43 | + enableBootbox: function() { |
| 44 | + $('[data-bootbox]').off('click').on('click', function() { |
| 45 | + var $target = $('#' + $(this).data('bootbox')); |
| 46 | + bootbox.alert({ |
| 47 | + title: $target.attr('title'), |
| 48 | + message: $target.html(), |
| 49 | + size: $(this).data('bootbox-size') |
| 50 | + }); |
| 51 | + }); |
| 52 | + }, |
| 53 | + |
| 54 | + trianglify: function(color1, color2, seed) { |
| 55 | + var header = $('#content'); |
| 56 | + var pattern = Trianglify({ |
| 57 | + width: window.screen.width | header.outerWidth(), |
| 58 | + height: header.outerHeight(), |
| 59 | + cell_size: 90, |
| 60 | + seed: seed, |
| 61 | + x_colors: [color1, color2] |
44 | 62 | }); |
45 | | - }); |
46 | | -}); |
47 | 63 |
|
48 | | -function trianglify(color1, color2, seed) { |
49 | | - var header = $('#content'); |
50 | | - var pattern = Trianglify({ |
51 | | - width: window.screen.width | header.outerWidth(), |
52 | | - height: header.outerHeight(), |
53 | | - cell_size: 90, |
54 | | - seed: seed, |
55 | | - x_colors: [color1, color2] |
56 | | - }); |
57 | | - |
58 | | - header.css('background-image', 'url(' + pattern.png() + ')'); |
| 64 | + header.css('background-image', 'url(' + pattern.png() + ')'); |
| 65 | + } |
59 | 66 | } |
| 67 | + |
| 68 | +$(function() { |
| 69 | + jekyllBootstrapDoc.buildSideMenu(); |
| 70 | + jekyllBootstrapDoc.addHeadingAnchors(); |
| 71 | + jekyllBootstrapDoc.enableBootbox(); |
| 72 | +}); |
0 commit comments