1 var SavedLinksListWidget
= require( './SavedLinksListWidget.js' ),
2 FilterWrapperWidget
= require( './FilterWrapperWidget.js' ),
3 ChangesListWrapperWidget
= require( './ChangesListWrapperWidget.js' ),
4 RcTopSectionWidget
= require( './RcTopSectionWidget.js' ),
5 RclTopSectionWidget
= require( './RclTopSectionWidget.js' ),
6 WatchlistTopSectionWidget
= require( './WatchlistTopSectionWidget.js' ),
7 FormWrapperWidget
= require( './FormWrapperWidget.js' ),
11 * Wrapper for changes list content
13 * @class mw.rcfilters.ui.MainWrapperWidget
14 * @extends OO.ui.Widget
17 * @param {mw.rcfilters.Controller} controller Controller
18 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
19 * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
20 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
21 * @param {Object} config Configuration object
22 * @cfg {jQuery} $topSection Top section container
23 * @cfg {jQuery} $filtersContainer
24 * @cfg {jQuery} $changesListContainer
25 * @cfg {jQuery} $formContainer
26 * @cfg {boolean} [collapsed] Filter area is collapsed
27 * @cfg {jQuery} [$wrapper] A jQuery object for the wrapper of the general
28 * system. If not given, falls back to this widget's $element
30 MainWrapperWidget
= function MwRcfiltersUiMainWrapperWidget(
31 controller
, model
, savedQueriesModel
, changesListModel
, config
33 config
= $.extend( {}, config
);
36 MainWrapperWidget
.parent
.call( this, config
);
38 this.controller
= controller
;
40 this.changesListModel
= changesListModel
;
41 this.$topSection
= config
.$topSection
;
42 this.$filtersContainer
= config
.$filtersContainer
;
43 this.$changesListContainer
= config
.$changesListContainer
;
44 this.$formContainer
= config
.$formContainer
;
45 this.$overlay
= $( '<div>' ).addClass( 'mw-rcfilters-ui-overlay oo-ui-defaultOverlay' );
46 this.$wrapper
= config
.$wrapper
|| this.$element
;
48 this.savedLinksListWidget
= new SavedLinksListWidget(
49 controller
, savedQueriesModel
, { $overlay
: this.$overlay
}
52 this.filtersWidget
= new FilterWrapperWidget(
58 $overlay
: this.$overlay
,
59 $wrapper
: this.$wrapper
,
60 collapsed
: config
.collapsed
64 this.changesListWidget
= new ChangesListWrapperWidget(
65 model
, changesListModel
, controller
, this.$changesListContainer
);
69 // Toggle changes list overlay when filters menu opens/closes. We use overlay on changes list
70 // to prevent users from accidentally clicking on links in results, while menu is opened.
71 // Overlay on changes list is not the same as this.$overlay
72 this.filtersWidget
.connect( this, { menuToggle
: this.onFilterMenuToggle
.bind( this ) } );
75 this.$filtersContainer
.append( this.filtersWidget
.$element
);
77 .append( this.$overlay
)
78 .addClass( 'mw-rcfilters-ui-initialized' );
83 OO
.inheritClass( MainWrapperWidget
, OO
.ui
.Widget
);
88 * Set the content of the top section, depending on the type of special page.
90 * @param {string} specialPage
92 MainWrapperWidget
.prototype.setTopSection = function ( specialPage
) {
95 if ( specialPage
=== 'Recentchanges' ) {
96 topSection
= new RcTopSectionWidget(
97 this.savedLinksListWidget
, this.$topSection
99 this.filtersWidget
.setTopSection( topSection
.$element
);
102 if ( specialPage
=== 'Recentchangeslinked' ) {
103 topSection
= new RclTopSectionWidget(
104 this.savedLinksListWidget
, this.controller
,
105 this.model
.getGroup( 'toOrFrom' ).getItemByParamName( 'showlinkedto' ),
106 this.model
.getGroup( 'page' ).getItemByParamName( 'target' )
109 this.filtersWidget
.setTopSection( topSection
.$element
);
112 if ( specialPage
=== 'Watchlist' ) {
113 topSection
= new WatchlistTopSectionWidget(
114 this.controller
, this.changesListModel
, this.savedLinksListWidget
, this.$topSection
117 this.filtersWidget
.setTopSection( topSection
.$element
);
122 * Filter menu toggle event listener
124 * @param {boolean} isVisible
126 MainWrapperWidget
.prototype.onFilterMenuToggle = function ( isVisible
) {
127 this.changesListWidget
.toggleOverlay( isVisible
);
131 * Initialize FormWrapperWidget
133 * @return {mw.rcfilters.ui.FormWrapperWidget} Form wrapper widget
135 MainWrapperWidget
.prototype.initFormWidget = function () {
136 return new FormWrapperWidget(
137 this.model
, this.changesListModel
, this.controller
, this.$formContainer
);
140 module
.exports
= MainWrapperWidget
;