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:
martimiz 2012-11-08 16:35:40 +01:00 committed by Will Rossiter
parent 2968e2947e
commit 5a29f0c9ba
2 changed files with 29 additions and 4 deletions

View File

@ -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">&#9660;</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('&#9650;');})
},
function() {
$("#toc").animate({'height':'hide'}, 200, function(){$('#table-of-contents h4 span').html('&#9660;');})
}
);
// Make sure clicking a link won't toggle the TOC
$("#table-of-contents li a").click(function (e) { e.stopPropagation(); });
}
/** ---------------------------------------------

View File

@ -18,7 +18,6 @@
<% if Content %>
<div id="sidebar-column">
<% include DocTableOfContents %>
<% include DocInThisModule %>
</div>
<% end_if %>