X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fdm%2Fmw.rcfilters.dm.FiltersViewModel.js;h=5013c086214cbc6ad1deec00bad071eb87bdcc7e;hb=f58546ef6e55342ff2d54bdf9e421102aed7aa76;hp=62ba002c1fedc0da157eef0a9281975f4628cd0b;hpb=802c199d0bd80ff0f4d730c61fd58cbf08a52d8d;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js index 62ba002c1f..5013c08621 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js @@ -598,6 +598,31 @@ 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. @@ -774,26 +799,6 @@ } ); }; - /** - * Check whether the default values of the filters are all false. - * - * @return {boolean} Default filters are all false - */ - mw.rcfilters.dm.FiltersViewModel.prototype.areDefaultFiltersEmpty = function () { - var defaultFilters; - - if ( this.defaultFiltersEmpty !== null ) { - // We only need to do this test once, - // because defaults are set once per session - defaultFilters = this.getFiltersFromParameters( this.getDefaultParams() ); - this.defaultFiltersEmpty = Object.keys( defaultFilters ).every( function ( filterName ) { - return !defaultFilters[ filterName ]; - } ); - } - - return this.defaultFiltersEmpty; - }; - /** * Get the item that matches the given name * @@ -1046,12 +1051,14 @@ enable = enable === undefined ? !this.highlightEnabled : enable; if ( this.highlightEnabled !== enable ) { - this.highlightEnabled = enable; - + // HACK make sure highlights are disabled globally while we toggle on the items, + // 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 ); } };