Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/dialogs/ve.ui.FragmentDialog.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface FragmentDialog class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Dialog for working with fragments of content.
9 *
10 * @class
11 * @abstract
12 * @extends OO.ui.ProcessDialog
13 * @mixes ve.ui.FragmentWindow
14 *
15 * @constructor
16 * @param {Object} [config] Configuration options
17 */
18 ve.ui.FragmentDialog = function VeUiFragmentDialog( config ) {
19 // Parent constructor
20 ve.ui.FragmentDialog.super.call( this, config );
21
22 // Mixin constructor
23 ve.ui.FragmentWindow.call( this, config );
24 };
25
26 /* Inheritance */
27
28 OO.inheritClass( ve.ui.FragmentDialog, OO.ui.ProcessDialog );
29
30 OO.mixinClass( ve.ui.FragmentDialog, ve.ui.FragmentWindow );
31
32 /* Static Properties */
33
34 ve.ui.FragmentDialog.static.actions = [
35 {
36 label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
37 flags: [ 'safe', 'close' ],
38 modes: [ 'readonly', 'edit', 'insert' ]
39 },
40 {
41 action: 'done',
42 label: OO.ui.deferMsg( 'visualeditor-dialog-action-apply' ),
43 flags: [ 'progressive', 'primary' ],
44 modes: 'edit'
45 },
46 {
47 action: 'done',
48 label: OO.ui.deferMsg( 'visualeditor-dialog-action-insert' ),
49 flags: [ 'progressive', 'primary' ],
50 modes: 'insert'
51 }
52 // The message visualeditor-dialog-action-goback is also available
53 // but currently only used in ve-mw.
54 ];
55
56 /* Methods */
57
58 /**
59 * @inheritdoc
60 */
61 ve.ui.FragmentDialog.prototype.initialize = function ( data ) {
62 // Parent method
63 ve.ui.FragmentDialog.super.prototype.initialize.call( this, data );
64
65 this.tabIndexScope = new ve.ui.TabIndexScope( {
66 root: this.$content
67 } );
68 };
69
70 /**
71 * @inheritdoc
72 */
73 ve.ui.FragmentDialog.prototype.getActionWidgetConfig = function ( config ) {
74 // Mixin method
75 config = ve.ui.FragmentWindow.prototype.getActionWidgetConfig.call( this, config );
76 // Parent method
77 return ve.ui.FragmentDialog.super.prototype.getActionWidgetConfig.call( this, config );
78 };
79
80 /**
81 * @inheritdoc
82 */
83 ve.ui.FragmentDialog.prototype.getSetupProcess = function ( data ) {
84 // Parent method
85 const process = ve.ui.FragmentDialog.super.prototype.getSetupProcess.call( this, data );
86 // Mixin method
87 return ve.ui.FragmentWindow.prototype.getSetupProcess.call( this, data, process );
88 };
89
90 /**
91 * @inheritdoc
92 */
93 ve.ui.FragmentDialog.prototype.getTeardownProcess = function ( data ) {
94 // Parent method
95 const process = ve.ui.FragmentDialog.super.prototype.getTeardownProcess.call( this, data )
96 .first( () => {
97 if ( this.selectFragmentOnClose ) {
98 this.fragment.select();
99 }
100 } );
101 // Mixin method
102 return ve.ui.FragmentWindow.prototype.getTeardownProcess.call( this, data, process );
103 };