Fix order of @var parameter in PHP
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / LiveUpdateButtonWidget.js
1 ( function () {
2 /**
3 * Widget for toggling live updates
4 *
5 * @class mw.rcfilters.ui.LiveUpdateButtonWidget
6 * @extends OO.ui.ToggleButtonWidget
7 *
8 * @constructor
9 * @param {mw.rcfilters.Controller} controller
10 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
11 * @param {Object} [config] Configuration object
12 */
13 var LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, changesListModel, config ) {
14 config = config || {};
15
16 // Parent
17 LiveUpdateButtonWidget.parent.call( this, $.extend( {
18 label: mw.message( 'rcfilters-liveupdates-button' ).text()
19 }, config ) );
20
21 this.controller = controller;
22 this.model = changesListModel;
23
24 // Events
25 this.connect( this, { click: 'onClick' } );
26 this.model.connect( this, { liveUpdateChange: 'onLiveUpdateChange' } );
27
28 this.$element.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' );
29
30 this.setState( false );
31 };
32
33 /* Initialization */
34
35 OO.inheritClass( LiveUpdateButtonWidget, OO.ui.ToggleButtonWidget );
36
37 /* Methods */
38
39 /**
40 * Respond to the button being clicked
41 */
42 LiveUpdateButtonWidget.prototype.onClick = function () {
43 this.controller.toggleLiveUpdate();
44 };
45
46 /**
47 * Set the button's state and change its appearance
48 *
49 * @param {boolean} enable Whether the 'live update' feature is now on/off
50 */
51 LiveUpdateButtonWidget.prototype.setState = function ( enable ) {
52 this.setValue( enable );
53 this.setIcon( enable ? 'stop' : 'play' );
54 this.setTitle( mw.message(
55 enable ?
56 'rcfilters-liveupdates-button-title-on' :
57 'rcfilters-liveupdates-button-title-off'
58 ).text() );
59 };
60
61 /**
62 * Respond to the 'live update' feature being turned on/off
63 *
64 * @param {boolean} enable Whether the 'live update' feature is now on/off
65 */
66 LiveUpdateButtonWidget.prototype.onLiveUpdateChange = function ( enable ) {
67 this.setState( enable );
68 };
69
70 module.exports = LiveUpdateButtonWidget;
71
72 }() );