Debian Codegraph @

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

raw symbols SCIP
1 /*!
2 * VisualEditor user interface MWWelcomeDialog 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 welcoming new users.
11 *
12 * @class
13 * @extends OO.ui.MessageDialog
14 *
15 * @constructor
16 * @param {Object} [config] Configuration options
17 */
18 mw.libs.ve.WelcomeDialog = function VeInitWelcomeDialog( config ) {
19 // Parent constructor
20 mw.libs.ve.WelcomeDialog.super.call( this, config );
21
22 this.$element
23 .addClass( 've-init-mw-welcomeDialog' );
24 };
25
26 /* Inheritance */
27
28 OO.inheritClass( mw.libs.ve.WelcomeDialog, OO.ui.MessageDialog );
29
30 /* Static Properties */
31
32 mw.libs.ve.WelcomeDialog.static.name = 'welcome';
33
34 mw.libs.ve.WelcomeDialog.static.size = 'medium';
35
36 mw.libs.ve.WelcomeDialog.static.actions = [
37 {
38 action: 'switch-wte',
39 label: OO.ui.deferMsg( 'visualeditor-welcomedialog-switch' ),
40 modes: [ 'visual' ]
41 },
42 {
43 action: 'switch-ve',
44 label: OO.ui.deferMsg( 'visualeditor-welcomedialog-switch-ve' ),
45 modes: [ 'source' ]
46 },
47 {
48 action: 'accept',
49 label: OO.ui.deferMsg( 'visualeditor-welcomedialog-action' ),
50 flags: [ 'progressive', 'primary' ],
51 modes: [ 'visual', 'source', 'noswitch' ]
52 }
53 ];
54
55 /**
56 * @inheritdoc
57 */
58 mw.libs.ve.WelcomeDialog.prototype.getSetupProcess = function ( data ) {
59 // Provide default title and message
60 data = $.extend( {
61 title: mw.msg( 'visualeditor-welcomedialog-title', mw.user, mw.config.get( 'wgSiteName' ) ),
62 message: $( '<span>' )
63 .addClass( 've-init-mw-welcomeDialog-content' )
64 .append(
65 $( document.createTextNode( mw.msg( 'visualeditor-welcomedialog-content' ) ) ),
66 $( '<br>' ),
67 $( document.createTextNode( mw.msg( 'visualeditor-welcomedialog-content-thanks' ) ) )
68 )
69 }, data );
70
71 return mw.libs.ve.WelcomeDialog.super.prototype.getSetupProcess.call( this, data )
72 .next( () => {
73 this.switchable = data.switchable;
74 this.editor = data.editor;
75
76 this.actions.setMode( this.switchable ? this.editor : 'noswitch' );
77 } );
78 };
79
80 /**
81 * @inheritdoc
82 */
83 mw.libs.ve.WelcomeDialog.prototype.getActionProcess = function ( action ) {
84 if ( action === 'switch-wte' ) {
85 return new OO.ui.Process( () => {
86 this.close( { action: 'switch-wte' } );
87 } );
88 }
89
90 // Parent method
91 return mw.libs.ve.WelcomeDialog.super.prototype.getActionProcess.call( this, action );
92 };