2015-10-23 16:29:56 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWEditingTabDialog class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2015-10-23 16:29:56 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
mw.libs.ve = mw.libs.ve || {};
|
|
|
|
/**
|
2016-04-28 21:08:26 +00:00
|
|
|
* Dialog for allowing new users to change editing tab preferences.
|
2015-10-23 16:29:56 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.MessageDialog
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
mw.libs.ve.EditingTabDialog = function MWLibsVEMWEditingTabDialog( config ) {
|
|
|
|
// Parent constructor
|
|
|
|
mw.libs.ve.EditingTabDialog.super.call( this, config );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( mw.libs.ve.EditingTabDialog, OO.ui.MessageDialog );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
mw.libs.ve.EditingTabDialog.static.name = 'editingtab';
|
|
|
|
|
2016-06-30 12:43:58 +00:00
|
|
|
mw.libs.ve.EditingTabDialog.static.size = 'medium';
|
2015-10-23 16:29:56 +00:00
|
|
|
|
|
|
|
mw.libs.ve.EditingTabDialog.static.title = mw.msg( 'visualeditor-editingtabdialog-title' );
|
|
|
|
|
2016-04-13 21:46:14 +00:00
|
|
|
mw.libs.ve.EditingTabDialog.static.message = mw.msg( 'visualeditor-editingtabdialog-body' );
|
|
|
|
|
2015-10-23 16:29:56 +00:00
|
|
|
mw.libs.ve.EditingTabDialog.static.actions = [
|
|
|
|
|
|
|
|
{
|
|
|
|
action: 'prefer-wt',
|
|
|
|
label: mw.msg( 'visualeditor-preference-tabs-prefer-wt' )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
action: 'prefer-ve',
|
|
|
|
label: mw.msg( 'visualeditor-preference-tabs-prefer-ve' )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
action: 'multi-tab',
|
|
|
|
label: mw.msg( 'visualeditor-preference-tabs-multi-tab' )
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: mw.msg( 'visualeditor-editingtabdialog-ok' ),
|
|
|
|
flags: [ 'progressive', 'primary' ]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mw.libs.ve.EditingTabDialog.prototype.getSetupProcess = function ( action ) {
|
|
|
|
return mw.libs.ve.EditingTabDialog.super.prototype.getSetupProcess.call( this, action )
|
2024-04-30 16:44:25 +00:00
|
|
|
.next( () => {
|
2019-07-22 19:31:00 +00:00
|
|
|
// Same as ve.init.target.getLocalApi()
|
|
|
|
new mw.Api().saveOption( 'visualeditor-hidetabdialog', 1 );
|
2015-10-23 16:29:56 +00:00
|
|
|
mw.user.options.set( 'visualeditor-hidetabdialog', 1 );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mw.libs.ve.EditingTabDialog.prototype.getActionProcess = function ( action ) {
|
2020-08-18 12:16:49 +00:00
|
|
|
var dialog = this;
|
|
|
|
if ( action ) {
|
2024-04-30 21:25:39 +00:00
|
|
|
return new OO.ui.Process( () => {
|
2020-08-18 12:16:49 +00:00
|
|
|
var actionWidget = this.getActions().get( { actions: action } )[ 0 ];
|
|
|
|
actionWidget.pushPending();
|
2016-04-04 16:33:40 +00:00
|
|
|
dialog.pushPending();
|
|
|
|
|
2019-07-22 19:31:00 +00:00
|
|
|
// Same as ve.init.target.getLocalApi()
|
2024-04-30 16:44:25 +00:00
|
|
|
new mw.Api().saveOption( 'visualeditor-tabs', action ).done( () => {
|
2020-08-18 12:16:49 +00:00
|
|
|
actionWidget.popPending();
|
|
|
|
mw.user.options.set( 'visualeditor-tabs', action );
|
|
|
|
dialog.close( { action: action } );
|
2016-04-04 16:33:40 +00:00
|
|
|
} );
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2015-10-23 16:29:56 +00:00
|
|
|
} else {
|
|
|
|
// Parent method
|
|
|
|
return mw.libs.ve.EditingTabDialog.super.prototype.getActionProcess.call( this, action );
|
|
|
|
}
|
|
|
|
};
|