Fix toc scrollspy and desc for internal.md

This commit is contained in:
Ryan Watters
2017-03-06 17:47:05 -06:00
parent b134f2c2c1
commit ee1147476f
4 changed files with 62 additions and 73 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: Internal Templates
linktitle: Internal Templates
description: Hugo ships with a series of internal templates to
description: Hugo ships with internal boilerplate templates that cover the most common use cases for static websites.
date: 2017-03-06
publishdate: 2017-03-06
lastmod: 2017-03-06
+1 -68
View File
@@ -46,71 +46,4 @@ $(document).ready(function() {
// else if (scroll > offset3)
});
}
});
// var mySequence = [
// { e: $element1, p: { translateX: 100 }, o: { duration: 1000 } },
// /* The call below will run at the same time as the first call. */
// { e: $element2, p: { translateX: 200 }, o: { duration: 1000, sequenceQueue: false },
// /* As normal, the call below will run once the second call is complete. */
// { e: $element3, p: { translateX: 300 }, o: { duration: 1000 }
// ];
// $.Velocity.RunSequence(mySequence);
// terminalElements = document.querySelectorAll('span.terminal-line');
// function terminals_init() {
// var elements = terminalElements;
// for (var i = 0; i < elements.length; i++) {
// var e = elements[i]
// e.completeHTML = e.innerHTML
// e.innerHTML = ""
// e.i = 0
// }
// }
// function terminals_start() {
// //terminalIntervalFunction = function(){ terminals_next() }
// // setInterval(terminalIntervalFunction, 1000/60);
// terminals_next()
// }
// function terminals_next() {
// var done = true
// var elements = terminalElements;
// for (var i = 0; i < elements.length && done == true; i++) {
// var e = elements[i]
// e.i++
// if (e.innerHTML.length >= e.completeHTML.length) {
// e.innerHTML = e.completeHTML
// } else {
// var s = e.completeHTML.substring(0, e.i)
// if (s.slice(-1) == " ") {
// if (e.innerHTML.length % 6 == 0) { s = s + "" } else { s = s + "|" }
// } else {
// s = s + "|"
// }
// e.innerHTML = s
// e.parentNode.style.display = 'none'
// e.parentNode.style.display = 'block'
// done = false
// }
// }
// if (!done) {
// //window.clearInterval(terminalIntervalFunction)
// setTimeout(terminals_next, 1600 / 15)
// }
// }
// terminals_init()
// window.onload = function() { terminals_start() };
});
+56
View File
@@ -0,0 +1,56 @@
//IIFE to remove all third-level li's from TOC so as not to negatively affect scrollspy (these are currently hidden anyway)
(function() {
let toc = document.getElementById('toc') ? true : false;
if (toc) {
let levelFours = document.querySelectorAll('#TableOfContents > ul > li > ul > li > ul > li > ul');
if (levelFours) {
for (var i = 0; i < levelFours.length; i++) {
levelFours[i].remove();
}
}
}
})();
$(document).ready(function() {
// Cache selectors
var lastId,
tocNav = $("#TableOfContents"),
tocNavHeight = tocNav.outerHeight() + 15,
headerHeight = $('#site-header').height(),
// All list items
menuItems = tocNav.find("a"),
// Anchors corresponding to menu items
scrollItems = menuItems.map(function() {
var item = $($(this).attr("href"));
if (item.length) {
return item;
}
});
// Bind to scroll
$(window).scroll(function(evt) {
evt.preventDefault();
var isBottom = $(window).scrollTop() + $(window).height() == $(document).height();
// Get container scroll position
var fromTop = $(this).scrollTop() + headerHeight + 100;
// Get id of current scroll item
var cur = scrollItems.map(function() {
if ($(this).offset().top < fromTop)
return this;
});
// Get the id of the current element
cur = cur[cur.length - 1];
var id = cur && cur.length ? cur[0].id : "";
if (lastId !== id) {
lastId = id;
// Set/remove active class
menuItems.parent().removeClass("active").end().filter("[href='#" + id + "']").parent().addClass("active");
history.replaceState({}, "", menuItems.filter("[href='#" + id + "']").attr("href"));
}
if (isBottom) {
menuItems.parent().removeClass('active');
if (menuItems.last().parent().attr('class') !== 'active') {
menuItems.last().parent().addClass('active');
}
}
});
});
+4 -4
View File
File diff suppressed because one or more lines are too long