Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/dialogs/ve.ui.MWFloatingHelpDialog.js

raw symbols SCIP
1 /*!
2 * VisualEditor user interface MWFloatingHelpDialog class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Popup help dialog launched by a {@see ve.ui.MWFloatingHelpElement}
10 *
11 * @class
12 * @extends OO.ui.ProcessDialog
13 *
14 * @constructor
15 * @param {Object} [config] Configuration options
16 * @param {string} config.label
17 * @param {jQuery} config.$message
18 */
19 ve.ui.MWFloatingHelpDialog = function VeUiMWFloatingHelpDialog( config ) {
20 // Parent constructor
21 ve.ui.MWFloatingHelpDialog.super.call( this, config );
22
23 this.label = config.label;
24 this.$message = config.$message;
25 };
26
27 /* Inheritance */
28
29 OO.inheritClass( ve.ui.MWFloatingHelpDialog, OO.ui.ProcessDialog );
30
31 /* Static properties */
32
33 ve.ui.MWFloatingHelpDialog.static.name = 'floatingHelp';
34
35 ve.ui.MWFloatingHelpDialog.static.actions = [
36 {
37 label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
38 flags: [ 'safe', 'close' ]
39 }
40 ];
41
42 /* Methods */
43
44 /**
45 * @inheritdoc
46 */
47 ve.ui.MWFloatingHelpDialog.prototype.initialize = function () {
48 ve.ui.MWFloatingHelpDialog.super.prototype.initialize.call( this );
49 const content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
50 content.$element.append( this.$message );
51 this.$body.append( content.$element );
52 this.$foot.remove();
53 };
54
55 /**
56 * @inheritdoc
57 */
58 ve.ui.MWFloatingHelpDialog.prototype.getSetupProcess = function ( data ) {
59 return ve.ui.MWFloatingHelpDialog.super.prototype.getSetupProcess.call( this, data ).next( () => {
60 this.title.setLabel( this.label );
61 } );
62 };
63
64 ve.ui.MWFloatingHelpDialog.prototype.getSizeProperties = function () {
65 const sizeProps = ve.ui.MWFloatingHelpDialog.super.prototype.getSizeProperties.call( this );
66 if ( !OO.ui.isMobile() ) {
67 return ve.extendObject( {}, sizeProps, { width: '350px', maxHeight: '50%' } );
68 }
69 return sizeProps;
70 };