mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-20 02:01:20 +00:00
b119b633cf
New changes: f5fe845bc ve.collab UI and bookmarklet e096b57e9 Localisation updates from https://translatewiki.net. 5ed427d39 FocusableNode: Try to redraw highlights during setup d966cf7be Exclude OOUI from generated JSDuck documentation 4abb6dfa6 Update OOUI to v0.49.0 Local changes: * Exclude OOUI from generated JSDuck documentation * ve.ui.MWConfirmationDialog: Remove copied documentation Added files: - .jsduck/external-ooui.js - collab/ve.ui.CollabProcessDialog.js - collab/ve.ui.CollabTool.js Bug: T185396 Bug: T250843 Bug: T356983 Change-Id: I8fcacbbf4f9f213e58af91cc79ef8e89b65895b4
93 lines
2.4 KiB
JavaScript
93 lines
2.4 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWConfirmationDialog class.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
*/
|
|
|
|
/**
|
|
* Dialog for displaying a confirmation.
|
|
*
|
|
* This class exists to override the static MessageDialog actions.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.MessageDialog
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MWConfirmationDialog = function VeUiMWConfirmationDialog( config ) {
|
|
// Parent constructor
|
|
ve.ui.MWConfirmationDialog.super.call( this, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWConfirmationDialog, OO.ui.MessageDialog );
|
|
|
|
/* Static properties */
|
|
|
|
ve.ui.MWConfirmationDialog.static.name = 'confirmation';
|
|
|
|
ve.ui.MWConfirmationDialog.static.size = 'small';
|
|
|
|
/* Static methods */
|
|
|
|
/**
|
|
* Open a confirmation dialog
|
|
*
|
|
* @static
|
|
* @param {string} prompt message key to show as dialog content
|
|
* @param {Function} successCmd callback if continue action is chosen
|
|
*/
|
|
ve.ui.MWConfirmationDialog.static.confirm = function ( prompt, successCmd ) {
|
|
var windowManager = new OO.ui.WindowManager();
|
|
$( OO.ui.getTeleportTarget() ).append( windowManager.$element );
|
|
var dialog = new ve.ui.MWConfirmationDialog();
|
|
windowManager.addWindows( [ dialog ] );
|
|
windowManager.openWindow( dialog, {
|
|
// Messages that can be used here:
|
|
// * visualeditor-dialog-transclusion-back-confirmation-prompt
|
|
// * visualeditor-dialog-transclusion-close-confirmation-prompt
|
|
message: mw.message( prompt ).text()
|
|
} ).closed.then( function ( data ) {
|
|
if ( data && data.action === 'accept' ) {
|
|
successCmd();
|
|
}
|
|
} );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWConfirmationDialog.prototype.getSetupProcess = function ( data ) {
|
|
data = data || {};
|
|
data = ve.extendObject( {
|
|
actions: [
|
|
{
|
|
action: 'reject',
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-transclusion-confirmation-reject' ),
|
|
flags: 'safe'
|
|
},
|
|
{
|
|
action: 'accept',
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-transclusion-confirmation-discard' ),
|
|
flags: 'destructive'
|
|
}
|
|
]
|
|
}, data );
|
|
|
|
return ve.ui.MWConfirmationDialog.super.prototype.getSetupProcess.call( this, data );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWConfirmationDialog.prototype.getReadyProcess = function ( data ) {
|
|
// "normal" destructive actions don't get focus by default
|
|
this.getActions().get( { actions: 'accept' } )[ 0 ].focus();
|
|
|
|
return ve.ui.MWConfirmationDialog.super.prototype.getReadyProcess.call( this, data );
|
|
};
|