From 095c891040d60c6dfebc3f8d6634e2b87b551441 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Tue, 10 Aug 2021 17:01:49 +0200 Subject: [PATCH] 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 --- ...ui.MWTransclusionOutlineContainerWidget.js | 2 +- .../ve.ui.MWTransclusionOutlinePartWidget.js | 27 ++++++------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js index a10a255647..1a4695493c 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js @@ -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 ) { diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js index 14d8a9be2e..84f53de709 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js @@ -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 ); };