Fix TOC placement: ignore Contents heading inside #toc
Leave default TOC on non-soldier pages; fix changelog Contents box
Line 229: Line 229:
}
}


// Contents box belongs near the top (after lead), never under Biography.
// Contents box belongs after the lead on soldier/profile pages only.
// Other pages (e.g. Site changelog) keep MediaWiki's default TOC placement.
var $toc = $out.find('#toc, .toc, .mw-table-of-contents').first();
var $toc = $out.find('#toc, .toc, .mw-table-of-contents').first();
if ($toc.length && !$toc.data('rbTocPlaced')) {
if ($toc.length && !$toc.data('rbTocPlaced')) {
Line 240: Line 241:
if ($ibox.length) {
if ($ibox.length) {
$ibox.after($toc);
$ibox.after($toc);
} else {
// Never use the TOC's own "Contents" heading (h2 inside #toc).
var $firstH2 = $out.find('h2').filter(function () {
return !$(this).closest('#toc, .toc, .mw-table-of-contents').length;
}).first();
if ($firstH2.length) {
$firstH2.before($toc);
}
}
}
}
}