Dynamically load Jquery.js and Bootstrap.js

This commit is contained in:
2020-12-01 17:20:53 +01:00
parent f9efb73c87
commit 2d266366bb
5 changed files with 340 additions and 261 deletions

47
dist/script.js vendored
View File

@@ -7,10 +7,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
// var $ = require('jquery');
// window.$ = $;
// require('bootstrap');
//
// Blocks
docReady(function () {
var boxesNames = {
@@ -105,7 +101,46 @@ function docReady(fn) {
} else {
document.addEventListener("DOMContentLoaded", fn);
}
} // function collapse_toc_elements_on_click (nav_li_a){
} // Load Jquery
var scr = document.createElement('script'),
head = document.head || document.getElementsByTagName('head')[0];
scr.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js';
scr.async = false; // optionally
head.insertBefore(scr, head.firstChild); // Load Bootstrap.js
var scr = document.createElement('script'),
head = document.head || document.getElementsByTagName('head')[0];
scr.src = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js';
scr.async = false; // optionally
head.insertBefore(scr, head.firstChild); // After it is loaded
scr.addEventListener('load', function () {
$(document).ready(function () {
$('#text-table-of-contents ul').first().addClass('nav'); // ScrollSpy also requires that we use
// a Bootstrap nav component.
$('body').scrollspy({
target: '#text-table-of-contents'
}); // set the height of tableOfContents
var $postamble = $('#postamble');
var $tableOfContents = $('#table-of-contents');
$tableOfContents.css({
paddingBottom: $postamble.outerHeight()
}); // add TOC button
var toggleSidebar = $('<div id="toggle-sidebar"><a href="#table-of-contents"><h2>Table of Contents</h2></a></div>');
$('#content').prepend(toggleSidebar); // add close button when sidebar showed in mobile screen
var closeBtn = $('<a class="close-sidebar" href="#">Close</a>');
var tocTitle = $('#table-of-contents').find('h2');
tocTitle.append(closeBtn);
});
}); // function collapse_toc_elements_on_click (nav_li_a){
// /*
// When an `a' element in the TOC is clicked, its parent
// `li' element's active attribute is toggled. This causes
@@ -145,8 +180,6 @@ function docReady(fn) {
// // ScrollSpy also requires that we use
// // a Bootstrap nav component.
// $('body').scrollspy({target: '#text-table-of-contents'});
// // DON'T add sticky table headers (Fix issue #69?)
// // $('table').stickyTableHeaders();
// // set the height of tableOfContents
// var $postamble = $('#postamble');
// var $tableOfContents = $('#table-of-contents');

2
dist/style.css vendored

File diff suppressed because one or more lines are too long