Fix order of @var parameter in PHP
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / MarkSeenButtonWidget.js
1 ( function () {
2 /**
3 * Button for marking all changes as seen on the Watchlist
4 *
5 * @class mw.rcfilters.ui.MarkSeenButtonWidget
6 * @extends OO.ui.ButtonWidget
7 *
8 * @constructor
9 * @param {mw.rcfilters.Controller} controller
10 * @param {mw.rcfilters.dm.ChangesListViewModel} model Changes list view model
11 * @param {Object} [config] Configuration object
12 */
13 var MarkSeenButtonWidget = function MwRcfiltersUiMarkSeenButtonWidget( controller, model, config ) {
14 config = config || {};
15
16 // Parent
17 MarkSeenButtonWidget.parent.call( this, $.extend( {
18 label: mw.message( 'rcfilters-watchlist-markseen-button' ).text(),
19 icon: 'checkAll'
20 }, config ) );
21
22 this.controller = controller;
23 this.model = model;
24
25 // Events
26 this.connect( this, { click: 'onClick' } );
27 this.model.connect( this, { update: 'onModelUpdate' } );
28
29 this.$element.addClass( 'mw-rcfilters-ui-markSeenButtonWidget' );
30
31 this.onModelUpdate();
32 };
33
34 /* Initialization */
35
36 OO.inheritClass( MarkSeenButtonWidget, OO.ui.ButtonWidget );
37
38 /* Methods */
39
40 /**
41 * Respond to the button being clicked
42 */
43 MarkSeenButtonWidget.prototype.onClick = function () {
44 this.controller.markAllChangesAsSeen();
45 // assume there's no more unseen changes until the next model update
46 this.setDisabled( true );
47 };
48
49 /**
50 * Respond to the model being updated with new changes
51 */
52 MarkSeenButtonWidget.prototype.onModelUpdate = function () {
53 this.setDisabled( !this.model.hasUnseenWatchedChanges() );
54 };
55
56 module.exports = MarkSeenButtonWidget;
57
58 }() );