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