Make sure enhanced editing toolbar is loaded before adding button

Bug: T169943
Change-Id: Id8828b0d49ecec5124430d15445739d73795d164
This commit is contained in:
Kaldari 2017-07-10 14:16:36 -07:00
parent f92c9004b6
commit 4fc52b7ba3

View file

@ -434,15 +434,20 @@
}
}
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
// If view is in edit mode, add the button to the toolbar.
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
// Check if the user is using the enhanced editing toolbar (supplied by the
// WikiEditor extension) or the default editing toolbar (supplied by core).
if ( wikiEditorToolbarEnabled ) {
// Add our button
$( addCodeMirrorToWikiEditor );
// They are using the enhanced editing toolbar.
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
// Add CodeMirror button to the enhanced editing toolbar.
$( addCodeMirrorToWikiEditor );
} );
} else {
// Load wikiEditor's toolbar and add our button
// They are using the default editing toolbar.
mw.loader.using( 'mediawiki.toolbar', function () {
// If WikiEditor isn't enabled, add CodeMirror button to the default wiki editor toolbar
// Add CodeMirror button to the default editing toolbar.
mw.toolbar.addButton( {
speedTip: mw.msg( 'codemirror-toggle-label' ),
imageId: 'mw-editbutton-codemirror',