diff --git a/includes/SkinCitizen.php b/includes/SkinCitizen.php index 9835f01d..33dcdac7 100644 --- a/includes/SkinCitizen.php +++ b/includes/SkinCitizen.php @@ -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 diff --git a/resources/skins.citizen.scripts/skin.js b/resources/skins.citizen.scripts/skin.js index 47326b18..881435d2 100644 --- a/resources/skins.citizen.scripts/skin.js +++ b/resources/skins.citizen.scripts/skin.js @@ -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' ); } diff --git a/resources/skins.citizen.scripts.toc/skins.citizen.scripts.toc.js b/resources/skins.citizen.scripts/tableOfContents.js similarity index 97% rename from resources/skins.citizen.scripts.toc/skins.citizen.scripts.toc.js rename to resources/skins.citizen.scripts/tableOfContents.js index 9a28cfdd..667e5b4c 100644 --- a/resources/skins.citizen.scripts.toc/skins.citizen.scripts.toc.js +++ b/resources/skins.citizen.scripts/tableOfContents.js @@ -48,4 +48,6 @@ function initTOC() { } } -initTOC(); +module.exports = { + init: initTOC +}; diff --git a/skin.json b/skin.json index 2b2246b4..a5a28314 100644 --- a/skin.json +++ b/skin.json @@ -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"