2 * JavaScript for Special:RecentChanges
12 var model = new mw.rcfilters.dm.FiltersViewModel(),
13 controller = new mw.rcfilters.Controller( model ),
14 widget = new mw.rcfilters.ui.FilterWrapperWidget( controller, model );
16 model.initializeFilters( {
18 title: mw.msg( 'rcfilters-filtergroup-authorship' ),
19 // Type 'send_unselected_if_any' means that the controller will go over
20 // all unselected filters in the group and use their parameters
21 // as truthy in the query string.
22 // This is to handle the "negative" filters. We are showing users
23 // a positive message ("Show xxx") but the filters themselves are
24 // based on "hide YYY". The purpose of this is to correctly map
25 // the functionality to the UI, whether we are dealing with 2
26 // parameters in the group or more.
27 type: 'send_unselected_if_any',
31 label: mw.msg( 'rcfilters-filter-editsbyself-label' ),
32 description: mw.msg( 'rcfilters-filter-editsbyself-description' )
36 label: mw.msg( 'rcfilters-filter-editsbyother-label' ),
37 description: mw.msg( 'rcfilters-filter-editsbyother-description' )
42 title: mw.msg( 'rcfilters-filtergroup-userExpLevel' ),
43 // Type 'string_options' means that the group is evaluated by
44 // string values separated by comma; for example, param=opt1,opt2
45 // If all options are selected they are replaced by the term "all".
46 // The filters are the values for the parameter defined by the group.
47 // ** In this case, the parameter name is the group name. **
48 type: 'string_options',
53 label: mw.msg( 'rcfilters-filter-userExpLevel-newcomer-label' ),
54 description: mw.msg( 'rcfilters-filter-userExpLevel-newcomer-description' )
58 label: mw.msg( 'rcfilters-filter-userExpLevel-learner-label' ),
59 description: mw.msg( 'rcfilters-filter-userExpLevel-learner-description' )
63 label: mw.msg( 'rcfilters-filter-userExpLevel-experienced-label' ),
64 description: mw.msg( 'rcfilters-filter-userExpLevel-experienced-description' )
70 $( '.rcoptions' ).before( widget.$element );
73 controller.initialize();
75 $( '.rcoptions form' ).submit( function () {
76 var $form = $( this );
78 // Get current filter values
79 $.each( model.getParametersFromFilters(), function ( paramName, paramValue ) {
80 var $existingInput = $form.find( 'input[name=' + paramName + ']' );
81 // Check if the hidden input already exists
82 // This happens if the parameter was already given
84 if ( $existingInput.length ) {
86 $existingInput.val( paramValue );
88 // Append hidden fields with filter values
91 .attr( 'type', 'hidden' )
92 .attr( 'name', paramName )
98 // Continue the submission process
106 module.exports = rcfilters;
108 }( mediaWiki, jQuery ) );