Remove unused code from ve.ui.MWTransclusionOutlinePartWidget

* 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
This commit is contained in:
Thiemo Kreuz 2021-08-10 17:01:49 +02:00 committed by Thiemo Kreuz (WMDE)
parent 7503b323b1
commit 095c891040
2 changed files with 9 additions and 20 deletions

View file

@ -110,7 +110,7 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.addPartWidget = function (
widget = new ve.ui.MWTransclusionOutlineWikitextWidget( part );
}
widget.connect( this, { partHeaderClick: 'focusPart' } );
widget.connect( this, { headerClick: 'focusPart' } );
this.partWidgets[ part.getId() ] = widget;
if ( typeof newPosition === 'number' && newPosition < this.$element.children().length ) {

View file

@ -20,20 +20,16 @@
*/
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
// Parent constructor
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, config );
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, {
data: part.getId()
} ) );
// FIXME: Use config.data and OO.ui.Element.getData() instead?
// Warning, there is already config.id and this.elementId!
this.partId = part.getId();
this.header = new ve.ui.MWTransclusionOutlineButtonWidget( config )
var header = new ve.ui.MWTransclusionOutlineButtonWidget( config )
.connect( this, { click: 'onHeaderClick' } );
this.$element
.addClass( 've-ui-mwTransclusionOutlinePartWidget' )
// Note: There is no code that uses this. It just helps when manually inspecting the HTML.
.attr( 'data-transclusion-part-id', part.getId() )
.append( this.header.$element );
.append( header.$element );
};
/* Inheritance */
@ -43,20 +39,13 @@ OO.inheritClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.Widget );
/* Events */
/**
* @event partHeaderClick
* @event headerClick
* @param {string} partId
*/
/**
* @return {string} Identifier of the {@see ve.dm.MWTransclusionPartModel} this widget represents
*/
ve.ui.MWTransclusionOutlinePartWidget.prototype.getPartId = function () {
return this.partId;
};
/**
* @fires partHeaderClick
* @fires headerClick
*/
ve.ui.MWTransclusionOutlinePartWidget.prototype.onHeaderClick = function () {
this.emit( 'partHeaderClick', this.partId );
this.emit( 'headerClick', this.data );
};