X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fdm%2Fmw.rcfilters.dm.FilterGroup.js;h=e08e28c6ee0b21ec22d5c7a9ed6267f4d2b5970d;hb=6f3d5a5204770b7e9076ec0c956631c32a9e1114;hp=bb29b36191f313d9b7f42b981f366a3bcb230b41;hpb=74426f3cf796b149f1ae445e41815bbe148640b2;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterGroup.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterGroup.js index bb29b36191..e08e28c6ee 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterGroup.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterGroup.js @@ -1,4 +1,5 @@ -( function ( mw ) { +/* eslint-disable no-restricted-properties */ +( function () { /** * View model for a filter group * @@ -210,7 +211,7 @@ // Verify that single_option group has at least one item selected if ( this.getType() === 'single_option' && - this.getSelectedItems().length === 0 + this.findSelectedItems().length === 0 ) { defaultParam = groupDefault !== undefined ? groupDefault : this.getItems()[ 0 ].getParamName(); @@ -237,19 +238,19 @@ if ( this.getType() === 'single_option' ) { // This group must have one item selected always // and must never have more than one item selected at a time - if ( this.getSelectedItems().length === 0 ) { + if ( this.findSelectedItems().length === 0 ) { // Nothing is selected anymore // Select the default or the first item this.currSelected = this.getItemByParamName( this.defaultParams[ this.getName() ] ) || this.getItems()[ 0 ]; this.currSelected.toggleSelected( true ); changed = true; - } else if ( this.getSelectedItems().length > 1 ) { + } else if ( this.findSelectedItems().length > 1 ) { // There is more than one item selected // This should only happen if the item given // is the one that is selected, so unselect // all items that is not it - this.getSelectedItems().forEach( function ( itemModel ) { + this.findSelectedItems().forEach( function ( itemModel ) { // Note that in case the given item is actually // not selected, this loop will end up unselecting // all items, which would trigger the case above @@ -266,17 +267,17 @@ } } + if ( this.isSticky() ) { + // If this group is sticky, then change the default according to the + // current selection. + this.defaultParams = this.getParamRepresentation( this.getSelectedState() ); + } + if ( changed || this.active !== active || this.currSelected !== item ) { - if ( this.isSticky() ) { - // If this group is sticky, then change the default according to the - // current selection. - this.defaultParams = this.getParamRepresentation( this.getSelectedState() ); - } - this.active = active; this.currSelected = item; @@ -494,7 +495,7 @@ * @param {mw.rcfilters.dm.FilterItem} [excludeItem] Item to exclude from the list * @return {mw.rcfilters.dm.FilterItem[]} Selected items */ - mw.rcfilters.dm.FilterGroup.prototype.getSelectedItems = function ( excludeItem ) { + mw.rcfilters.dm.FilterGroup.prototype.findSelectedItems = function ( excludeItem ) { var excludeName = ( excludeItem && excludeItem.getName() ) || ''; return this.getItems().filter( function ( item ) { @@ -509,7 +510,7 @@ * @return {boolean} All selected items are in conflict with this item */ mw.rcfilters.dm.FilterGroup.prototype.areAllSelectedInConflictWith = function ( filterItem ) { - var selectedItems = this.getSelectedItems( filterItem ); + var selectedItems = this.findSelectedItems( filterItem ); return selectedItems.length > 0 && ( @@ -529,7 +530,7 @@ * @return {boolean} Any of the selected items are in conflict with this item */ mw.rcfilters.dm.FilterGroup.prototype.areAnySelectedInConflictWith = function ( filterItem ) { - var selectedItems = this.getSelectedItems( filterItem ); + var selectedItems = this.findSelectedItems( filterItem ); return selectedItems.length > 0 && ( // The group as a whole is in conflict with this item @@ -980,4 +981,4 @@ itemModel.toggleVisible( visibleItems.indexOf( itemModel ) !== -1 ); } ); }; -}( mediaWiki ) ); +}() );