mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-14 10:04:52 +00:00
Merge "Optimize .selectPartById() to fire less events"
This commit is contained in:
commit
3b78f40e7a
|
@ -153,10 +153,17 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.addPartWidget = function (
|
|||
* parameter ids like "part_1/param1".
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineContainerWidget.prototype.selectPartById = function ( partId ) {
|
||||
var changed = false;
|
||||
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