Also prevent the reset/trash button from opening the popup.
Bug: T151006
Change-Id: I16009c5d96f2cafddb8d545eedbf9ca1e11d06c6
mw.rcfilters.Controller.prototype.toggleHighlight = function () {
this.filtersModel.toggleHighlight();
this.updateURL();
+
+ if ( this.filtersModel.isHighlightEnabled() ) {
+ mw.hook( 'RcFilters.highlight.enable' ).fire();
+ }
};
/**
// Events
this.model.connect( this, { update: 'onModelUpdate' } );
- this.closeButton.$element.on( 'mousedown', this.onCloseButtonMouseDown.bind( this ) );
-
// Initialization
this.$overlay.append( this.popup.$element );
this.$element
.prepend( this.$highlight )
.attr( 'aria-haspopup', 'true' )
.addClass( 'mw-rcfilters-ui-capsuleItemWidget' )
+ .on( 'mousedown', this.onMouseDown.bind( this ) )
.on( 'mouseenter', this.onMouseEnter.bind( this ) )
.on( 'mouseleave', this.onMouseLeave.bind( this ) );
*
* @param {jQuery.Event} e Event
*/
- mw.rcfilters.ui.CapsuleItemWidget.prototype.onCloseButtonMouseDown = function ( e ) {
+ mw.rcfilters.ui.CapsuleItemWidget.prototype.onMouseDown = function ( e ) {
e.stopPropagation();
};
// Events
this.resetButton.connect( this, { click: 'onResetButtonClick' } );
+ this.resetButton.$element.on( 'mousedown', this.onResetButtonMouseDown.bind( this ) );
this.model.connect( this, {
itemUpdate: 'onModelItemUpdate',
highlightChange: 'onModelHighlightChange'
}
};
+ /**
+ * Respond to mouse down event on the reset button to prevent the popup from opening
+ *
+ * @param {jQuery.Event} e Event
+ */
+ mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onResetButtonMouseDown = function ( e ) {
+ e.stopPropagation();
+ };
+
/**
* Reevaluate the restore state for the widget between setting to defaults and clearing all filters
*/
this.filterPopup.select( filterName );
this.capsule.select( item );
+ this.capsule.popup.toggle( true );
this.scrollToTop( filterWidget.$element );
};
this.capsule.resetSelection();
}
} else {
+ mw.hook( 'RcFilters.popup.open' ).fire( this.filterPopup.getSelectedFilter() );
+
this.scrollToTop( this.capsule.$element, 10 );
if ( !this.filterPopup.getSelectedFilter() ) {
// No selection, scroll the popup list to top