mediawiki-extensions-Discus.../modules/dt.init.js
Bartosz Dziewoński 3e5a67010f Use module.exports/require() rather than mw.dt namespace for defining classes
The packageFiles system makes it easier to export site config data
from PHP to JS, which we need a lot of, but it's awkward when mixing
it with defining and accessing classes via a namespace like mw.dt.

The only thing remaining in mw.dt is mw.dt.pageThreads, which is
described to be "for debugging", so we should keep it easy to type.
Also we still use the namespace for documenting classes.

Everything else can be reached by require()'ing a ResourceLoader
module, for example instead of `mw.dt.ui.ReplyWidget`
you'd do `require( 'ext.discussionTools.ReplyWidget' )`.
(When debugging from browser console, use `mw.loader.require` instead.)

Change-Id: I6496abcf58c21658d6fd0f3fc1db1f7380a89df7
2019-12-10 22:47:40 +01:00

19 lines
487 B
JavaScript

var controller = require( 'ext.discussionTools.controller' );
/**
* @class mw.dt
* @singleton
*/
mw.dt = {};
if ( new mw.Uri().query.dtdebug ) {
mw.loader.load( 'ext.discussionTools.debug' );
} else {
mw.hook( 'wikipage.content' ).add( function ( $container ) {
// Don't re-run if we already handled this element
if ( $container.closest( '.dt-init-done' ).length === 0 ) {
controller.init( $container.find( '#mw-content-text' ).addBack( '#mw-content-text' ) );
}
} );
}