RCFilters: Basic implementation of live updates
[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 {Object} config Configuration object
10 */
11 mw.rcfilters.ui.LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, config ) {
12 config = config || {};
13
14 // Parent
15 mw.rcfilters.ui.LiveUpdateButtonWidget.parent.call( this, $.extend( {
16 icon: 'play',
17 label: mw.message( 'rcfilters-liveupdates-button' ).text()
18 } ), config );
19
20 this.controller = controller;
21
22 // Events
23 this.connect( this, { change: 'onChange' } );
24
25 this.$element.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' );
26 };
27
28 /* Initialization */
29
30 OO.inheritClass( mw.rcfilters.ui.LiveUpdateButtonWidget, OO.ui.ToggleButtonWidget );
31
32 /* Methods */
33
34 /**
35 * Respond to the button being toggled.
36 * @param {boolean} enable Whether the button is now pressed/enabled
37 */
38 mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onChange = function ( enable ) {
39 this.controller.toggleLiveUpdate( enable );
40 };
41
42 }( mediaWiki ) );