RC Filters: Hooks for highlight guided tour
authorStephane Bisson <sbisson@wikimedia.org>
Wed, 22 Mar 2017 12:56:50 +0000 (08:56 -0400)
committerSbisson <sbisson@wikimedia.org>
Tue, 28 Mar 2017 10:34:55 +0000 (10:34 +0000)
Also prevent the reset/trash button from opening the popup.

Bug: T151006
Change-Id: I16009c5d96f2cafddb8d545eedbf9ca1e11d06c6

resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.CapsuleItemWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js

index 14eabe2..e334d5d 100644 (file)
        mw.rcfilters.Controller.prototype.toggleHighlight = function () {
                this.filtersModel.toggleHighlight();
                this.updateURL();
+
+               if ( this.filtersModel.isHighlightEnabled() ) {
+                       mw.hook( 'RcFilters.highlight.enable' ).fire();
+               }
        };
 
        /**
index 728bb38..20eff8b 100644 (file)
                // 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 ) );
 
@@ -84,7 +83,7 @@
         *
         * @param {jQuery.Event} e Event
         */
-       mw.rcfilters.ui.CapsuleItemWidget.prototype.onCloseButtonMouseDown = function ( e ) {
+       mw.rcfilters.ui.CapsuleItemWidget.prototype.onMouseDown = function ( e ) {
                e.stopPropagation();
        };
 
index e481bde..f4f460d 100644 (file)
@@ -49,6 +49,7 @@
 
                // 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
         */
index 1fba18c..761fc65 100644 (file)
@@ -98,6 +98,7 @@
                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