mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-05 03:08:37 +00:00
095c891040
* getPartId() is unused. * Use this.data instead of a custom this.partId. * No need to store this.header as a property. * Rename the event to "headerClick". That's enough when the event comes from a widget that does have the word "part" in it's name. Bug: T274544 Bug: T288827 Change-Id: I8c70425403c6cd6a19e3a1cacb2b085e5c8b2e46
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
/**
|
|
* Common base class for top-level items (a.k.a. "parts") in the template editor sidebar. Subclasses
|
|
* should exist for all subclasses of {@see ve.dm.MWTransclusionPartModel}:
|
|
* - {@see ve.dm.MWTemplateModel}
|
|
* - {@see ve.dm.MWTemplatePlaceholderModel}
|
|
* - {@see ve.dm.MWTransclusionContentModel}
|
|
*
|
|
* This is inspired by and meant to replace {@see OO.ui.DecoratedOptionWidget} in the context of the
|
|
* template dialog. Also see {@see OO.ui.ButtonWidget} for inspiration.
|
|
*
|
|
* @abstract
|
|
* @class
|
|
* @extends OO.ui.Widget
|
|
*
|
|
* @constructor
|
|
* @param {ve.dm.MWTransclusionPartModel} part
|
|
* @param {Object} config
|
|
* @cfg {string} [icon='']
|
|
* @cfg {string} label
|
|
*/
|
|
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
|
|
// Parent constructor
|
|
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, {
|
|
data: part.getId()
|
|
} ) );
|
|
|
|
var header = new ve.ui.MWTransclusionOutlineButtonWidget( config )
|
|
.connect( this, { click: 'onHeaderClick' } );
|
|
|
|
this.$element
|
|
.addClass( 've-ui-mwTransclusionOutlinePartWidget' )
|
|
.append( header.$element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.Widget );
|
|
|
|
/* Events */
|
|
|
|
/**
|
|
* @event headerClick
|
|
* @param {string} partId
|
|
*/
|
|
|
|
/**
|
|
* @fires headerClick
|
|
*/
|
|
ve.ui.MWTransclusionOutlinePartWidget.prototype.onHeaderClick = function () {
|
|
this.emit( 'headerClick', this.data );
|
|
};
|