mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
fix: do not show TOC if fewer than 2 headings
This commit is contained in:
@@ -5,19 +5,25 @@ define('admin/settings', ['uploader', 'mousetrap'], function (uploader, mousetra
|
|||||||
var Settings = {};
|
var Settings = {};
|
||||||
|
|
||||||
Settings.populateTOC = function () {
|
Settings.populateTOC = function () {
|
||||||
$('.settings-header').each(function () {
|
var headers = $('.settings-header');
|
||||||
var header = $(this).text();
|
|
||||||
var anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
|
||||||
|
|
||||||
$(this).prepend('<a name="' + anchor + '"></a>');
|
if (headers.length > 1) {
|
||||||
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
|
headers.each(function () {
|
||||||
});
|
var header = $(this).text();
|
||||||
|
var anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
||||||
|
|
||||||
var scrollTo = $('a[name="' + window.location.hash.replace('#', '') + '"]');
|
$(this).prepend('<a name="' + anchor + '"></a>');
|
||||||
if (scrollTo.length) {
|
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
|
||||||
$('html, body').animate({
|
});
|
||||||
scrollTop: (scrollTo.offset().top) + 'px',
|
|
||||||
}, 400);
|
var scrollTo = $('a[name="' + window.location.hash.replace('#', '') + '"]');
|
||||||
|
if (scrollTo.length) {
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: (scrollTo.offset().top) + 'px',
|
||||||
|
}, 400);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('.content-header').parents('.row').remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user