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;
|
padding: 4px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
#minitoc a {
|
#minitoc a {
|
||||||
|
|
|
@ -45,13 +45,27 @@ $(function() {
|
||||||
|
|
||||||
// generate contents of minitoc
|
// generate contents of minitoc
|
||||||
function generateMiniToc(divId) {
|
function generateMiniToc(divId) {
|
||||||
$('#minitoc').empty().append('<h2>In this section</h2>');
|
let headers = null;
|
||||||
$('#' + divId).find('h3').each(function(i) {
|
if(divId) {
|
||||||
let pos = $(this).text().search(" ");
|
$('#minitoc').empty().append('<h2>In this section</h2>');
|
||||||
let text = $(this).text().substring(0, pos);
|
headers = $('#' + divId).find('h3');
|
||||||
$("#minitoc").append("<a href='#" + $(this).attr("id") + "'>"
|
}
|
||||||
+ text + "</a>");
|
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)
|
// Ensure that the target is expanded (hideShow)
|
||||||
$('#minitoc a[href^="#"]').click(function() {
|
$('#minitoc a[href^="#"]').click(function() {
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
|
|
Loading…
Reference in New Issue