2016-04-28 21:08:26 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWWelcomeDialog class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2016-04-28 21:08:26 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
mw.libs.ve = mw.libs.ve || {};
|
|
|
|
/**
|
|
|
|
* Dialog for welcoming new users.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.MessageDialog
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
mw.libs.ve.WelcomeDialog = function VeInitWelcomeDialog( config ) {
|
|
|
|
// Parent constructor
|
|
|
|
mw.libs.ve.WelcomeDialog.super.call( this, config );
|
|
|
|
|
|
|
|
this.$element
|
2019-01-13 00:21:33 +00:00
|
|
|
.addClass( 've-init-mw-welcomeDialog' );
|
2016-04-28 21:08:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( mw.libs.ve.WelcomeDialog, OO.ui.MessageDialog );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
mw.libs.ve.WelcomeDialog.static.name = 'welcome';
|
|
|
|
|
|
|
|
mw.libs.ve.WelcomeDialog.static.size = 'medium';
|
|
|
|
|
|
|
|
mw.libs.ve.WelcomeDialog.static.actions = [
|
|
|
|
{
|
|
|
|
action: 'switch-wte',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-welcomedialog-switch' ),
|
2016-09-15 00:18:10 +00:00
|
|
|
modes: [ 'visual' ]
|
2016-04-28 21:08:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
action: 'switch-ve',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-welcomedialog-switch-ve' ),
|
2016-09-15 00:18:10 +00:00
|
|
|
modes: [ 'source' ]
|
2016-04-28 21:08:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
action: 'accept',
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-welcomedialog-action' ),
|
|
|
|
flags: [ 'progressive', 'primary' ],
|
2016-09-15 00:18:10 +00:00
|
|
|
modes: [ 'visual', 'source', 'noswitch' ]
|
2016-04-28 21:08:26 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mw.libs.ve.WelcomeDialog.prototype.getSetupProcess = function ( data ) {
|
|
|
|
// Provide default title and message
|
|
|
|
data = $.extend( {
|
|
|
|
title: mw.msg( 'visualeditor-welcomedialog-title', mw.user, mw.config.get( 'wgSiteName' ) ),
|
2018-04-12 22:15:15 +00:00
|
|
|
message: $( '<span>' )
|
2019-01-13 00:21:33 +00:00
|
|
|
.addClass( 've-init-mw-welcomeDialog-content' )
|
2016-04-28 21:08:26 +00:00
|
|
|
.append(
|
2021-10-25 15:51:29 +00:00
|
|
|
$( document.createTextNode( mw.msg( 'visualeditor-welcomedialog-content' ) ) ),
|
2018-04-12 22:15:15 +00:00
|
|
|
$( '<br>' ),
|
2021-10-25 15:51:29 +00:00
|
|
|
$( document.createTextNode( mw.msg( 'visualeditor-welcomedialog-content-thanks' ) ) )
|
2016-04-28 21:08:26 +00:00
|
|
|
)
|
|
|
|
}, data );
|
|
|
|
|
2018-06-21 21:08:17 +00:00
|
|
|
return mw.libs.ve.WelcomeDialog.super.prototype.getSetupProcess.call( this, data )
|
2024-04-30 21:25:39 +00:00
|
|
|
.next( () => {
|
2018-06-21 21:08:17 +00:00
|
|
|
this.switchable = data.switchable;
|
|
|
|
this.editor = data.editor;
|
2016-04-28 21:08:26 +00:00
|
|
|
|
2018-06-21 21:08:17 +00:00
|
|
|
this.actions.setMode( this.switchable ? this.editor : 'noswitch' );
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2016-04-28 21:08:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mw.libs.ve.WelcomeDialog.prototype.getActionProcess = function ( action ) {
|
|
|
|
if ( action === 'switch-wte' ) {
|
2024-04-30 21:25:39 +00:00
|
|
|
return new OO.ui.Process( () => {
|
2016-04-28 21:08:26 +00:00
|
|
|
this.close( { action: 'switch-wte' } );
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2016-04-28 21:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parent method
|
|
|
|
return mw.libs.ve.WelcomeDialog.super.prototype.getActionProcess.call( this, action );
|
|
|
|
};
|