3 * View model for the filters selection and display
5 * @mixins OO.EventEmitter
6 * @mixins OO.EmitterList
10 mw
.rcfilters
.dm
.FiltersViewModel
= function MwRcfiltersDmFiltersViewModel() {
12 OO
.EventEmitter
.call( this );
13 OO
.EmitterList
.call( this );
16 this.defaultParams
= {};
17 this.defaultFiltersEmpty
= null;
18 this.highlightEnabled
= false;
19 this.parameterMap
= {};
22 this.aggregate( { update
: 'filterItemUpdate' } );
23 this.connect( this, { filterItemUpdate
: [ 'emit', 'itemUpdate' ] } );
27 OO
.initClass( mw
.rcfilters
.dm
.FiltersViewModel
);
28 OO
.mixinClass( mw
.rcfilters
.dm
.FiltersViewModel
, OO
.EventEmitter
);
29 OO
.mixinClass( mw
.rcfilters
.dm
.FiltersViewModel
, OO
.EmitterList
);
36 * Filter list is initialized
41 * @param {mw.rcfilters.dm.FilterItem} item Filter item updated
43 * Filter item has changed
47 * @event highlightChange
48 * @param {boolean} Highlight feature is enabled
50 * Highlight feature has been toggled enabled or disabled
56 * Re-assess the states of filter items based on the interactions between them
58 * @param {mw.rcfilters.dm.FilterItem} [item] Changed item. If not given, the
59 * method will go over the state of all items
61 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.reassessFilterInteractions = function ( item
) {
64 iterationItems
= item
!== undefined ? [ item
] : this.getItems();
66 iterationItems
.forEach( function ( checkedItem
) {
67 var allCheckedItems
= checkedItem
.getSubset().concat( [ checkedItem
.getName() ] ),
68 groupModel
= checkedItem
.getGroupModel();
70 // Check for subsets (included filters) plus the item itself:
71 allCheckedItems
.forEach( function ( filterItemName
) {
72 var itemInSubset
= model
.getItemByName( filterItemName
);
74 itemInSubset
.toggleIncluded(
75 // If any of itemInSubset's supersets are selected, this item
77 itemInSubset
.getSuperset().some( function ( supersetName
) {
78 return ( model
.getItemByName( supersetName
).isSelected() );
83 // Update coverage for the changed group
84 if ( groupModel
.isFullCoverage() ) {
85 allSelected
= groupModel
.areAllSelected();
86 groupModel
.getItems().forEach( function ( filterItem
) {
87 filterItem
.toggleFullyCovered( allSelected
);
92 // Check for conflicts
93 // In this case, we must go over all items, since
94 // conflicts are bidirectional and depend not only on
95 // individual items, but also on the selected states of
96 // the groups they're in.
97 this.getItems().forEach( function ( filterItem
) {
98 var inConflict
= false,
99 filterItemGroup
= filterItem
.getGroupModel();
101 // For each item, see if that item is still conflicting
102 $.each( model
.groups
, function ( groupName
, groupModel
) {
103 if ( filterItem
.getGroupName() === groupName
) {
104 // Check inside the group
105 inConflict
= groupModel
.areAnySelectedInConflictWith( filterItem
);
107 // According to the spec, if two items conflict from two different
108 // groups, the conflict only lasts if the groups **only have selected
109 // items that are conflicting**. If a group has selected items that
110 // are conflicting and non-conflicting, the scope of the result has
111 // expanded enough to completely remove the conflict.
113 // For example, see two groups with conflicts:
116 // name: 'experienced',
117 // conflicts: [ 'unregistered' ]
122 // name: 'registered',
125 // name: 'unregistered',
128 // If we select 'experienced', then 'unregistered' is in conflict (and vice versa),
129 // because, inherently, 'experienced' filter only includes registered users, and so
130 // both filters are in conflict with one another.
131 // However, the minute we select 'registered', the scope of our results
132 // has expanded to no longer have a conflict with 'experienced' filter, and
133 // so the conflict is removed.
135 // In our case, we need to check if the entire group conflicts with
136 // the entire item's group, so we follow the above spec
138 // The foreign group is in conflict with this item
139 groupModel
.areAllSelectedInConflictWith( filterItem
) &&
140 // Every selected member of the item's own group is also
141 // in conflict with the other group
142 filterItemGroup
.getSelectedItems().every( function ( otherGroupItem
) {
143 return groupModel
.areAllSelectedInConflictWith( otherGroupItem
);
148 // If we're in conflict, this will return 'false' which
149 // will break the loop. Otherwise, we're not in conflict
150 // and the loop continues
154 // Toggle the item state
155 filterItem
.toggleConflicted( inConflict
);
160 * Get whether the model has any conflict in its items
162 * @return {boolean} There is a conflict
164 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.hasConflict = function () {
165 return this.getItems().some( function ( filterItem
) {
166 return filterItem
.isSelected() && filterItem
.isConflicted();
171 * Get the first item with a current conflict
173 * @return {mw.rcfilters.dm.FilterItem} Conflicted item
175 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getFirstConflictedItem = function () {
178 $.each( this.getItems(), function ( index
, filterItem
) {
179 if ( filterItem
.isSelected() && filterItem
.isConflicted() ) {
180 conflictedItem
= filterItem
;
185 return conflictedItem
;
189 * Set filters and preserve a group relationship based on
190 * the definition given by an object
192 * @param {Array} filters Filter group definition
194 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.initializeFilters = function ( filters
) {
195 var i
, filterItem
, selectedFilterNames
, filterConflictResult
, groupConflictResult
, subsetNames
,
199 groupConflictMap
= {},
200 filterConflictMap
= {},
201 addArrayElementsUnique = function ( arr
, elements
) {
202 elements
= Array
.isArray( elements
) ? elements
: [ elements
];
204 elements
.forEach( function ( element
) {
205 if ( arr
.indexOf( element
) === -1 ) {
212 expandConflictDefinitions = function ( obj
) {
215 $.each( obj
, function ( key
, conflicts
) {
217 adjustedConflicts
= {};
219 conflicts
.forEach( function ( conflict
) {
222 if ( conflict
.filter
) {
223 filterName
= model
.groups
[ conflict
.group
].getNamePrefix() + conflict
.filter
;
224 filter
= model
.getItemByName( filterName
);
227 adjustedConflicts
[ filterName
] = $.extend(
236 // This conflict is for an entire group. Split it up to
237 // represent each filter
239 // Get the relevant group items
240 model
.groups
[ conflict
.group
].getItems().forEach( function ( groupItem
) {
241 // Rebuild the conflict
242 adjustedConflicts
[ groupItem
.getName() ] = $.extend(
246 filter
: groupItem
.getName(),
254 result
[ key
] = adjustedConflicts
;
264 filters
.forEach( function ( data
) {
265 var group
= data
.name
;
267 if ( !model
.groups
[ group
] ) {
268 model
.groups
[ group
] = new mw
.rcfilters
.dm
.FilterGroup( group
, {
270 title
: mw
.msg( data
.title
),
271 separator
: data
.separator
,
272 fullCoverage
: !!data
.fullCoverage
276 if ( data
.conflicts
) {
277 groupConflictMap
[ group
] = data
.conflicts
;
280 selectedFilterNames
= [];
281 for ( i
= 0; i
< data
.filters
.length
; i
++ ) {
282 data
.filters
[ i
].subset
= data
.filters
[ i
].subset
|| [];
283 data
.filters
[ i
].subset
= data
.filters
[ i
].subset
.map( function ( el
) {
287 filterItem
= new mw
.rcfilters
.dm
.FilterItem( data
.filters
[ i
].name
, model
.groups
[ group
], {
289 label
: mw
.msg( data
.filters
[ i
].label
),
290 description
: mw
.msg( data
.filters
[ i
].description
),
291 cssClass
: data
.filters
[ i
].cssClass
294 if ( data
.filters
[ i
].subset
) {
296 data
.filters
[ i
].subset
.forEach( function ( subsetFilterName
) { // eslint-disable-line no-loop-func
297 var subsetName
= model
.groups
[ group
].getNamePrefix() + subsetFilterName
;
298 // For convenience, we should store each filter's "supersets" -- these are
299 // the filters that have that item in their subset list. This will just
300 // make it easier to go through whether the item has any other items
301 // that affect it (and are selected) at any given time
302 supersetMap
[ subsetName
] = supersetMap
[ subsetName
] || [];
303 addArrayElementsUnique(
304 supersetMap
[ subsetName
],
308 // Translate subset param name to add the group name, so we
309 // get consistent naming. We know that subsets are only within
311 subsetNames
.push( subsetName
);
314 // Set translated subset
315 filterItem
.setSubset( subsetNames
);
319 if ( data
.filters
[ i
].conflicts
) {
320 filterConflictMap
[ filterItem
.getName() ] = data
.filters
[ i
].conflicts
;
323 if ( data
.type
=== 'send_unselected_if_any' ) {
324 // Store the default parameter state
325 // For this group type, parameter values are direct
326 model
.defaultParams
[ data
.filters
[ i
].name
] = Number( !!data
.filters
[ i
].default );
328 data
.type
=== 'string_options' &&
329 data
.filters
[ i
].default
331 selectedFilterNames
.push( data
.filters
[ i
].name
);
334 model
.groups
[ group
].addItems( filterItem
);
335 items
.push( filterItem
);
338 if ( data
.type
=== 'string_options' ) {
339 // Store the default parameter group state
340 // For this group, the parameter is group name and value is the names
342 model
.defaultParams
[ group
] = model
.sanitizeStringOptionGroup( group
, selectedFilterNames
).join( model
.groups
[ group
].getSeparator() );
346 // Add items to the model
347 this.addItems( items
);
350 groupConflictResult
= expandConflictDefinitions( groupConflictMap
);
351 filterConflictResult
= expandConflictDefinitions( filterConflictMap
);
353 // Set conflicts for groups
354 $.each( groupConflictResult
, function ( group
, conflicts
) {
355 model
.groups
[ group
].setConflicts( conflicts
);
358 items
.forEach( function ( filterItem
) {
359 // Apply the superset map
360 filterItem
.setSuperset( supersetMap
[ filterItem
.getName() ] );
362 // set conflicts for item
363 if ( filterConflictResult
[ filterItem
.getName() ] ) {
364 filterItem
.setConflicts( filterConflictResult
[ filterItem
.getName() ] );
368 // Create a map between known parameters and their models
369 $.each( this.groups
, function ( group
, groupModel
) {
370 if ( groupModel
.getType() === 'send_unselected_if_any' ) {
371 // Individual filters
372 groupModel
.getItems().forEach( function ( filterItem
) {
373 model
.parameterMap
[ filterItem
.getParamName() ] = filterItem
;
375 } else if ( groupModel
.getType() === 'string_options' ) {
377 model
.parameterMap
[ groupModel
.getName() ] = groupModel
;
381 this.emit( 'initialize' );
385 * Get the names of all available filters
387 * @return {string[]} An array of filter names
389 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getFilterNames = function () {
390 return this.getItems().map( function ( item
) { return item
.getName(); } );
394 * Get the object that defines groups by their name.
396 * @return {Object} Filter groups
398 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getFilterGroups = function () {
403 * Get the value of a specific parameter
405 * @param {string} name Parameter name
406 * @return {number|string} Parameter value
408 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getParamValue = function ( name
) {
409 return this.parameters
[ name
];
413 * Get the current selected state of the filters
415 * @return {Object} Filters selected state
417 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getSelectedState = function () {
419 items
= this.getItems(),
422 for ( i
= 0; i
< items
.length
; i
++ ) {
423 result
[ items
[ i
].getName() ] = items
[ i
].isSelected();
430 * Get the current full state of the filters
432 * @return {Object} Filters full state
434 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getFullState = function () {
436 items
= this.getItems(),
439 for ( i
= 0; i
< items
.length
; i
++ ) {
440 result
[ items
[ i
].getName() ] = {
441 selected
: items
[ i
].isSelected(),
442 conflicted
: items
[ i
].isConflicted(),
443 included
: items
[ i
].isIncluded()
451 * Get the default parameters object
453 * @return {Object} Default parameter values
455 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getDefaultParams = function () {
456 return this.defaultParams
;
460 * Set all filter states to default values
462 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.setFiltersToDefaults = function () {
463 var defaultFilterStates
= this.getFiltersFromParameters( this.getDefaultParams() );
465 this.toggleFiltersSelected( defaultFilterStates
);
469 * Analyze the groups and their filters and output an object representing
470 * the state of the parameters they represent.
472 * @param {Object} [filterGroups] An object defining the filter groups to
473 * translate to parameters. Its structure must follow that of this.groups
474 * see #getFilterGroups
475 * @return {Object} Parameter state object
477 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getParametersFromFilters = function ( filterGroups
) {
479 groupItems
= filterGroups
|| this.getFilterGroups();
481 $.each( groupItems
, function ( group
, model
) {
482 $.extend( result
, model
.getParamRepresentation() );
489 * Get the highlight parameters based on current filter configuration
491 * @return {object} Object where keys are "<filter name>_color" and values
492 * are the selected highlight colors.
494 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getHighlightParameters = function () {
495 var result
= { highlight
: Number( this.isHighlightEnabled() ) };
497 this.getItems().forEach( function ( filterItem
) {
498 result
[ filterItem
.getName() + '_color' ] = filterItem
.getHighlightColor();
504 * Sanitize value group of a string_option groups type
505 * Remove duplicates and make sure to only use valid
509 * @param {string} groupName Group name
510 * @param {string[]} valueArray Array of values
511 * @return {string[]} Array of valid values
513 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.sanitizeStringOptionGroup = function( groupName
, valueArray
) {
515 validNames
= this.getGroupFilters( groupName
).map( function ( filterItem
) {
516 return filterItem
.getParamName();
519 if ( valueArray
.indexOf( 'all' ) > -1 ) {
520 // If anywhere in the values there's 'all', we
521 // treat it as if only 'all' was selected.
522 // Example: param=valid1,valid2,all
527 // Get rid of any dupe and invalid parameter, only output
529 // Example: param=valid1,valid2,invalid1,valid1
530 // Result: param=valid1,valid2
531 valueArray
.forEach( function ( value
) {
533 validNames
.indexOf( value
) > -1 &&
534 result
.indexOf( value
) === -1
536 result
.push( value
);
544 * Check whether the current filter state is set to all false.
546 * @return {boolean} Current filters are all empty
548 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.areCurrentFiltersEmpty = function () {
549 // Check if there are either any selected items or any items
550 // that have highlight enabled
551 return !this.getItems().some( function ( filterItem
) {
552 return filterItem
.isSelected() || filterItem
.isHighlighted();
557 * Check whether the default values of the filters are all false.
559 * @return {boolean} Default filters are all false
561 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.areDefaultFiltersEmpty = function () {
564 if ( this.defaultFiltersEmpty
!== null ) {
565 // We only need to do this test once,
566 // because defaults are set once per session
567 defaultFilters
= this.getFiltersFromParameters();
568 this.defaultFiltersEmpty
= Object
.keys( defaultFilters
).every( function ( filterName
) {
569 return !defaultFilters
[ filterName
];
573 return this.defaultFiltersEmpty
;
577 * This is the opposite of the #getParametersFromFilters method; this goes over
578 * the given parameters and translates into a selected/unselected value in the filters.
580 * @param {Object} params Parameters query object
581 * @return {Object} Filter state object
583 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getFiltersFromParameters = function ( params
) {
587 base
= this.getDefaultParams(),
590 params
= $.extend( {}, base
, params
);
592 // Go over the given parameters
593 $.each( params
, function ( paramName
, paramValue
) {
594 var itemOrGroup
= model
.parameterMap
[ paramName
];
596 if ( itemOrGroup
instanceof mw
.rcfilters
.dm
.FilterItem
) {
597 // Mark the group if it has any items that are selected
598 groupMap
[ itemOrGroup
.getGroupName() ] = groupMap
[ itemOrGroup
.getGroupName() ] || {};
599 groupMap
[ itemOrGroup
.getGroupName() ].hasSelected
= (
600 groupMap
[ itemOrGroup
.getGroupName() ].hasSelected
||
601 !!Number( paramValue
)
605 groupMap
[ itemOrGroup
.getGroupName() ].filters
= groupMap
[ itemOrGroup
.getGroupName() ].filters
|| [];
606 groupMap
[ itemOrGroup
.getGroupName() ].filters
.push( itemOrGroup
);
607 } else if ( itemOrGroup
instanceof mw
.rcfilters
.dm
.FilterGroup
) {
608 groupMap
[ itemOrGroup
.getName() ] = groupMap
[ itemOrGroup
.getName() ] || {};
609 // This parameter represents a group (values are the filters)
610 // this is equivalent to checking if the group is 'string_options'
611 groupMap
[ itemOrGroup
.getName() ].filters
= itemOrGroup
.getItems();
615 // Now that we know the groups' selection states, we need to go over
616 // the filters in the groups and mark their selected states appropriately
617 $.each( groupMap
, function ( group
, data
) {
618 var paramValues
, filterItem
,
619 allItemsInGroup
= data
.filters
;
621 if ( model
.groups
[ group
].getType() === 'send_unselected_if_any' ) {
622 for ( i
= 0; i
< allItemsInGroup
.length
; i
++ ) {
623 filterItem
= allItemsInGroup
[ i
];
625 result
[ filterItem
.getName() ] = groupMap
[ filterItem
.getGroupName() ].hasSelected
?
626 // Flip the definition between the parameter
627 // state and the filter state
628 // This is what the 'toggleSelected' value of the filter is
629 !Number( params
[ filterItem
.getParamName() ] ) :
630 // Otherwise, there are no selected items in the
631 // group, which means the state is false
634 } else if ( model
.groups
[ group
].getType() === 'string_options' ) {
635 paramValues
= model
.sanitizeStringOptionGroup(
637 params
[ group
].split(
638 model
.groups
[ group
].getSeparator()
642 for ( i
= 0; i
< allItemsInGroup
.length
; i
++ ) {
643 filterItem
= allItemsInGroup
[ i
];
645 result
[ filterItem
.getName() ] = (
646 // If it is the word 'all'
647 paramValues
.length
=== 1 && paramValues
[ 0 ] === 'all' ||
648 // All values are written
649 paramValues
.length
=== model
.groups
[ group
].getItemCount()
651 // All true (either because all values are written or the term 'all' is written)
652 // is the same as all filters set to false
654 // Otherwise, the filter is selected only if it appears in the parameter values
655 paramValues
.indexOf( filterItem
.getParamName() ) > -1;
664 * Get the item that matches the given name
666 * @param {string} name Filter name
667 * @return {mw.rcfilters.dm.FilterItem} Filter item
669 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getItemByName = function ( name
) {
670 return this.getItems().filter( function ( item
) {
671 return name
=== item
.getName();
676 * Set all filters to false or empty/all
677 * This is equivalent to display all.
679 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.emptyAllFilters = function () {
680 this.getItems().forEach( function ( filterItem
) {
681 this.toggleFilterSelected( filterItem
.getName(), false );
686 * Toggle selected state of one item
688 * @param {string} name Name of the filter item
689 * @param {boolean} [isSelected] Filter selected state
691 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.toggleFilterSelected = function ( name
, isSelected
) {
692 var item
= this.getItemByName( name
);
695 item
.toggleSelected( isSelected
);
700 * Toggle selected state of items by their names
702 * @param {Object} filterDef Filter definitions
704 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.toggleFiltersSelected = function ( filterDef
) {
705 Object
.keys( filterDef
).forEach( function ( name
) {
706 this.toggleFilterSelected( name
, filterDef
[ name
] );
711 * Get a group model from its name
713 * @param {string} groupName Group name
714 * @return {mw.rcfilters.dm.FilterGroup} Group model
716 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getGroup = function ( groupName
) {
717 return this.groups
[ groupName
];
721 * Get all filters within a specified group by its name
723 * @param {string} groupName Group name
724 * @return {mw.rcfilters.dm.FilterItem[]} Filters belonging to this group
726 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getGroupFilters = function ( groupName
) {
727 return ( this.getGroup( groupName
) && this.getGroup( groupName
).getItems() ) || [];
731 * Find items whose labels match the given string
733 * @param {string} query Search string
734 * @return {Object} An object of items to show
735 * arranged by their group names
737 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.findMatches = function ( query
) {
741 items
= this.getItems();
743 // Normalize so we can search strings regardless of case
744 query
= query
.toLowerCase();
746 // item label starting with the query string
747 for ( i
= 0; i
< items
.length
; i
++ ) {
748 if ( items
[ i
].getLabel().toLowerCase().indexOf( query
) === 0 ) {
749 result
[ items
[ i
].getGroupName() ] = result
[ items
[ i
].getGroupName() ] || [];
750 result
[ items
[ i
].getGroupName() ].push( items
[ i
] );
754 if ( $.isEmptyObject( result
) ) {
755 // item containing the query string in their label, description, or group title
756 for ( i
= 0; i
< items
.length
; i
++ ) {
757 groupTitle
= items
[ i
].getGroupModel().getTitle();
759 items
[ i
].getLabel().toLowerCase().indexOf( query
) > -1 ||
760 items
[ i
].getDescription().toLowerCase().indexOf( query
) > -1 ||
761 groupTitle
.toLowerCase().indexOf( query
) > -1
763 result
[ items
[ i
].getGroupName() ] = result
[ items
[ i
].getGroupName() ] || [];
764 result
[ items
[ i
].getGroupName() ].push( items
[ i
] );
773 * Get items that are highlighted
775 * @return {mw.rcfilters.dm.FilterItem[]} Highlighted items
777 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.getHighlightedItems = function () {
778 return this.getItems().filter( function ( filterItem
) {
779 return filterItem
.isHighlightSupported() &&
780 filterItem
.getHighlightColor();
785 * Toggle the highlight feature on and off.
786 * Propagate the change to filter items.
788 * @param {boolean} enable Highlight should be enabled
789 * @fires highlightChange
791 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.toggleHighlight = function ( enable
) {
792 enable
= enable
=== undefined ? !this.highlightEnabled
: enable
;
794 if ( this.highlightEnabled
!== enable
) {
795 this.highlightEnabled
= enable
;
797 this.getItems().forEach( function ( filterItem
) {
798 filterItem
.toggleHighlight( this.highlightEnabled
);
801 this.emit( 'highlightChange', this.highlightEnabled
);
806 * Check if the highlight feature is enabled
809 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.isHighlightEnabled = function () {
810 return !!this.highlightEnabled
;
814 * Set highlight color for a specific filter item
816 * @param {string} filterName Name of the filter item
817 * @param {string} color Selected color
819 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.setHighlightColor = function ( filterName
, color
) {
820 this.getItemByName( filterName
).setHighlightColor( color
);
824 * Clear highlight for a specific filter item
826 * @param {string} filterName Name of the filter item
828 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.clearHighlightColor = function ( filterName
) {
829 this.getItemByName( filterName
).clearHighlightColor();
833 * Clear highlight for all filter items
835 mw
.rcfilters
.dm
.FiltersViewModel
.prototype.clearAllHighlightColors = function () {
836 this.getItems().forEach( function ( filterItem
) {
837 filterItem
.clearHighlightColor();
840 }( mediaWiki
, jQuery
) );