Fix namespace handling for uncategorized-categories-exceptionlist
[mediawiki.git] / resources / src / mediawiki.rcfilters / mw.rcfilters.Controller.js
blobea44b8b9623db83a0189fd19f9d7bccd586fe039
1 ( function ( mw ) {
2 /**
3 * Controller for the filters in Recent Changes
5 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
6 */
7 mw.rcfilters.Controller = function MwRcfiltersController( model ) {
8 this.model = model;
10 // TODO: When we are ready, update the URL when a filter is updated
11 // this.model.connect( this, { itemUpdate: 'updateURL' } );
14 /* Initialization */
15 OO.initClass( mw.rcfilters.Controller );
17 /**
18 * Initialize the filter and parameter states
20 mw.rcfilters.Controller.prototype.initialize = function () {
21 var uri = new mw.Uri();
23 this.model.updateFilters(
24 // Translate the url params to filter select states
25 this.model.getFiltersFromParameters( uri.query )
29 /**
30 * Update the state of a filter
32 * @param {string} filterName Filter name
33 * @param {boolean} isSelected Filter selected state
35 mw.rcfilters.Controller.prototype.updateFilter = function ( filterName, isSelected ) {
36 var obj = {};
38 obj[ filterName ] = isSelected;
39 this.model.updateFilters( obj );
42 /**
43 * Update the URL of the page to reflect current filters
45 mw.rcfilters.Controller.prototype.updateURL = function () {
46 var uri = new mw.Uri();
48 // Add to existing queries in URL
49 // TODO: Clean up the list of filters; perhaps 'falsy' filters
50 // shouldn't appear at all? Or compare to existing query string
51 // and see if current state of a specific filter is needed?
52 uri.extend( this.model.getParametersFromFilters() );
54 // Update the URL itself
55 window.history.pushState( { tag: 'rcfilters' }, document.title, uri.toString() );
57 }( mediaWiki ) );