Fix minitoc
I make a distinction between searching the whole doc contents or just the current section, as I've adapted bigblow to not tabify main sections
This commit is contained in:
parent
0c3d9286c3
commit
b04414a421
|
@ -620,6 +620,7 @@ span.todo .selected {
|
|||
padding: 4px;
|
||||
position: fixed;
|
||||
width: auto;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#minitoc a {
|
||||
|
|
|
@ -45,13 +45,27 @@ $(function() {
|
|||
|
||||
// generate contents of minitoc
|
||||
function generateMiniToc(divId) {
|
||||
$('#minitoc').empty().append('<h2>In this section</h2>');
|
||||
$('#' + divId).find('h3').each(function(i) {
|
||||
let pos = $(this).text().search(" ");
|
||||
let text = $(this).text().substring(0, pos);
|
||||
$("#minitoc").append("<a href='#" + $(this).attr("id") + "'>"
|
||||
+ text + "</a>");
|
||||
});
|
||||
let headers = null;
|
||||
if(divId) {
|
||||
$('#minitoc').empty().append('<h2>In this section</h2>');
|
||||
headers = $('#' + divId).find('h3');
|
||||
}
|
||||
else {
|
||||
$('#minitoc').empty().append('<h2>In this document</h2>');
|
||||
headers = $('div#content').find(':header');
|
||||
}
|
||||
headers.each(function(i) {
|
||||
let text = $(this)
|
||||
.clone() //clone the element
|
||||
.children() //select all the children
|
||||
.remove() //remove all the children
|
||||
.end() //again go back to selected element
|
||||
.text().trim();
|
||||
var level = parseInt(this.nodeName.substring(1), 10);
|
||||
let prefix = "".padStart(level-1, " ");
|
||||
$("#minitoc").append("<a href='#" + $(this).attr("id") + "'>"
|
||||
+ prefix + text + "</a>");
|
||||
});
|
||||
// Ensure that the target is expanded (hideShow)
|
||||
$('#minitoc a[href^="#"]').click(function() {
|
||||
var href = $(this).attr('href');
|
||||
|
|
Loading…
Reference in New Issue