Debian Codegraph @

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

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface ToolbarDialog class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Toolbar dialog.
9 *
10 * @class
11 * @abstract
12 * @extends OO.ui.Dialog
13 *
14 * @constructor
15 * @param {Object} [config] Configuration options
16 */
17 ve.ui.ToolbarDialog = function VeUiToolbarDialog( config ) {
18 // Parent constructor
19 ve.ui.ToolbarDialog.super.call( this, config );
20
21 // Properties
22 this.disabled = false;
23
24 // Pre-initialization
25 // This class needs to exist before setup to constrain the height
26 // of the dialog when it first loads.
27 this.$element.addClass( 've-ui-toolbarDialog' );
28 };
29
30 /* Inheritance */
31
32 OO.inheritClass( ve.ui.ToolbarDialog, OO.ui.Dialog );
33
34 /* Static Properties */
35
36 ve.ui.ToolbarDialog.static.size = 'full';
37
38 /**
39 * The dialog is padded
40 *
41 * @static
42 * @type {boolean}
43 */
44 ve.ui.ToolbarDialog.static.padded = true;
45
46 /**
47 * The dialog has a frame border, for use with position='side'
48 *
49 * @static
50 * @type {boolean}
51 */
52 ve.ui.ToolbarDialog.static.framed = true;
53
54 /**
55 * Toolbar position, either 'above', 'side' (right in LTR), 'below' or 'inline'
56 * For 'inline' the caller will be manually positioning the dialog.
57 *
58 * @static
59 * @type {string}
60 */
61 ve.ui.ToolbarDialog.static.position = 'above';
62
63 /* Methods */
64
65 /**
66 * @inheritdoc
67 */
68 ve.ui.ToolbarDialog.prototype.initialize = function () {
69 // Parent method
70 ve.ui.ToolbarDialog.super.prototype.initialize.call( this );
71
72 this.$content.addClass( 've-ui-toolbarDialog-content' );
73 // The following classes are used here:
74 // * ve-ui-toolbarDialog-position-above
75 // * ve-ui-toolbarDialog-position-side
76 // * ve-ui-toolbarDialog-position-below
77 // * ve-ui-toolbarDialog-position-inline
78 this.$element.addClass( 've-ui-toolbarDialog-position-' + this.constructor.static.position );
79 if ( this.constructor.static.padded ) {
80 this.$element.addClass( 've-ui-toolbarDialog-padded' );
81 }
82 if ( this.constructor.static.framed ) {
83 this.$element.addClass( 've-ui-toolbarDialog-framed' );
84 }
85 // Invisible title for accessibility
86 this.title.setInvisibleLabel( true );
87 this.$element.prepend( this.title.$element );
88 };
89
90 /**
91 * Set the disabled state of the toolbar dialog
92 *
93 * @param {boolean} disabled Disable the dialog
94 */
95 ve.ui.ToolbarDialog.prototype.setDisabled = function ( disabled ) {
96 this.$content.addClass( 've-ui-toolbarDialog-content' );
97 if ( disabled !== this.disabled ) {
98 this.disabled = disabled;
99 this.$body.toggleClass( 've-ui-toolbarDialog-disabled', this.disabled );
100 }
101 };
102
103 /**
104 * @inheritdoc
105 */
106 ve.ui.ToolbarDialog.prototype.getTeardownProcess = function ( data ) {
107 ve.track( 'activity.' + this.constructor.static.name, { action: 'dialog-' + ( data && data.action || 'abort' ) } );
108 return ve.ui.ToolbarDialog.super.prototype.getTeardownProcess.apply( this, arguments );
109 };