Merge "MWCategoryWidget: Implement setDisabled"

This commit is contained in:
jenkins-bot 2019-02-25 23:05:23 +00:00 committed by Gerrit Code Review
commit 99351fa20a
2 changed files with 29 additions and 6 deletions

View file

@ -49,6 +49,9 @@ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
ve.init.platform.linkCache.styleElement( this.name, this.$label );
}
// Events
this.on( 'click', this.onButtonClick.bind( this ) );
this.$element.addClass( 've-ui-mwCategoryItemWidget' );
};
@ -68,15 +71,11 @@ OO.mixinClass( ve.ui.MWCategoryItemWidget, OO.ui.mixin.DraggableElement );
/* Methods */
/**
* Handle mouse click events.
* Handle button widget click events.
*
* @method
* @param {jQuery.Event} e Mouse click event
* @fires togglePopupMenu on click.
*/
ve.ui.MWCategoryItemWidget.prototype.onClick = function () {
ve.ui.MWCategoryItemWidget.prototype.onButtonClick = function () {
this.emit( 'togglePopupMenu', this );
// Parent method
return ve.ui.MWCategoryItemWidget.super.prototype.onClick.apply( this, arguments );
};

View file

@ -230,6 +230,29 @@ ve.ui.MWCategoryWidget.prototype.setDefaultSortKey = function ( value ) {
this.popup.setDefaultSortKey( value );
};
/**
* @inheritdoc
*/
ve.ui.MWCategoryWidget.prototype.setDisabled = function () {
var isDisabled;
// Parent method
ve.ui.MWCategoryWidget.super.prototype.setDisabled.apply( this, arguments );
isDisabled = this.isDisabled();
if ( this.input ) {
this.input.setDisabled( isDisabled );
}
if ( this.items ) {
this.items.forEach( function ( item ) {
item.setDisabled( isDisabled );
} );
}
if ( this.popup ) {
this.popup.closePopup();
}
};
/**
* Get list of category names.
*
@ -362,6 +385,7 @@ ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
}
config.hidden = cachedData.hidden;
config.missing = cachedData.missing;
config.disabled = widget.disabled;
categoryItem = new ve.ui.MWCategoryItemWidget( config );
categoryItem.connect( widget, {