X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fmw.rcfilters.Controller.js;h=4b78175064eead4ad15c4005dd539b371be8016f;hp=aa768f7480354ec4ca44703703c258f4675e31f2;hb=fe4b09380562976aea9f06e59d342fff8d91b026;hpb=ca2a24cf172313d69908f7e98cbc4a0eab2f5130 diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index aa768f7480..4b78175064 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -410,15 +410,6 @@ } ); }; - /** - * 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 */ @@ -1174,4 +1165,40 @@ 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 ) );