2021-07-09 13:48:08 +00:00
|
|
|
/**
|
|
|
|
* 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}
|
|
|
|
*
|
2021-07-09 14:47:01 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2021-07-09 13:48:08 +00:00
|
|
|
* @abstract
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.Widget
|
|
|
|
*
|
|
|
|
* @constructor
|
2021-07-13 07:27:22 +00:00
|
|
|
* @param {ve.dm.MWTransclusionPartModel} part
|
2021-07-13 09:00:57 +00:00
|
|
|
* @param {Object} config
|
2021-07-09 14:47:01 +00:00
|
|
|
* @cfg {string} [icon='']
|
2021-07-13 09:00:57 +00:00
|
|
|
* @cfg {string} label
|
2021-07-09 13:48:08 +00:00
|
|
|
*/
|
2021-07-13 07:27:22 +00:00
|
|
|
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
|
2021-07-09 13:48:08 +00:00
|
|
|
// Parent constructor
|
2021-07-09 15:04:14 +00:00
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, config );
|
2021-07-09 14:47:01 +00:00
|
|
|
|
2021-07-13 19:01:30 +00:00
|
|
|
// FIXME: Use config.data and OO.ui.Element.getData() instead?
|
|
|
|
// Warning, there is already config.id and this.elementId!
|
|
|
|
this.partId = part.getId();
|
2021-07-13 07:27:22 +00:00
|
|
|
|
2021-07-13 11:02:26 +00:00
|
|
|
this.header = new ve.ui.MWTransclusionOutlineButtonWidget( config )
|
|
|
|
.connect( this, { click: 'onHeaderClick' } );
|
2021-07-13 09:00:57 +00:00
|
|
|
|
2021-07-09 14:47:01 +00:00
|
|
|
this.$element
|
2021-07-09 15:04:14 +00:00
|
|
|
.addClass( 've-ui-mwTransclusionOutlinePartWidget' )
|
2021-07-13 07:27:22 +00:00
|
|
|
// Note: There is no code that uses this. It just helps when manually inspecting the HTML.
|
|
|
|
.attr( 'data-transclusion-part-id', part.getId() )
|
2021-07-13 11:02:26 +00:00
|
|
|
.append( this.header.$element );
|
2021-07-09 13:48:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2021-07-09 15:04:14 +00:00
|
|
|
OO.inheritClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.Widget );
|
2021-07-13 07:27:22 +00:00
|
|
|
|
2021-07-13 11:02:26 +00:00
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @event partHeaderClick
|
|
|
|
* @param {string} partId
|
|
|
|
*/
|
|
|
|
|
2021-07-13 07:27:22 +00:00
|
|
|
/**
|
|
|
|
* @return {string} Identifier of the {@see ve.dm.MWTransclusionPartModel} this widget represents
|
|
|
|
*/
|
2021-07-13 19:01:30 +00:00
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.prototype.getPartId = function () {
|
|
|
|
return this.partId;
|
2021-07-13 07:27:22 +00:00
|
|
|
};
|
2021-07-13 11:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fires partHeaderClick
|
|
|
|
*/
|
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.prototype.onHeaderClick = function () {
|
2021-07-13 19:01:30 +00:00
|
|
|
this.emit( 'partHeaderClick', this.partId );
|
2021-07-13 11:02:26 +00:00
|
|
|
};
|