mediawiki-extensions-Discus.../modules/dt.init.js
Ed Sanders d0bcec6196 Enable DT server side via a cookie to preserve user enable hack
Bug: T265499
Change-Id: Ied330c633732651d1c4e136646afd676ceb570c7
2020-10-19 21:42:58 +01:00

46 lines
1.3 KiB
JavaScript

var controller = require( './controller.js' ),
config = require( './config.json' ),
uri = new mw.Uri();
/**
* @class mw.dt
* @singleton
*/
mw.dt = {};
mw.dt.initState = {};
mw.dt.init = function ( $container ) {
if ( $container.is( '#mw-content-text' ) || $container.find( '#mw-content-text' ).length ) {
// eslint-disable-next-line no-jquery/no-global-selector
controller.init( $( '#mw-content-text' ), mw.dt.initState );
// Reset for next init
mw.dt.initState = {};
}
};
if ( uri.query.dtdebug ) {
mw.loader.load( 'ext.discussionTools.debug' );
} else if ( mw.config.get( 'wgIsProbablyEditable' ) ) {
// Don't use an anonymous function, because ReplyWidget needs to be able to remove this handler
mw.hook( 'wikipage.content' ).add( mw.dt.init );
}
// If the tool is not enabled on this wiki, then the user
// is using a local hack to load this code. Set a cookie
// so reply links are added on the server.
if ( !config.enable && !uri.query.dtenable ) {
mw.cookie.set( 'discussiontools-tempenable', 1 );
}
module.exports = {
controller: controller,
Parser: require( './Parser.js' ),
modifier: require( './modifier.js' ),
ThreadItem: require( './ThreadItem.js' ),
HeadingItem: require( './HeadingItem.js' ),
CommentItem: require( './CommentItem.js' ),
utils: require( './utils.js' ),
logger: require( './logger.js' ),
config: config
};