File: ve.init.MWEditingTabDialog.js

package info (click to toggle)
mediawiki 1%3A1.35.13-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 274,932 kB
  • sloc: php: 677,563; javascript: 572,709; sql: 11,565; python: 4,447; xml: 3,145; sh: 892; perl: 788; ruby: 496; pascal: 365; makefile: 128
file content (94 lines) | stat: -rw-r--r-- 2,499 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*!
 * VisualEditor user interface MWEditingTabDialog class.
 *
 * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

mw.libs.ve = mw.libs.ve || {};
/**
 * Dialog for allowing new users to change editing tab preferences.
 *
 * @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';

mw.libs.ve.EditingTabDialog.static.size = 'medium';

mw.libs.ve.EditingTabDialog.static.title = mw.msg( 'visualeditor-editingtabdialog-title' );

mw.libs.ve.EditingTabDialog.static.message = mw.msg( 'visualeditor-editingtabdialog-body' );

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 )
		.next( function () {
			// Same as ve.init.target.getLocalApi()
			new mw.Api().saveOption( 'visualeditor-hidetabdialog', 1 );
			mw.user.options.set( 'visualeditor-hidetabdialog', 1 );
		} );
};

/**
 * @inheritdoc
 */
mw.libs.ve.EditingTabDialog.prototype.getActionProcess = function ( action ) {
	var dialog = this,
		act = action;
	if ( act ) {
		return new OO.ui.Process( function () {
			var action = this.getActions().get( { actions: act } )[ 0 ];
			action.pushPending();
			dialog.pushPending();

			// Same as ve.init.target.getLocalApi()
			new mw.Api().saveOption( 'visualeditor-tabs', act ).done( function () {
				action.popPending();
				mw.user.options.set( 'visualeditor-tabs', act );
				dialog.close( { action: act } );
			} );
		}, this );
	} else {
		// Parent method
		return mw.libs.ve.EditingTabDialog.super.prototype.getActionProcess.call( this, action );
	}
};