refactor(core): merge ToC script into core scripts

This commit is contained in:
alistair3149 2022-05-12 17:18:39 -04:00
parent e0d5eb9657
commit 508c96ae9d
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C
4 changed files with 14 additions and 12 deletions

View file

@ -307,7 +307,6 @@ class SkinCitizen extends SkinMustache {
}
// Table of content highlight
$options['scripts'][] = 'skins.citizen.scripts.toc';
$options['styles'][] = 'skins.citizen.styles.toc';
// Drawer sitestats

View file

@ -113,7 +113,8 @@ function onTitleHidden( document ) {
*/
function main( window ) {
const theme = require( './theme.js' ),
search = require( './search.js' );
search = require( './search.js' ),
toc = require( './tableOfContents.js' );
enableCssAnimations( window.document );
theme.init( window );
@ -125,6 +126,15 @@ function main( window ) {
document.documentElement.classList.add( 'citizen-loading' );
}, false );
// TODO: This need some serious refactoring
// * Have a function to define checkbox targets then pass it to init
// * initCheckboxHack needs should take such objects as parameter
// * We shouldn't get the toc element multitple times
// * Need to consolidate scroll and intersection handlers
if ( document.getElementById( 'toc' ) ) {
toc.init();
}
mw.loader.load( 'skins.citizen.preferences' );
}

View file

@ -48,4 +48,6 @@ function initTOC() {
}
}
initTOC();
module.exports = {
init: initTOC
};

View file

@ -195,15 +195,6 @@
"mobile"
]
},
"skins.citizen.scripts.toc": {
"scripts": [
"resources/skins.citizen.scripts.toc/skins.citizen.scripts.toc.js"
],
"targets": [
"desktop",
"mobile"
]
},
"skins.citizen.scripts.drawer": {
"scripts": [
"resources/skins.citizen.scripts.drawer/skins.citizen.scripts.drawer.js"