All files / src/ui/dialogs ve.ui.ToolbarDialog.js

77.77% Statements 21/27
22.22% Branches 2/9
50% Functions 2/4
77.77% Lines 21/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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