*
* @param {Array} filterStructure Filter definition and structure for the model
* @param {Object} [namespaceStructure] Namespace definition
+ * @param {Object} [tagList] Tag definition
*/
- mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure ) {
+ mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList ) {
var parsedSavedQueries,
+ views = {},
+ items = [],
uri = new mw.Uri(),
$changesList = $( '.mw-changeslist' ).first().contents();
+ // Prepare views
+ if ( namespaceStructure ) {
+ items = [];
+ $.each( namespaceStructure, function ( namespaceID, label ) {
+ // Build and clean up the individual namespace items definition
+ items.push( {
+ name: namespaceID,
+ label: label || mw.msg( 'blanknamespace' ),
+ description: '',
+ identifiers: [
+ ( namespaceID < 0 || namespaceID % 2 === 0 ) ?
+ 'subject' : 'talk'
+ ],
+ cssClass: 'mw-changeslist-ns-' + namespaceID
+ } );
+ } );
+
+ views.namespaces = {
+ title: mw.msg( 'namespaces' ),
+ trigger: ':',
+ groups: [ {
+ // Group definition (single group)
+ name: 'namespace', // parameter name is singular
+ type: 'string_options',
+ title: mw.msg( 'namespaces' ),
+ labelPrefixKey: { 'default': 'rcfilters-tag-prefix-namespace', inverted: 'rcfilters-tag-prefix-namespace-inverted' },
+ separator: ';',
+ fullCoverage: true,
+ filters: items
+ } ]
+ };
+ }
+ if ( tagList ) {
+ views.tags = {
+ title: mw.msg( 'rcfilters-view-tags' ),
+ trigger: '#',
+ groups: [ {
+ // Group definition (single group)
+ name: 'tagfilter', // Parameter name
+ type: 'string_options',
+ title: 'rcfilters-view-tags', // Message key
+ labelPrefixKey: 'rcfilters-tag-prefix-tags',
+ separator: '|',
+ fullCoverage: false,
+ filters: tagList
+ } ]
+ };
+ }
+
// Initialize the model
- this.filtersModel.initializeFilters( filterStructure, namespaceStructure );
+ this.filtersModel.initializeFilters( filterStructure, views );
+
this._buildBaseFilterState();
this.uriProcessor = new mw.rcfilters.UriProcessor(
* @param {string} queryID Query id
*/
mw.rcfilters.Controller.prototype.removeSavedQuery = function ( queryID ) {
- var query = this.savedQueriesModel.getItemByID( queryID );
-
- this.savedQueriesModel.removeItems( [ query ] );
+ this.savedQueriesModel.removeQuery( queryID );
- // Check if this item was the default
- if ( this.savedQueriesModel.getDefault() === queryID ) {
- // Nulify the default
- this.savedQueriesModel.setDefault( null );
- }
this._saveSavedQueries();
};
this.uriProcessor.getVersion( currentUri.query ) !== 2 ||
this.uriProcessor.isNewState( currentUri.query, updatedUri.query )
) {
- if ( this.initializing ) {
- // Initially, when we just build the first page load
- // out of defaults, we want to replace the history
- mw.rcfilters.UriProcessor.static.replaceState( updatedUri );
- } else {
- mw.rcfilters.UriProcessor.static.pushState( updatedUri );
- }
+ mw.rcfilters.UriProcessor.static.replaceState( updatedUri );
}
};