ResourceLoaderMediaWikiUtilModule (mediawiki.util): Fix loading in debug mode
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.LiveUpdateButtonWidget.js
1 ( function ( mw ) {
2 /**
3 * Widget for toggling live updates
4 *
5 * @extends OO.ui.ToggleButtonWidget
6 *
7 * @constructor
8 * @param {mw.rcfilters.Controller} controller
9 * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
10 * @param {Object} [config] Configuration object
11 */
12 mw.rcfilters.ui.LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, changesListModel, config ) {
13 config = config || {};
14
15 // Parent
16 mw.rcfilters.ui.LiveUpdateButtonWidget.parent.call( this, $.extend( {
17 icon: 'play',
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
31 /* Initialization */
32
33 OO.inheritClass( mw.rcfilters.ui.LiveUpdateButtonWidget, OO.ui.ToggleButtonWidget );
34
35 /* Methods */
36
37 /**
38 * Respond to the button being clicked
39 */
40 mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onClick = function () {
41 this.controller.toggleLiveUpdate();
42 };
43
44 /**
45 * Respond to the 'live update' feature being turned on/off
46 *
47 * @param {boolean} enable Whether the 'live update' feature is now on/off
48 */
49 mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onLiveUpdateChange = function ( enable ) {
50 this.setValue( enable );
51 this.setIcon( enable ? 'stop' : 'play' );
52 };
53
54 }( mediaWiki ) );