settings - automated table of contents

This commit is contained in:
psychobunny
2015-08-19 13:27:30 -04:00
parent acb1e8a495
commit d464cb2f0d
4 changed files with 33 additions and 5 deletions

View File

@@ -8,6 +8,16 @@ define('admin/settings', ['uploader', 'sounds'], function(uploader, sounds) {
$(window).on('action:config.loaded', Settings.prepare);
};
Settings.populateTOC = function() {
$('.settings-header').each(function() {
var header = $(this).text(),
anchor = header.toLowerCase().replace(/ /g, '-').trim();
$(this).prepend('<a name="' + anchor + '"></a>');
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
});
};
Settings.prepare = function(callback) {
// Populate the fields on the page from the config
var fields = $('#content [data-field]'),