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

80.95% Statements 17/21
25% Branches 1/4
66.67% Functions 2/3
80.95% Lines 17/21
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                                                                                                                               
/*!
 * VisualEditor UserInterface ToolbarDialog class.
 *
 * @copyright 2011-2019 VisualEditor Team and others; see http://ve.mit-license.org
 */
 
/**
 * 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;
	this.$shield = $( '<div>' ).addClass( 've-ui-toolbarDialog-shield' );
 
	// 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' or 'side' (right in LTR)
 *
 * @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.$body.append( this.$shield );
	this.$content.addClass( 've-ui-toolbarDialog-content' );
	this.$element.addClass( 've-ui-toolbarDialog-position-' + this.constructor.static.position );
	Eif ( this.constructor.static.padded ) {
		this.$element.addClass( 've-ui-toolbarDialog-padded' );
	}
};
 
/**
 * 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
			// Make sure shield is last child
			.append( this.$shield )
			.toggleClass( 've-ui-toolbarDialog-disabled', this.disabled );
	}
};