mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
Relocate table of contents
The table of contents is removed from the sidebar and relocated underneath breadcrumbs and page title (if there is one). It can be toggled open and closed.
This commit is contained in:
parent
2968e2947e
commit
5a29f0c9ba
@ -6,8 +6,9 @@
|
||||
*
|
||||
* Transform a #table-of-contents div to a nested list
|
||||
*/
|
||||
if($("#table-of-contents").length > 0) {
|
||||
var toc = '<div class="box"><ul id="toc"><h4>In this document:</h4>';
|
||||
if($("#content-column").length > 0) {
|
||||
var toc = '<div id="table-of-contents" class="open">' +
|
||||
'<h4>Table of contents<span class="updown">▼</span></h4><ul id="toc" style="display:none;">';
|
||||
|
||||
// Remove existing anchor redirection in the url
|
||||
var pageURL = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
|
||||
@ -22,7 +23,32 @@
|
||||
|
||||
toc += '</ul></div>';
|
||||
|
||||
$('#table-of-contents').prepend(toc);
|
||||
// Table of content location
|
||||
var title = $('#content-column h1:first');
|
||||
if (title.length > 0) {
|
||||
title.after(toc);
|
||||
} else {
|
||||
var breadcrums = $('#content-column #breadcrumbs');
|
||||
if (breadcrums.length > 0) {
|
||||
breadcrums.after(toc);
|
||||
} else {
|
||||
$('#content-column').prepend(toc);
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the TOC
|
||||
$('#table-of-contents').attr('href', 'javascript:void()').toggle(
|
||||
function() {
|
||||
$("#toc").animate({'height':'show'}, 200, function(){$('#table-of-contents h4 span').html('▲');})
|
||||
},
|
||||
function() {
|
||||
$("#toc").animate({'height':'hide'}, 200, function(){$('#table-of-contents h4 span').html('▼');})
|
||||
}
|
||||
);
|
||||
|
||||
// Make sure clicking a link won't toggle the TOC
|
||||
$("#table-of-contents li a").click(function (e) { e.stopPropagation(); });
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
<% if Content %>
|
||||
<div id="sidebar-column">
|
||||
<% include DocTableOfContents %>
|
||||
<% include DocInThisModule %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
Loading…
Reference in New Issue
Block a user