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
|
* @constructor
|
||||||
* @param {Object} [config] Configuration options
|
* @param {Object} [config] Configuration options
|
||||||
* @cfg {Function} [$$] jQuery for the frame the widget is in
|
* @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 ) {
|
OO.ui.Element = function OoUiElement( config ) {
|
||||||
// Initialize config
|
// Configuration initialization
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
this.$$ = config.$$ || OO.ui.Element.get$$( document );
|
this.$$ = config.$$ || OO.ui.Element.get$$( document );
|
||||||
this.$ = this.$$( this.$$.context.createElement( this.getTagName() ) );
|
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 */
|
/* Static Properties */
|
||||||
|
|
Loading…
Reference in a new issue