3 * Wrapper for changes list content
5 * @extends OO.ui.Widget
8 * @param {mw.rcfilters.Controller} controller Controller
9 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
10 * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
11 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
12 * @param {Object} config Configuration object
13 * @cfg {jQuery} $topSection Top section container
14 * @cfg {jQuery} $filtersContainer
15 * @cfg {jQuery} $changesListContainer
16 * @cfg {jQuery} $formContainer
17 * @cfg {boolean} [collapsed] Filter area is collapsed
18 * @cfg {jQuery} [$wrapper] A jQuery object for the wrapper of the general
19 * system. If not given, falls back to this widget's $element
21 mw
.rcfilters
.ui
.MainWrapperWidget
= function MwRcfiltersUiMainWrapperWidget(
22 controller
, model
, savedQueriesModel
, changesListModel
, config
24 config
= $.extend( {}, config
);
27 mw
.rcfilters
.ui
.MainWrapperWidget
.parent
.call( this, config
);
29 this.controller
= controller
;
31 this.changesListModel
= changesListModel
;
32 this.$topSection
= config
.$topSection
;
33 this.$filtersContainer
= config
.$filtersContainer
;
34 this.$changesListContainer
= config
.$changesListContainer
;
35 this.$formContainer
= config
.$formContainer
;
36 this.$overlay
= $( '<div>' ).addClass( 'mw-rcfilters-ui-overlay' );
37 this.$wrapper
= config
.$wrapper
|| this.$element
;
39 this.savedLinksListWidget
= new mw
.rcfilters
.ui
.SavedLinksListWidget(
40 controller
, savedQueriesModel
, { $overlay
: this.$overlay
}
43 this.filtersWidget
= new mw
.rcfilters
.ui
.FilterWrapperWidget(
49 $overlay
: this.$overlay
,
50 $wrapper
: this.$wrapper
,
51 collapsed
: config
.collapsed
55 this.changesListWidget
= new mw
.rcfilters
.ui
.ChangesListWrapperWidget(
56 model
, changesListModel
, controller
, this.$changesListContainer
);
60 // Toggle changes list overlay when filters menu opens/closes. We use overlay on changes list
61 // to prevent users from accidentally clicking on links in results, while menu is opened.
62 // Overlay on changes list is not the same as this.$overlay
63 this.filtersWidget
.connect( this, { menuToggle
: this.onFilterMenuToggle
.bind( this ) } );
66 this.$filtersContainer
.append( this.filtersWidget
.$element
);
68 .append( this.$overlay
)
69 .addClass( 'mw-rcfilters-ui-initialized' );
74 OO
.inheritClass( mw
.rcfilters
.ui
.MainWrapperWidget
, OO
.ui
.Widget
);
79 * Set the content of the top section, depending on the type of special page.
81 * @param {string} specialPage
83 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.setTopSection = function ( specialPage
) {
86 if ( specialPage
=== 'Recentchanges' ) {
87 topSection
= new mw
.rcfilters
.ui
.RcTopSectionWidget(
88 this.savedLinksListWidget
, this.$topSection
90 this.filtersWidget
.setTopSection( topSection
.$element
);
93 if ( specialPage
=== 'Recentchangeslinked' ) {
94 topSection
= new mw
.rcfilters
.ui
.RclTopSectionWidget(
95 this.savedLinksListWidget
, this.controller
,
96 this.model
.getGroup( 'toOrFrom' ).getItemByParamName( 'showlinkedto' ),
97 this.model
.getGroup( 'page' ).getItemByParamName( 'target' )
100 this.filtersWidget
.setTopSection( topSection
.$element
);
103 if ( specialPage
=== 'Watchlist' ) {
104 topSection
= new mw
.rcfilters
.ui
.WatchlistTopSectionWidget(
105 this.controller
, this.changesListModel
, this.savedLinksListWidget
, this.$topSection
108 this.filtersWidget
.setTopSection( topSection
.$element
);
113 * Filter menu toggle event listener
115 * @param {boolean} isVisible
117 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.onFilterMenuToggle = function ( isVisible
) {
118 this.changesListWidget
.toggleOverlay( isVisible
);
122 * Initialize FormWrapperWidget
124 * @return {mw.rcfilters.ui.FormWrapperWidget} Form wrapper widget
126 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.initFormWidget = function () {
127 return new mw
.rcfilters
.ui
.FormWrapperWidget(
128 this.model
, this.changesListModel
, this.controller
, this.$formContainer
);