Skip to content

Commit 978fc74

Browse files
author
jordanmccullough
committed
Add all H3 TOC parsing support
Prevents JS parsing issue from adding ID attribute when non-`slide` wrapped H3 is encountered.
1 parent 76ddd95 commit 978fc74

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

_javascript/curriculum.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ $(function(){
1919
proximity: 150
2020
});
2121

22-
23-
2422
function buildToc(){
2523
var headings = $("h3"),
2624
toc = $("#toc-list");
@@ -41,15 +39,13 @@ $(function(){
4139

4240
item = $('<li><a href="#' + headingSep + '">' + headings[h].innerHTML + '</a></li>');
4341
toc.append(item);
44-
// console.log(headings[h].parentElement);
45-
46-
// var hiddenTitle = document.createElement("h3");
47-
// hiddenTitle.setAttribute("id", headingSep);
48-
// console.log(hiddenTitle);
4942

50-
// $(headings[h].parentElement).prepend(hiddenTitle);
51-
52-
headings[h].parentElement.setAttribute("id", headingSep);
43+
if(headings[h].parentElement.getAttribute("class").indexOf("alignment")>-1){
44+
headings[h].parentElement.setAttribute("id", headingSep);
45+
}
46+
else{
47+
headings[h].setAttribute("id", headingSep);
48+
}
5349

5450
$('.curriculum').scrollspy({ target: '#toc' });
5551
}

0 commit comments

Comments
 (0)