mediawiki-extensions-Visual.../modules/oojs-ui/OO.ui.Widget.js
Roan Kattouw 2ea9437e32 Get rid of OO.ui.extendObject and OO.ui.indexOf
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
2013-10-31 15:09:44 -07:00

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;
};