mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Streamline hide unused handling
Extracted the state change so we do not need the `internal` var. Change-Id: I0ce1afab35abf3e0e656ad1a3601513d55406537
This commit is contained in:
parent
4a8ca84ecc
commit
824648b32a
|
@ -42,22 +42,32 @@ OO.inheritClass( ve.ui.MWTransclusionOutlineToggleUnusedWidget, OO.ui.ButtonWidg
|
|||
* @fires toggleUnusedFields
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.onClick = function () {
|
||||
this.toggleUnusedParameters( !this.showUnusedFields, false, true );
|
||||
this.toggleUnusedParameters( !this.showUnusedFields, true );
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.setDisabled = function ( disabled ) {
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.super.prototype.setDisabled.call( this, disabled );
|
||||
this.toggleUnusedParameters( this.showUnusedFields, true );
|
||||
this.updateState( this.showUnusedFields );
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} showUnused
|
||||
* @param {boolean} [internal]
|
||||
* @param {boolean} [fromClick]
|
||||
* @fires toggleUnusedFields
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.toggleUnusedParameters = function ( showUnused, internal, fromClick ) {
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.toggleUnusedParameters = function ( showUnused, fromClick ) {
|
||||
if ( this.updateState( showUnused ) ) {
|
||||
this.emit( 'toggleUnusedFields', this.showUnusedFields, fromClick );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {boolean} showUnused
|
||||
* @return {boolean} Returns true when state changed.
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.updateState = function ( showUnused ) {
|
||||
showUnused = showUnused || this.isDisabled();
|
||||
if ( showUnused !== this.showUnusedFields ) {
|
||||
this.showUnusedFields = showUnused;
|
||||
|
@ -65,10 +75,9 @@ ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.toggleUnusedParameters =
|
|||
'visualeditor-dialog-transclusion-filter-hide-unused' :
|
||||
'visualeditor-dialog-transclusion-filter-show-all'
|
||||
) );
|
||||
if ( !internal ) {
|
||||
this.emit( 'toggleUnusedFields', this.showUnusedFields, fromClick );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue