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
18 mw
.rcfilters
.ui
.MainWrapperWidget
= function MwRcfiltersUiMainWrapperWidget(
19 controller
, model
, savedQueriesModel
, changesListModel
, config
21 config
= $.extend( {}, config
);
24 mw
.rcfilters
.ui
.MainWrapperWidget
.parent
.call( this, config
);
26 this.controller
= controller
;
28 this.changesListModel
= changesListModel
;
29 this.$topSection
= config
.$topSection
;
30 this.$filtersContainer
= config
.$filtersContainer
;
31 this.$changesListContainer
= config
.$changesListContainer
;
32 this.$formContainer
= config
.$formContainer
;
33 this.$overlay
= $( '<div>' ).addClass( 'mw-rcfilters-ui-overlay' );
35 this.savedLinksListWidget
= new mw
.rcfilters
.ui
.SavedLinksListWidget(
36 controller
, savedQueriesModel
, { $overlay
: this.$overlay
}
39 this.filtersWidget
= new mw
.rcfilters
.ui
.FilterWrapperWidget(
45 $overlay
: this.$overlay
49 this.changesListWidget
= new mw
.rcfilters
.ui
.ChangesListWrapperWidget(
50 model
, changesListModel
, controller
, this.$changesListContainer
);
54 // Toggle changes list overlay when filters menu opens/closes. We use overlay on changes list
55 // to prevent users from accidentally clicking on links in results, while menu is opened.
56 // Overlay on changes list is not the same as this.$overlay
57 this.filtersWidget
.connect( this, { menuToggle
: this.onFilterMenuToggle
.bind( this ) } );
60 this.$filtersContainer
.append( this.filtersWidget
.$element
);
62 .append( this.$overlay
)
63 .addClass( 'mw-rcfilters-ui-initialized' );
68 OO
.inheritClass( mw
.rcfilters
.ui
.MainWrapperWidget
, OO
.ui
.Widget
);
73 * Set the content of the top section, depending on the type of special page.
75 * @param {string} specialPage
77 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.setTopSection = function ( specialPage
) {
80 if ( specialPage
=== 'Recentchanges' ) {
81 topSection
= new mw
.rcfilters
.ui
.RcTopSectionWidget(
82 this.savedLinksListWidget
, this.$topSection
84 this.filtersWidget
.setTopSection( topSection
.$element
);
87 if ( specialPage
=== 'Recentchangeslinked' ) {
88 topSection
= new mw
.rcfilters
.ui
.RclTopSectionWidget(
89 this.savedLinksListWidget
, this.controller
,
90 this.model
.getGroup( 'toOrFrom' ).getItemByParamName( 'showlinkedto' ),
91 this.model
.getGroup( 'page' ).getItemByParamName( 'target' )
94 this.filtersWidget
.setTopSection( topSection
.$element
);
97 if ( specialPage
=== 'Watchlist' ) {
98 topSection
= new mw
.rcfilters
.ui
.WatchlistTopSectionWidget(
99 this.controller
, this.changesListModel
, this.savedLinksListWidget
, this.$topSection
102 this.filtersWidget
.setTopSection( topSection
.$element
);
107 * Filter menu toggle event listener
109 * @param {boolean} isVisible
111 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.onFilterMenuToggle = function ( isVisible
) {
112 this.changesListWidget
.toggleOverlay( isVisible
);
116 * Initialize FormWrapperWidget
118 * @return {mw.rcfilters.ui.FormWrapperWidget} Form wrapper widget
120 mw
.rcfilters
.ui
.MainWrapperWidget
.prototype.initFormWidget = function () {
121 return new mw
.rcfilters
.ui
.FormWrapperWidget(
122 this.model
, this.changesListModel
, this.controller
, this.$formContainer
);
124 }( jQuery
, mediaWiki
) );