mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 19:55:55 +00:00
3f0f302577
Previously, the ve-mw/init/ directory contained two kinds of files: those that were used when initializing VE, and those that may be loaded even if VE is not going to be initialized at all. The latter kind must not use the `ve` global variable. After moving those files to ve-mw/preinit/ we can enforce this with .eslintrc.json in that directory. This would have prevented T228684. (Technically they merely must not use `ve.init`, and may use `ve`, but that's harder to enforce. We should instead move the few non-init methods out of `ve`: now, track, trackSubscribe, trackSubscribeAll). Also, group some files under ve-mw/init/: targets/ now (only) contains ve.init.mw.Target and its subclasses, apiresponsecache/ now contains ve.init.mw.ApiResponseCache and its subclasses. Bug: T228684 Change-Id: I945249a27f6a0fa10a432d5c5dc57bc7e0461fd8
72 lines
1.8 KiB
JavaScript
72 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWVESwitchConfirmDialog class.
|
|
*
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
mw.libs.ve = mw.libs.ve || {};
|
|
/**
|
|
* Dialog for letting the user choose how to switch to wikitext mode.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.MessageDialog
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
mw.libs.ve.SwitchConfirmDialog = function MWLibsVESwitchConfirmDialog( config ) {
|
|
// Parent constructor
|
|
mw.libs.ve.SwitchConfirmDialog.super.call( this, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( mw.libs.ve.SwitchConfirmDialog, OO.ui.MessageDialog );
|
|
|
|
/* Static Properties */
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.name = 'veswitchconfirm';
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.title =
|
|
mw.msg( 'visualeditor-mweditmodeve-title' );
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.message =
|
|
mw.msg( 'visualeditor-mweditmodeve-warning' );
|
|
|
|
mw.libs.ve.SwitchConfirmDialog.static.actions = [
|
|
{
|
|
action: 'cancel',
|
|
label: mw.msg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
|
flags: [ 'safe', 'back' ]
|
|
},
|
|
{
|
|
action: 'discard',
|
|
label: mw.msg( 'visualeditor-mweditmodesource-warning-switch-discard' ),
|
|
flags: 'destructive'
|
|
}
|
|
];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
mw.libs.ve.SwitchConfirmDialog.prototype.getActionProcess = function ( action ) {
|
|
if ( action === 'discard' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.getActions()
|
|
.setAbilities( { cancel: false } )
|
|
.get( { actions: 'discard' } )[ 0 ].pushPending();
|
|
this.close( { action: 'discard' } );
|
|
}, this );
|
|
} else if ( action === 'cancel' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.close( { action: 'cancel' } );
|
|
}, this );
|
|
}
|
|
|
|
// Parent method
|
|
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getActionProcess.call( this, action );
|
|
};
|