Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/preinit/ve.init.MWEditingTabDialog.js

raw symbols SCIP
1 /*!
2 * VisualEditor user interface MWEditingTabDialog class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 mw.libs.ve = mw.libs.ve || {};
9 /**
10 * Dialog for allowing new users to change editing tab preferences.
11 *
12 * @class
13 * @extends OO.ui.MessageDialog
14 *
15 * @constructor
16 * @param {Object} [config] Configuration options
17 */
18 mw.libs.ve.EditingTabDialog = function MWLibsVEMWEditingTabDialog( config ) {
19 // Parent constructor
20 mw.libs.ve.EditingTabDialog.super.call( this, config );
21 };
22
23 /* Inheritance */
24
25 OO.inheritClass( mw.libs.ve.EditingTabDialog, OO.ui.MessageDialog );
26
27 /* Static Properties */
28
29 mw.libs.ve.EditingTabDialog.static.name = 'editingtab';
30
31 mw.libs.ve.EditingTabDialog.static.size = 'medium';
32
33 mw.libs.ve.EditingTabDialog.static.title = mw.msg( 'visualeditor-editingtabdialog-title' );
34
35 mw.libs.ve.EditingTabDialog.static.message = mw.msg( 'visualeditor-editingtabdialog-body' );
36
37 mw.libs.ve.EditingTabDialog.static.actions = [
38
39 {
40 action: 'prefer-wt',
41 label: mw.msg( 'visualeditor-preference-tabs-prefer-wt' )
42 },
43 {
44 action: 'prefer-ve',
45 label: mw.msg( 'visualeditor-preference-tabs-prefer-ve' )
46 },
47 {
48 action: 'multi-tab',
49 label: mw.msg( 'visualeditor-preference-tabs-multi-tab' )
50 },
51 {
52 label: mw.msg( 'visualeditor-editingtabdialog-ok' ),
53 flags: [ 'progressive', 'primary' ]
54 }
55 ];
56
57 /* Methods */
58
59 /**
60 * @inheritdoc
61 */
62 mw.libs.ve.EditingTabDialog.prototype.getSetupProcess = function ( action ) {
63 return mw.libs.ve.EditingTabDialog.super.prototype.getSetupProcess.call( this, action )
64 .next( () => {
65 // Same as ve.init.target.getLocalApi()
66 new mw.Api().saveOption( 'visualeditor-hidetabdialog', 1 );
67 mw.user.options.set( 'visualeditor-hidetabdialog', 1 );
68 } );
69 };
70
71 /**
72 * @inheritdoc
73 */
74 mw.libs.ve.EditingTabDialog.prototype.getActionProcess = function ( action ) {
75 if ( action ) {
76 return new OO.ui.Process( () => {
77 const actionWidget = this.getActions().get( { actions: action } )[ 0 ];
78 actionWidget.pushPending();
79 this.pushPending();
80
81 // Same as ve.init.target.getLocalApi()
82 new mw.Api().saveOption( 'visualeditor-tabs', action ).done( () => {
83 actionWidget.popPending();
84 mw.user.options.set( 'visualeditor-tabs', action );
85 this.close( { action: action } );
86 } );
87 } );
88 } else {
89 // Parent method
90 return mw.libs.ve.EditingTabDialog.super.prototype.getActionProcess.call( this, action );
91 }
92 };