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

75% Statements 18/24
14.28% Branches 1/7
50% Functions 2/4
75% Lines 18/24

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                                1x   2x     2x         2x         1x       1x   1x                 1x             1x   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';
 
ve.ui.ToolbarDialog.static.padded = 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} Toolbar position
 */
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' );
	}
	// 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 );
};