Use the jquery.toc.js library to auto-generate a table of contents for the loaded page under the side nav menu

This commit is contained in:
Andrew Manning 2016-11-27 21:25:38 -07:00
parent 678239424a
commit 5bcb373c00
3 changed files with 35 additions and 26 deletions

View File

@ -472,4 +472,4 @@ href="[baseurl]/removeaccount">[baseurl]/removeaccount
the account you are currently logged into will be removed. <br><br>This is
irreversible.<br><br>All your channels will be deleted. If you have identity
clones on other hubs this only removes by default the channels instances which
exists on this hub.
exists on this hub.

View File

@ -93,29 +93,38 @@
</div>
</div>
<div id="page-toc-container" style="margin-top:1.0em;">
<h3>Contents</h3>
</div>
<script>
// $(document).ready(function() {
// Determine the content section from the URL and expand the appropriate menu section
var url = document.createElement('a');
url.href = window.location;
switch (url.pathname.split('/')[2]) {
case 'tutorials':
$('#tutorials').addClass('in');
break;
case 'about':
$('#about').addClass('in');
break;
case 'admin':
$('#administrators').addClass('in');
break;
case 'member':
$('#members').addClass('in');
break;
case 'developer':
$('#developers').addClass('in');
break;
default:
break;
}
// }
// Determine the content section from the URL and expand the appropriate menu section
var url = document.createElement('a');
url.href = window.location;
switch (url.pathname.split('/')[2]) {
case 'tutorials':
$('#tutorials').addClass('in');
break;
case 'about':
$('#about').addClass('in');
break;
case 'admin':
$('#administrators').addClass('in');
break;
case 'member':
$('#members').addClass('in');
break;
case 'developer':
$('#developers').addClass('in');
break;
default:
break;
}
$(document).ready(function () {
var tocUl = $('#page-toc-container').append('<ul>').find('ul');
tocUl.removeClass();
tocUl.toc({content: "#doco-content", headings: "h1,h2,h3,h4"});
});
</script>

View File

@ -2,7 +2,7 @@
<div class="section-title-wrapper">
<h2>{{$title}}</h2>
</div>
<div class="section-content-wrapper">
<div class="section-content-wrapper" id="doco-content">
{{$content}}
</div>
</div>