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