Add 'classes' and '$content' config options to OO.ui.Element

Makes it easier to setup elements in a single call.

Change-Id: I6aba6ca121972b984401d845d0e7253049c490e4
This commit is contained in:
Trevor Parscal 2013-10-30 14:05:49 -07:00 committed by Roan Kattouw
parent c00d8d6bb1
commit 341138b16b

View file

@ -14,13 +14,24 @@
* @constructor
* @param {Object} [config] Configuration options
* @cfg {Function} [$$] jQuery for the frame the widget is in
* @cfg {string[]} [classes] CSS class names
* @cfg {jQuery} [$content] Content elements to append
*/
OO.ui.Element = function OoUiElement( config ) {
// Initialize config
// Configuration initialization
config = config || {};
// Properties
this.$$ = config.$$ || OO.ui.Element.get$$( document );
this.$ = this.$$( this.$$.context.createElement( this.getTagName() ) );
// Initialization
if ( Array.isArray( config.classes ) ) {
this.$.addClass( config.classes.join( ' ' ) );
}
if ( config.$content ) {
this.$.append( config.$content );
}
};
/* Static Properties */