mirror of https://github.com/docker/docs.git
Fix for nesting of TOC
This commit is contained in:
parent
cc2092d2fa
commit
6b2de29fa7
22
js/menu.js
22
js/menu.js
|
@ -57,7 +57,6 @@ jQuery(document).ready(function(){
|
|||
var output = "";
|
||||
$("h2, h3, h4").each(function() {
|
||||
var li= "<li><a href='" + window.location + "#" + $(this).attr('id') + "'>" + $(this).text().replace("¶","") + "</a></li>";
|
||||
lastHeader = currentHeader;
|
||||
if( $(this).is("h2") ){
|
||||
// h2
|
||||
currentHeader = 2;
|
||||
|
@ -68,18 +67,19 @@ jQuery(document).ready(function(){
|
|||
// h4
|
||||
currentHeader = 4;
|
||||
}
|
||||
if (currentHeader > lastHeader)
|
||||
{
|
||||
if (currentHeader > lastHeader) {
|
||||
// nest further
|
||||
output += "<ul>" + li;
|
||||
} else if (lastHeader < currentHeader)
|
||||
{
|
||||
// close nesting
|
||||
output += "</ul>" + li
|
||||
} else {
|
||||
// continue, no change in nesting
|
||||
output += li;
|
||||
output += "<ul>"
|
||||
}
|
||||
if (currentHeader < lastHeader && lastHeader > 0) {
|
||||
// close nesting
|
||||
for (i=0; i < (lastHeader - currentHeader); i++)
|
||||
{
|
||||
output += "</ul>"
|
||||
}
|
||||
}
|
||||
output += li;
|
||||
lastHeader = currentHeader;
|
||||
/*
|
||||
if( $(this).is("h2") ){
|
||||
prevH2List = $("<ul></ul>");
|
||||
|
|
Loading…
Reference in New Issue