} );
// Collect views
- allViews = {
+ allViews = $.extend( true, {
'default': {
title: mw.msg( 'rcfilters-filterlist-title' ),
groups: filterGroups
}
- };
-
- if ( views && mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) {
- // If we have extended views, add them in
- $.extend( true, allViews, views );
- }
+ }, views );
// Go over all views
$.each( allViews, function ( viewName, viewData ) {
return result;
};
+ /**
+ * Get a parameter representation of all sticky parameters
+ *
+ * @return {Object} Sticky parameter values
+ */
+ mw.rcfilters.dm.FiltersViewModel.prototype.getStickyParams = function () {
+ var result = {};
+
+ $.each( this.groups, function ( name, model ) {
+ if ( model.isSticky() ) {
+ $.extend( true, result, model.getDefaultParams() );
+ }
+ } );
+
+ return result;
+ };
+
+ /**
+ * Get a filter representation of all sticky parameters
+ *
+ * @return {Object} Sticky filters values
+ */
+ mw.rcfilters.dm.FiltersViewModel.prototype.getStickyFiltersState = function () {
+ var result = {};
+
+ $.each( this.groups, function ( name, model ) {
+ if ( model.isSticky() ) {
+ $.extend( true, result, model.getSelectedState() );
+ }
+ } );
+
+ 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.
/**
* Get the highlight parameters based on current filter configuration
*
- * @return {Object} Object where keys are "<filter name>_color" and values
+ * @return {Object} Object where keys are `<filter name>_color` and values
* are the selected highlight colors.
*/
mw.rcfilters.dm.FiltersViewModel.prototype.getHighlightParameters = function () {
*
* @param {Object} representation Object containing representation of
* some or all highlight values
- * @return {Object} Object where keys are "<filter name>_color" and values
+ * @return {Object} Object where keys are `<filter name>_color` and values
* are the selected highlight colors. The returned object
* contains all available filters either with a color value
* or with null.
// Check if there are either any selected items or any items
// that have highlight enabled
return !this.getItems().some( function ( filterItem ) {
- return filterItem.isSelected() || filterItem.isHighlighted();
+ return !filterItem.getGroupModel().isHidden() && ( filterItem.isSelected() || filterItem.isHighlighted() );
} );
};
*/
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 ) );
};
items = this.getFiltersByView( view );
// Normalize so we can search strings regardless of case and view
- query = query.toLowerCase();
+ query = query.trim().toLowerCase();
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