Fix js for toc

This commit is contained in:
Ryan Watters 2017-02-14 22:29:09 -08:00
parent 7768124fb2
commit ed50c7dbd0
4 changed files with 15 additions and 14 deletions

View File

@ -1,6 +1,6 @@
---
title: The Benefits of Static
linktitle: Benefits of Static
linktitle: The Benefits of Static
description:
date: 2017-02-01
publishdate: 2017-02-01

View File

@ -5,10 +5,9 @@ description:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
tags: [wercker]
weight:
draft: false
type:
layout:
slug:
aliases: []
notes:

View File

@ -1,17 +1,19 @@
//removes toc if not enough headings
(function() {
let tocLinks = document.querySelectorAll('#TableOfContents > ul a');
if(tocLinks && tocLinks.length < 2){
document.getElementById('toc').remove();
}else if (tocLinks && tocLinks.length > 1){
document.getElementById('toc-toggle').addEventListener('click',toggleToc,false);
let toc = document.getElementById('toc');
console.log(tocLinks);
if (toc && (tocLinks.length < 2)) {
toc.remove();
} else if (tocLinks.length > 1) {
document.getElementById('toc-toggle').addEventListener('click', toggleToc, false);
}
})();
function toggleToc(evt) {
evt.preventDefault();
evt.stopPropagation();
console.log("hello");
document.getElementById('toc').classList.toggle('toc-open');
document.getElementById('toc-toggle').classList.toggle('toc-open');
}
evt.preventDefault();
evt.stopPropagation();
console.log("hello");
document.getElementById('toc').classList.toggle('toc-open');
document.getElementById('toc-toggle').classList.toggle('toc-open');
}

File diff suppressed because one or more lines are too long