Merge "Improve "selfmove" message's wording"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FilterWrapperWidget.js
1 ( function ( mw ) {
2 /**
3 * List displaying all filter groups
4 *
5 * @extends OO.ui.Widget
6 * @mixins OO.ui.mixin.PendingElement
7 *
8 * @constructor
9 * @param {mw.rcfilters.Controller} controller Controller
10 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
11 * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
12 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
13 * @param {Object} [config] Configuration object
14 * @cfg {Object} [filters] A definition of the filter groups in this list
15 * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups
16 */
17 mw.rcfilters.ui.FilterWrapperWidget = function MwRcfiltersUiFilterWrapperWidget(
18 controller, model, savedQueriesModel, changesListModel, config
19 ) {
20 var $bottom;
21 config = config || {};
22
23 // Parent
24 mw.rcfilters.ui.FilterWrapperWidget.parent.call( this, config );
25 // Mixin constructors
26 OO.ui.mixin.PendingElement.call( this, config );
27
28 this.controller = controller;
29 this.model = model;
30 this.queriesModel = savedQueriesModel;
31 this.$overlay = config.$overlay || this.$element;
32
33 this.filterTagWidget = new mw.rcfilters.ui.FilterTagMultiselectWidget(
34 this.controller,
35 this.model,
36 this.queriesModel,
37 { $overlay: this.$overlay }
38 );
39
40 this.liveUpdateButton = new mw.rcfilters.ui.LiveUpdateButtonWidget(
41 this.controller,
42 changesListModel
43 );
44
45 this.numChangesWidget = new mw.rcfilters.ui.ChangesLimitButtonWidget(
46 this.controller,
47 this.model,
48 {
49 $overlay: this.$overlay
50 }
51 );
52
53 this.dateWidget = new mw.rcfilters.ui.DateButtonWidget(
54 this.controller,
55 this.model,
56 {
57 $overlay: this.$overlay
58 }
59 );
60
61 // Initialize
62 this.$top = $( '<div>' )
63 .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top' );
64
65 $bottom = $( '<div>' )
66 .addClass( 'mw-rcfilters-ui-filterWrapperWidget-bottom' )
67 .append(
68 this.numChangesWidget.$element,
69 this.dateWidget.$element
70 );
71
72 if ( mw.rcfilters.featureFlags.liveUpdate ) {
73 $bottom.append( this.liveUpdateButton.$element );
74 }
75
76 this.$element
77 .addClass( 'mw-rcfilters-ui-filterWrapperWidget' )
78 .append(
79 this.$top,
80 this.filterTagWidget.$element,
81 $bottom
82 );
83 };
84
85 /* Initialization */
86
87 OO.inheritClass( mw.rcfilters.ui.FilterWrapperWidget, OO.ui.Widget );
88 OO.mixinClass( mw.rcfilters.ui.FilterWrapperWidget, OO.ui.mixin.PendingElement );
89
90 /* Methods */
91
92 /**
93 * Set the content of the top section
94 *
95 * @param {jQuery} $topSectionElement
96 */
97 mw.rcfilters.ui.FilterWrapperWidget.prototype.setTopSection = function ( $topSectionElement ) {
98 this.$top.append( $topSectionElement );
99 };
100 }( mediaWiki ) );