* @cfg {string} savedQueriesPreferenceName Where to save the saved queries
* @cfg {string} daysPreferenceName Preference name for the days filter
* @cfg {string} limitPreferenceName Preference name for the limit filter
+ * @cfg {boolean} [normalizeTarget] Dictates whether or not to go through the
+ * title normalization to separate title subpage/parts into the target= url
+ * parameter
*/
mw.rcfilters.Controller = function MwRcfiltersController( filtersModel, changesListModel, savedQueriesModel, config ) {
this.filtersModel = filtersModel;
this.savedQueriesPreferenceName = config.savedQueriesPreferenceName;
this.daysPreferenceName = config.daysPreferenceName;
this.limitPreferenceName = config.limitPreferenceName;
+ this.normalizeTarget = !!config.normalizeTarget;
this.requestCounter = {};
this.baseFilterState = {};
this.filtersModel.initializeFilters( filterStructure, views );
this.uriProcessor = new mw.rcfilters.UriProcessor(
- this.filtersModel
+ this.filtersModel,
+ { normalizeTarget: this.normalizeTarget }
);
if ( !mw.user.isAnon() ) {
} );
};
- /**
- * Switch the view of the filters model
- *
- * @param {string} view Requested view
- */
- mw.rcfilters.Controller.prototype.switchView = function ( view ) {
- this.filtersModel.switchView( view );
- };
-
/**
* Reset to default filters
*/
this.updateChangesList( null, 'markSeen' );
}.bind( this ) );
};
+
+ /**
+ * Set the current search for the system.
+ *
+ * @param {string} searchQuery Search query, including triggers
+ */
+ mw.rcfilters.Controller.prototype.setSearch = function ( searchQuery ) {
+ this.filtersModel.setSearch( searchQuery );
+ };
+
+ /**
+ * Switch the view by changing the search query trigger
+ * without changing the search term
+ *
+ * @param {string} view View to change to
+ */
+ mw.rcfilters.Controller.prototype.switchView = function ( view ) {
+ this.setSearch(
+ this.filtersModel.getViewTrigger( view ) +
+ this.filtersModel.removeViewTriggers( this.filtersModel.getSearch() )
+ );
+ };
+
+ /**
+ * Reset the search for a specific view. This means we null the search query
+ * and replace it with the relevant trigger for the requested view
+ *
+ * @param {string} [view='default'] View to change to
+ */
+ mw.rcfilters.Controller.prototype.resetSearchForView = function ( view ) {
+ view = view || 'default';
+
+ this.setSearch(
+ this.filtersModel.getViewTrigger( view )
+ );
+ };
}( mediaWiki, jQuery ) );