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-08-10 15:01:49 +00:00
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, {
|
|
|
|
data: part.getId()
|
|
|
|
} ) );
|
2021-07-09 14:47:01 +00:00
|
|
|
|
2021-08-27 16:22:37 +00:00
|
|
|
this.header = new ve.ui.MWTransclusionOutlineButtonWidget( config )
|
|
|
|
.connect( this, { click: [ 'emit', 'selectPart', part.getId() ] } );
|
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-08-27 16:22:37 +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 */
|
|
|
|
|
|
|
|
/**
|
2021-08-19 11:02:11 +00:00
|
|
|
* @event focusPart
|
|
|
|
* @param {string} partId Unique id of the part, e.g. something "part_1" or "part_1/param1".
|
2021-07-13 11:02:26 +00:00
|
|
|
*/
|
2021-08-27 16:22:37 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method, modelled after {@see OO.ui.OptionWidget}, but this isn't one.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.prototype.isSelected = function () {
|
|
|
|
return this.header.isSelected();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method, modelled after {@see OO.ui.OptionWidget}, but this isn't one.
|
|
|
|
*
|
|
|
|
* @param {boolean} state
|
|
|
|
*/
|
|
|
|
ve.ui.MWTransclusionOutlinePartWidget.prototype.setSelected = function ( state ) {
|
|
|
|
this.header
|
|
|
|
.setSelected( state )
|
|
|
|
.setFlags( { progressive: state } );
|
|
|
|
};
|