Merge "Move around "ا" to after "آ" and not before"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FiltersViewModel.js
index a6a22ef..62ba002 100644 (file)
                return result;
        };
 
+       /**
+        * Get a filter representation of all parameters that are marked
+        * as being excluded from saved query.
+        *
+        * @return {Object} Excluded filters values
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.getExcludedFiltersState = function () {
+               var result = {};
+
+               $.each( this.groups, function ( name, model ) {
+                       if ( model.isExcludedFromSavedQueries() ) {
+                               $.extend( true, result, model.getSelectedState() );
+                       }
+               } );
+
+               return result;
+       };
+
        /**
         * Analyze the groups and their filters and output an object representing
         * the state of the parameters they represent.
                return result;
        };
 
+       /**
+        * Get an array of currently applied highlight colors
+        *
+        * @return {string[]} Currently applied highlight colors
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.getCurrentlyUsedHighlightColors = function () {
+               var result = [];
+
+               this.getHighlightedItems().forEach( function ( filterItem ) {
+                       var color = filterItem.getHighlightColor();
+
+                       if ( result.indexOf( color ) === -1 ) {
+                               result.push( color );
+                       }
+               } );
+
+               return result;
+       };
+
        /**
         * Sanitize value group of a string_option groups type
         * Remove duplicates and make sure to only use valid
         */
        mw.rcfilters.dm.FiltersViewModel.prototype.emptyAllFilters = function () {
                this.getItems().forEach( function ( filterItem ) {
-                       this.toggleFilterSelected( filterItem.getName(), false );
+                       if ( !filterItem.getGroupModel().isSticky() ) {
+                               this.toggleFilterSelected( filterItem.getName(), false );
+                       }
                }.bind( this ) );
        };
 
                if ( view !== 'default' ) {
                        query = query.substr( 1 );
                }
+               // Trim again to also intercept cases where the spaces were after the trigger
+               // eg: '#   str'
+               query = query.trim();
 
                // Check if the search if actually empty; this can be a problem when
                // we use prefixes to denote different views