mediawiki-extensions-Discus.../modules/dt.init.js
Bartosz Dziewoński 253da36101 Check if you can edit the page before opening the tools
The information is already included in the VisualEditor metadata request.

Bug: T276393
Bug: T270803
Change-Id: I45a232dcd23418da0711834bcc369a9a718006b0
2021-03-25 17:04:31 +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 {
// 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
};