blob: 0fb3cb77c0e901a94cc0b3a6d9556dab3ce9d00e (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
( function ( mw ) {
/**
* Widget for toggling live updates
*
* @extends OO.ui.ToggleButtonWidget
*
* @constructor
* @param {mw.rcfilters.Controller} controller
* @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
* @param {Object} [config] Configuration object
*/
mw.rcfilters.ui.LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, changesListModel, config ) {
config = config || {};
// Parent
mw.rcfilters.ui.LiveUpdateButtonWidget.parent.call( this, $.extend( {
label: mw.message( 'rcfilters-liveupdates-button' ).text()
}, config ) );
this.controller = controller;
this.model = changesListModel;
// Events
this.connect( this, { click: 'onClick' } );
this.model.connect( this, { liveUpdateChange: 'onLiveUpdateChange' } );
this.$element.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' );
this.setState( false );
};
/* Initialization */
OO.inheritClass( mw.rcfilters.ui.LiveUpdateButtonWidget, OO.ui.ToggleButtonWidget );
/* Methods */
/**
* Respond to the button being clicked
*/
mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onClick = function () {
this.controller.toggleLiveUpdate();
};
/**
* Set the button's state and change its appearance
*
* @param {boolean} enable Whether the 'live update' feature is now on/off
*/
mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.setState = function ( enable ) {
this.setValue( enable );
this.setIcon( enable ? 'stop' : 'play' );
this.setTitle( mw.message(
enable ?
'rcfilters-liveupdates-button-title-on' :
'rcfilters-liveupdates-button-title-off'
).text() );
};
/**
* Respond to the 'live update' feature being turned on/off
*
* @param {boolean} enable Whether the 'live update' feature is now on/off
*/
mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onLiveUpdateChange = function ( enable ) {
this.setState( enable );
};
}( mediaWiki ) );
|