Merge "Remove perf tracking code that was moved to WikimediaEvents in Ib300af5c"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FiltersViewModel.js
index fdea5ef..772ed92 100644 (file)
 
                this.currentView = 'default';
 
+               if ( this.getHighlightedItems().length > 0 ) {
+                       this.toggleHighlight( true );
+               }
+
                // Finish initialization
                this.emit( 'initialize' );
        };
                return result;
        };
 
+       /**
+        * Get the parameter names that represent filters that are excluded
+        * from saved queries.
+        *
+        * @return {string[]} Parameter names
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.getExcludedParams = function () {
+               var result = [];
+
+               $.each( this.groups, function ( name, model ) {
+                       if ( model.isExcludedFromSavedQueries() ) {
+                               if ( model.isPerGroupRequestParameter() ) {
+                                       result.push( name );
+                               } else {
+                                       // Each filter is its own param
+                                       result = result.concat( model.getItems().map( function ( filterItem ) {
+                                               return filterItem.getParamName();
+                                       } ) );
+                               }
+                       }
+               } );
+
+               return result;
+       };
+
        /**
         * Analyze the groups and their filters and output an object representing
         * the state of the parameters they represent.
                return result;
        };
 
+       /**
+        * Get an object representing the complete empty state of highlights
+        *
+        * @return {Object} Object containing all the highlight parameters set to their negative value
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.getEmptyHighlightParameters = function () {
+               var result = {};
+
+               this.getItems().forEach( function ( filterItem ) {
+                       result[ filterItem.getName() + '_color' ] = null;
+               } );
+               result.highlight = '0';
+
+               return result;
+       };
+
        /**
         * Extract the highlight values from given object. Since highlights are
         * the same for filter and parameters, it doesn't matter which one is
                        // otherwise we'll call clearHighlight() and applyHighlight() many many times
                        this.highlightEnabled = false;
                        this.getItems().forEach( function ( filterItem ) {
-                               filterItem.toggleHighlight( this.highlightEnabled );
-                       }.bind( this ) );
+                               filterItem.toggleHighlight( enable );
+                       } );
 
                        this.highlightEnabled = enable;
                        this.emit( 'highlightChange', this.highlightEnabled );