2 var SavedLinksListWidget
= require( './SavedLinksListWidget.js' ),
3 FilterWrapperWidget
= require( './FilterWrapperWidget.js' ),
4 ChangesListWrapperWidget
= require( './ChangesListWrapperWidget.js' ),
5 RcTopSectionWidget
= require( './RcTopSectionWidget.js' ),
6 RclTopSectionWidget
= require( './RclTopSectionWidget.js' ),
7 WatchlistTopSectionWidget
= require( './WatchlistTopSectionWidget.js' ),
8 FormWrapperWidget
= require( './FormWrapperWidget.js' ),
12 * Wrapper for changes list content
14 * @class mw.rcfilters.ui.MainWrapperWidget
15 * @extends OO.ui.Widget
18 * @param {mw.rcfilters.Controller} controller Controller
19 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
20 * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
21 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
22 * @param {Object} config Configuration object
23 * @cfg {jQuery} $topSection Top section container
24 * @cfg {jQuery} $filtersContainer
25 * @cfg {jQuery} $changesListContainer
26 * @cfg {jQuery} $formContainer
27 * @cfg {boolean} [collapsed] Filter area is collapsed
28 * @cfg {jQuery} [$wrapper] A jQuery object for the wrapper of the general
29 * system. If not given, falls back to this widget's $element
31 MainWrapperWidget
= function MwRcfiltersUiMainWrapperWidget(
32 controller
, model
, savedQueriesModel
, changesListModel
, config
34 config
= $.extend( {}, config
);
37 MainWrapperWidget
.parent
.call( this, config
);
39 this.controller
= controller
;
41 this.changesListModel
= changesListModel
;
42 this.$topSection
= config
.$topSection
;
43 this.$filtersContainer
= config
.$filtersContainer
;
44 this.$changesListContainer
= config
.$changesListContainer
;
45 this.$formContainer
= config
.$formContainer
;
46 this.$overlay
= $( '<div>' ).addClass( 'mw-rcfilters-ui-overlay' );
47 this.$wrapper
= config
.$wrapper
|| this.$element
;
49 this.savedLinksListWidget
= new SavedLinksListWidget(
50 controller
, savedQueriesModel
, { $overlay
: this.$overlay
}
53 this.filtersWidget
= new FilterWrapperWidget(
59 $overlay
: this.$overlay
,
60 $wrapper
: this.$wrapper
,
61 collapsed
: config
.collapsed
65 this.changesListWidget
= new ChangesListWrapperWidget(
66 model
, changesListModel
, controller
, this.$changesListContainer
);
70 // Toggle changes list overlay when filters menu opens/closes. We use overlay on changes list
71 // to prevent users from accidentally clicking on links in results, while menu is opened.
72 // Overlay on changes list is not the same as this.$overlay
73 this.filtersWidget
.connect( this, { menuToggle
: this.onFilterMenuToggle
.bind( this ) } );
76 this.$filtersContainer
.append( this.filtersWidget
.$element
);
78 .append( this.$overlay
)
79 .addClass( 'mw-rcfilters-ui-initialized' );
84 OO
.inheritClass( MainWrapperWidget
, OO
.ui
.Widget
);
89 * Set the content of the top section, depending on the type of special page.
91 * @param {string} specialPage
93 MainWrapperWidget
.prototype.setTopSection = function ( specialPage
) {
96 if ( specialPage
=== 'Recentchanges' ) {
97 topSection
= new RcTopSectionWidget(
98 this.savedLinksListWidget
, this.$topSection
100 this.filtersWidget
.setTopSection( topSection
.$element
);
103 if ( specialPage
=== 'Recentchangeslinked' ) {
104 topSection
= new RclTopSectionWidget(
105 this.savedLinksListWidget
, this.controller
,
106 this.model
.getGroup( 'toOrFrom' ).getItemByParamName( 'showlinkedto' ),
107 this.model
.getGroup( 'page' ).getItemByParamName( 'target' )
110 this.filtersWidget
.setTopSection( topSection
.$element
);
113 if ( specialPage
=== 'Watchlist' ) {
114 topSection
= new WatchlistTopSectionWidget(
115 this.controller
, this.changesListModel
, this.savedLinksListWidget
, this.$topSection
118 this.filtersWidget
.setTopSection( topSection
.$element
);
123 * Filter menu toggle event listener
125 * @param {boolean} isVisible
127 MainWrapperWidget
.prototype.onFilterMenuToggle = function ( isVisible
) {
128 this.changesListWidget
.toggleOverlay( isVisible
);
132 * Initialize FormWrapperWidget
134 * @return {mw.rcfilters.ui.FormWrapperWidget} Form wrapper widget
136 MainWrapperWidget
.prototype.initFormWidget = function () {
137 return new FormWrapperWidget(
138 this.model
, this.changesListModel
, this.controller
, this.$formContainer
);
141 module
.exports
= MainWrapperWidget
;