mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-26 15:21:51 +00:00
2ea9437e32
Replaced uses of extendObject with $.extend . Replaced the one use of OO.ui.indexOf with Array.prototype.indexOf because that's what everything else was already using. Change-Id: I63f40989057b8065ec977efafbf68d6e22c8e679
74 lines
1.5 KiB
JavaScript
74 lines
1.5 KiB
JavaScript
/*!
|
|
* ObjectOriented UserInterface Widget class.
|
|
*
|
|
* @copyright 2011-2013 OOJS Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* User interface control.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @extends OO.ui.Element
|
|
* @mixin OO.EventEmitter
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
* @cfg {boolean} [disabled=false] Disable
|
|
*/
|
|
OO.ui.Widget = function OoUiWidget( config ) {
|
|
// Initialize config
|
|
config = $.extend( { 'disabled': false }, config );
|
|
|
|
// Parent constructor
|
|
OO.ui.Element.call( this, config );
|
|
|
|
// Mixin constructors
|
|
OO.EventEmitter.call( this );
|
|
|
|
// Properties
|
|
this.disabled = config.disabled;
|
|
|
|
// Initialization
|
|
this.$.addClass( 'oo-ui-widget' );
|
|
this.setDisabled( this.disabled );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( OO.ui.Widget, OO.ui.Element );
|
|
|
|
OO.mixinClass( OO.ui.Widget, OO.EventEmitter );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Check if the widget is disabled.
|
|
*
|
|
* @method
|
|
* @param {boolean} Button is disabled
|
|
*/
|
|
OO.ui.Widget.prototype.isDisabled = function () {
|
|
return this.disabled;
|
|
};
|
|
|
|
/**
|
|
* Set the disabled state of the widget.
|
|
*
|
|
* This should probably change the widgets's appearance and prevent it from being used.
|
|
*
|
|
* @method
|
|
* @param {boolean} disabled Disable button
|
|
* @chainable
|
|
*/
|
|
OO.ui.Widget.prototype.setDisabled = function ( disabled ) {
|
|
this.disabled = !!disabled;
|
|
if ( this.disabled ) {
|
|
this.$.addClass( 'oo-ui-widget-disabled' );
|
|
} else {
|
|
this.$.removeClass( 'oo-ui-widget-disabled' );
|
|
}
|
|
return this;
|
|
};
|