Generalise the way extra modules are loaded

Change-Id: Icd453421b022a6450d1358edbe2132e49ca0b3bf
This commit is contained in:
Roan Kattouw 2013-10-11 14:04:11 +01:00 committed by Ed Sanders
parent 75bee13db5
commit 0901c0328a
2 changed files with 15 additions and 6 deletions

View file

@ -288,7 +288,7 @@ class VisualEditorHooks {
'defaultUserOptions' => array(
'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'],
'enable' => $wgDefaultUserOptions['visualeditor-enable'],
'experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'],
'enable-experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'],
),
'skins' => $wgVisualEditorSupportedSkins,
'tabPosition' => $wgVisualEditorTabPosition,

View file

@ -20,7 +20,8 @@
* revision id here. Defaults to loading the latest version (see #load).
*/
ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) {
var conf = mw.config.get( 'wgVisualEditorConfig' );
var i, len, prefName, prefValue, conf = mw.config.get( 'wgVisualEditorConfig' ),
extraModules = [ 'experimental' ];
// Parent constructor
ve.init.Target.call( this, $container );
@ -34,11 +35,9 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId )
this.apiUrl = mw.util.wikiScript( 'api' );
this.submitUrl = ( new mw.Uri( mw.util.wikiGetlink( this.pageName ) ) )
.extend( { 'action': 'submit' } );
this.modules = [
( mw.config.get( 'wgUserName' ) === null ?
conf.defaultUserOptions.experimental :
mw.user.options.get( 'visualeditor-enable-experimental', conf.defaultUserOptions.experimental ) ) ?
'ext.visualEditor.experimental' : 'ext.visualEditor.core',
'ext.visualEditor.core',
'ext.visualEditor.data'
]
.concat(
@ -47,6 +46,16 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId )
['ext.visualEditor.viewPageTarget.icons-raster', 'ext.visualEditor.icons-raster']
)
.concat( mw.config.get( 'wgVisualEditorConfig' ).pluginModules || [] );
for ( i = 0, len = extraModules.length; i < len; i++ ) {
prefName = 'visualeditor-enable-' + extraModules[i];
prefValue = mw.config.get( 'wgUserName' ) === null ?
conf.defaultUserOptions[prefName] :
mw.user.options.get( prefName, conf.defaultUserOptions[prefName] );
if ( prefValue && prefValue !== '0' ) {
this.modules.push( 'ext.visualEditor.' + extraModules[i] );
}
}
this.pluginCallbacks = [];
this.modulesReady = $.Deferred();
this.loading = false;