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-registration' ),
19 type
: 'send_unselected_if_any',
23 label
: mw
.msg( 'rcfilters-filter-registered-label' ),
24 description
: mw
.msg( 'rcfilters-filter-registered-description' )
28 label
: mw
.msg( 'rcfilters-filter-unregistered-label' ),
29 description
: mw
.msg( 'rcfilters-filter-unregistered-description' )
34 title
: mw
.msg( 'rcfilters-filtergroup-userExpLevel' ),
35 // Type 'string_options' means that the group is evaluated by
36 // string values separated by comma; for example, param=opt1,opt2
37 // If all options are selected they are replaced by the term "all".
38 // The filters are the values for the parameter defined by the group.
39 // ** In this case, the parameter name is the group name. **
40 type
: 'string_options',
45 label
: mw
.msg( 'rcfilters-filter-userExpLevel-newcomer-label' ),
46 description
: mw
.msg( 'rcfilters-filter-userExpLevel-newcomer-description' )
50 label
: mw
.msg( 'rcfilters-filter-userExpLevel-learner-label' ),
51 description
: mw
.msg( 'rcfilters-filter-userExpLevel-learner-description' )
55 label
: mw
.msg( 'rcfilters-filter-userExpLevel-experienced-label' ),
56 description
: mw
.msg( 'rcfilters-filter-userExpLevel-experienced-description' )
61 title
: mw
.msg( 'rcfilters-filtergroup-authorship' ),
62 // Type 'send_unselected_if_any' means that the controller will go over
63 // all unselected filters in the group and use their parameters
64 // as truthy in the query string.
65 // This is to handle the "negative" filters. We are showing users
66 // a positive message ("Show xxx") but the filters themselves are
67 // based on "hide YYY". The purpose of this is to correctly map
68 // the functionality to the UI, whether we are dealing with 2
69 // parameters in the group or more.
70 type
: 'send_unselected_if_any',
74 label
: mw
.msg( 'rcfilters-filter-editsbyself-label' ),
75 description
: mw
.msg( 'rcfilters-filter-editsbyself-description' )
79 label
: mw
.msg( 'rcfilters-filter-editsbyother-label' ),
80 description
: mw
.msg( 'rcfilters-filter-editsbyother-description' )
85 title
: mw
.msg( 'rcfilters-filtergroup-automated' ),
86 type
: 'send_unselected_if_any',
90 label
: mw
.msg( 'rcfilters-filter-bots-label' ),
91 description
: mw
.msg( 'rcfilters-filter-bots-description' )
95 label
: mw
.msg( 'rcfilters-filter-humans-label' ),
96 description
: mw
.msg( 'rcfilters-filter-humans-description' )
101 title
: mw
.msg( 'rcfilters-filtergroup-significance' ),
102 type
: 'send_unselected_if_any',
106 label
: mw
.msg( 'rcfilters-filter-minor-label' ),
107 description
: mw
.msg( 'rcfilters-filter-minor-description' )
111 label
: mw
.msg( 'rcfilters-filter-major-label' ),
112 description
: mw
.msg( 'rcfilters-filter-major-description' )
117 title
: mw
.msg( 'rcfilters-filtergroup-changetype' ),
118 type
: 'send_unselected_if_any',
121 name
: 'hidepageedits',
122 label
: mw
.msg( 'rcfilters-filter-pageedits-label' ),
123 description
: mw
.msg( 'rcfilters-filter-pageedits-description' )
126 name
: 'hidenewpages',
127 label
: mw
.msg( 'rcfilters-filter-newpages-label' ),
128 description
: mw
.msg( 'rcfilters-filter-newpages-description' )
131 name
: 'hidecategorization',
132 label
: mw
.msg( 'rcfilters-filter-categorization-label' ),
133 description
: mw
.msg( 'rcfilters-filter-categorization-description' )
137 label
: mw
.msg( 'rcfilters-filter-logactions-label' ),
138 description
: mw
.msg( 'rcfilters-filter-logactions-description' )
144 $( '.rcoptions' ).before( widget
.$element
);
147 controller
.initialize();
149 $( '.rcoptions form' ).submit( function () {
150 var $form
= $( this );
152 // Get current filter values
153 $.each( model
.getParametersFromFilters(), function ( paramName
, paramValue
) {
154 var $existingInput
= $form
.find( 'input[name=' + paramName
+ ']' );
155 // Check if the hidden input already exists
156 // This happens if the parameter was already given
158 if ( $existingInput
.length
) {
160 $existingInput
.val( paramValue
);
162 // Append hidden fields with filter values
165 .attr( 'type', 'hidden' )
166 .attr( 'name', paramName
)
172 // Continue the submission process
180 module
.exports
= rcfilters
;
182 }( mediaWiki
, jQuery
) );