diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryItemWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryItemWidget.js index b030a31c6e..56224e20e9 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryItemWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryItemWidget.js @@ -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 ); }; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js index f92d448251..8485d07efa 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js @@ -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, {