Merge "Group messages in WANObjectCache by key"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FilterTagMultiselectWidget.js
index 757a000..4e33be0 100644 (file)
                this.viewsSelectWidget = new OO.ui.ButtonSelectWidget( {
                        classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-views-select-widget' ],
                        items: [
-                               new OO.ui.ButtonOptionWidget( {
-                                       framed: false,
-                                       data: '',
-                                       disabled: true,
-                                       classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-views-select-widget-label' ],
-                                       label: mw.msg( 'rcfilters-view-advanced-filters-label' )
-                               } ),
                                new OO.ui.ButtonOptionWidget( {
                                        framed: false,
                                        data: 'namespaces',
                                        icon: 'article',
+                                       label: mw.msg( 'namespaces' ),
                                        title: mw.msg( 'rcfilters-view-namespaces-tooltip' )
                                } ),
                                new OO.ui.ButtonOptionWidget( {
                                        framed: false,
                                        data: 'tags',
                                        icon: 'tag',
+                                       label: mw.msg( 'tags-title' ),
                                        title: mw.msg( 'rcfilters-view-tags-tooltip' )
                                } )
                        ]
                mw.rcfilters.ui.FilterTagMultiselectWidget.parent.prototype.onMenuToggle.call( this );
 
                if ( isVisible ) {
+                       this.focus();
+
                        mw.hook( 'RcFilters.popup.open' ).fire();
 
                        if ( !this.getMenu().getSelectedItem() ) {
                                setTimeout( function () { this.getMenu().scrollToTop(); }.bind( this ), 0 );
                        }
                } else {
+                       this.blur();
+
                        // Clear selection
                        this.selectTag( null );
 
                this.input.$input.blur();
        };
 
+       /**
+        * @inheritdoc
+        */
+       mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.onMouseDown = function ( e ) {
+               if ( !this.isDisabled() && e.which === OO.ui.MouseButtons.LEFT ) {
+                       this.menu.toggle();
+
+                       return false;
+               }
+       };
+
        /**
         * @inheritdoc
         */
                        this.matchingQuery ? this.matchingQuery.getLabel() : ''
                );
                this.savedQueryTitle.toggle( !!this.matchingQuery );
-               this.saveQueryButton.toggle( !this.matchingQuery );
+               this.saveQueryButton.setDisabled( !!this.matchingQuery );
+               this.saveQueryButton.setTitle( !this.matchingQuery ?
+                       mw.msg( 'rcfilters-savedqueries-add-new-title' ) :
+                       mw.msg( 'rcfilters-savedqueries-already-saved' ) );
 
                if ( this.matchingQuery ) {
                        this.emphasize();
 
        /**
         * Respond to model itemUpdate event
+        * fixme: when a new state is applied to the model this function is called 60+ times in a row
         *
         * @param {mw.rcfilters.dm.FilterItem} item Filter item model
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.onModelItemUpdate = function ( item ) {
-               if ( item.getGroupModel().isHidden() ) {
-                       return;
-               }
-
-               if (
-                       item.isSelected() ||
-                       (
-                               this.model.isHighlightEnabled() &&
-                               item.isHighlightSupported() &&
-                               item.getHighlightColor()
-                       )
-               ) {
-                       this.addTag( item.getName(), item.getLabel() );
-               } else {
-                       this.removeTagByData( item.getName() );
+               if ( !item.getGroupModel().isHidden() ) {
+                       if (
+                               item.isSelected() ||
+                               (
+                                       this.model.isHighlightEnabled() &&
+                                       item.getHighlightColor()
+                               )
+                       ) {
+                               this.addTag( item.getName(), item.getLabel() );
+                       } else {
+                               this.removeTagByData( item.getName() );
+                       }
                }
 
                this.setSavedQueryVisibility();
                                }
                        }.bind( this ) );
                }
+
+               this.setSavedQueryVisibility();
        };
 
        /**
                if ( filterItem ) {
                        return new mw.rcfilters.ui.FilterTagItemWidget(
                                this.controller,
+                               this.model,
+                               this.model.getInvertModel(),
                                filterItem,
                                {
                                        $overlay: this.$overlay