2014-07-14 21:32:49 +00:00
|
|
|
/*
|
|
|
|
* VisualEditor user interface MWWikitextSwitchConfirmDialog class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @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
|
2014-07-14 21:32:49 +00:00
|
|
|
* @param {OO.ui.WindowManager} manager Manager of window
|
2014-06-25 20:13:11 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2014-07-14 21:32:49 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog = function VeUiMWWikitextSwitchConfirmDialog( manager, config ) {
|
2014-06-25 20:13:11 +00:00
|
|
|
// Parent constructor
|
2014-07-14 21:32:49 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.super.call( this, manager, 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.verbose = true;
|
|
|
|
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.size = 'small';
|
|
|
|
|
2014-06-25 20:13:11 +00:00
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.static.icon = 'help';
|
|
|
|
|
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 = [
|
|
|
|
{
|
|
|
|
'action': 'cancel',
|
|
|
|
'label': OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
|
|
|
'flags': 'safe'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'action': 'switch',
|
|
|
|
'label': OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-switch' ),
|
|
|
|
'flags': 'primary'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'action': 'discard',
|
|
|
|
'label': OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-switch-discard' ),
|
|
|
|
'flags': 'destructive'
|
|
|
|
}
|
|
|
|
];
|
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 ) {
|
|
|
|
if ( action === 'switch' || action === 'discard' ) {
|
|
|
|
return new OO.ui.Process( function () {
|
|
|
|
this.close( { 'action': action } );
|
|
|
|
}, 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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWWikitextSwitchConfirmDialog.prototype.getTeardownProcess = function ( data ) {
|
2014-07-15 22:49:51 +00:00
|
|
|
data = data || {};
|
2014-06-25 20:13:11 +00:00
|
|
|
return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.getTeardownProcess.call( this, data )
|
|
|
|
.first( function () {
|
2014-07-14 21:32:49 +00:00
|
|
|
// EVIL HACK - we shouldn't be reaching into the manager for these promises
|
2014-06-25 20:13:11 +00:00
|
|
|
if ( data.action === 'switch' || data.action === 'discard' ) {
|
2014-07-14 21:32:49 +00:00
|
|
|
this.manager.closing.resolve( data );
|
2014-06-25 20:13:11 +00:00
|
|
|
} else {
|
2014-07-14 21:32:49 +00:00
|
|
|
this.manager.closing.reject( data );
|
2014-06-25 20:13:11 +00:00
|
|
|
}
|
|
|
|
}, this );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.windowFactory.register( ve.ui.MWWikitextSwitchConfirmDialog );
|