3 * Widget for toggling live updates
5 * @class mw.rcfilters.ui.LiveUpdateButtonWidget
6 * @extends OO.ui.ToggleButtonWidget
9 * @param {mw.rcfilters.Controller} controller
10 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
11 * @param {Object} [config] Configuration object
13 var LiveUpdateButtonWidget
= function MwRcfiltersUiLiveUpdateButtonWidget( controller
, changesListModel
, config
) {
14 config
= config
|| {};
17 LiveUpdateButtonWidget
.parent
.call( this, $.extend( {
18 label
: mw
.message( 'rcfilters-liveupdates-button' ).text()
21 this.controller
= controller
;
22 this.model
= changesListModel
;
25 this.connect( this, { click
: 'onClick' } );
26 this.model
.connect( this, { liveUpdateChange
: 'onLiveUpdateChange' } );
28 this.$element
.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' );
30 this.setState( false );
35 OO
.inheritClass( LiveUpdateButtonWidget
, OO
.ui
.ToggleButtonWidget
);
40 * Respond to the button being clicked
42 LiveUpdateButtonWidget
.prototype.onClick = function () {
43 this.controller
.toggleLiveUpdate();
47 * Set the button's state and change its appearance
49 * @param {boolean} enable Whether the 'live update' feature is now on/off
51 LiveUpdateButtonWidget
.prototype.setState = function ( enable
) {
52 this.setValue( enable
);
53 this.setIcon( enable
? 'stop' : 'play' );
54 this.setTitle( mw
.message(
56 'rcfilters-liveupdates-button-title-on' :
57 'rcfilters-liveupdates-button-title-off'
62 * Respond to the 'live update' feature being turned on/off
64 * @param {boolean} enable Whether the 'live update' feature is now on/off
66 LiveUpdateButtonWidget
.prototype.onLiveUpdateChange = function ( enable
) {
67 this.setState( enable
);
70 module
.exports
= LiveUpdateButtonWidget
;