mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
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:
parent
c00d8d6bb1
commit
341138b16b
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue