2018-09-26 12:49:10 +00:00
|
|
|
/*!
|
2014-07-14 21:32:49 +00:00
|
|
|
* VisualEditor user interface MWWikitextSwitchConfirmDialog class.
|
|
|
|
*
|
2019-01-01 13:24:23 +00:00
|
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
2014-07-14 21:32:49 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2014-06-25 20:13:11 +00:00
|
|
|
/**
|
2014-07-14 21:32:49 +00:00
|
|
|
* Dialog for letting the user choose how to switch to wikitext mode.
|
2014-06-25 20:13:11 +00:00
|
|
|
*
|
|
|
|
* @class
|
2014-07-14 21:32:49 +00:00
|
|
|
* @extends OO.ui.MessageDialog
|
2014-06-25 20:13:11 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2014-08-21 00:50:54 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog = function VeUiMWWikitextSwitchConfirmDialog( config ) {
|
2014-06-25 20:13:11 +00:00
|
|
|
// Parent constructor
|
2014-08-21 00:50:54 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.super.call( this, config );
|
2014-06-25 20:13:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
OO.inheritClass( ve.ui.MWWikitextSwitchConfirmDialog, OO.ui.MessageDialog );
|
2014-06-25 20:13:11 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.name = 'wikitextswitchconfirm';
|
|
|
|
|
2014-07-14 21:32:49 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-mweditmodesource-title' );
|
|
|
|
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.message =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning' );
|
|
|
|
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.actions = [
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'cancel',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
2015-08-06 13:34:32 +00:00
|
|
|
flags: [ 'safe', 'back' ]
|
2014-07-14 21:32:49 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
action: 'switch',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-switch' ),
|
2014-12-11 22:49:51 +00:00
|
|
|
flags: [ 'progressive', 'primary' ]
|
2014-07-14 21:32:49 +00:00
|
|
|
}
|
|
|
|
];
|
2014-06-25 20:13:11 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2014-07-14 21:32:49 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.prototype.getActionProcess = function ( action ) {
|
2014-07-07 19:51:41 +00:00
|
|
|
if ( action === 'switch' ) {
|
|
|
|
return new OO.ui.Process( function () {
|
2016-03-07 20:07:41 +00:00
|
|
|
this.getActions().setAbilities( { cancel: false } );
|
2015-08-19 17:33:02 +00:00
|
|
|
this.getActions().get()[ 1 ].pushPending();
|
2015-09-04 00:42:05 +00:00
|
|
|
this.target.switchToWikitextEditor( false, true );
|
2014-07-07 19:51:41 +00:00
|
|
|
}, this );
|
|
|
|
} else if ( action === 'cancel' ) {
|
2014-07-14 21:32:49 +00:00
|
|
|
return new OO.ui.Process( function () {
|
2014-08-22 20:50:48 +00:00
|
|
|
this.close( { action: action } );
|
2014-07-14 21:32:49 +00:00
|
|
|
}, this );
|
|
|
|
}
|
|
|
|
|
2014-06-25 20:13:11 +00:00
|
|
|
// Parent method
|
2014-07-14 21:32:49 +00:00
|
|
|
return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.getActionProcess.call( this, action );
|
2014-06-25 20:13:11 +00:00
|
|
|
};
|
|
|
|
|
2014-07-07 19:51:41 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
**/
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.prototype.setup = function ( data ) {
|
|
|
|
this.target = data.target;
|
|
|
|
|
|
|
|
// Parent method
|
|
|
|
return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.setup.call( this, data );
|
|
|
|
};
|
|
|
|
|
2014-06-25 20:13:11 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.windowFactory.register( ve.ui.MWWikitextSwitchConfirmDialog );
|