mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
Optimize .selectPartById() to fire less events
There is no point in firing this event when noting changed. This should reduce flickering and some of the issues described in I97d77f4. Change-Id: I7c387889a4a33dac5053cec11a0641d358020b56
This commit is contained in:
parent
844606d573
commit
e62b3fecbb
|
@ -153,10 +153,17 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.addPartWidget = function (
|
||||||
* parameter ids like "part_1/param1".
|
* parameter ids like "part_1/param1".
|
||||||
*/
|
*/
|
||||||
ve.ui.MWTransclusionOutlineContainerWidget.prototype.selectPartById = function ( partId ) {
|
ve.ui.MWTransclusionOutlineContainerWidget.prototype.selectPartById = function ( partId ) {
|
||||||
|
var changed = false;
|
||||||
for ( var id in this.partWidgets ) {
|
for ( var id in this.partWidgets ) {
|
||||||
this.partWidgets[ id ].setSelected( id === partId );
|
var selected = id === partId;
|
||||||
|
if ( this.partWidgets[ id ].isSelected() !== selected ) {
|
||||||
|
this.partWidgets[ id ].setSelected( selected );
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ( changed ) {
|
||||||
this.emit( 'updateOutlineControlButtons', partId );
|
this.emit( 'updateOutlineControlButtons', partId );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue