| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
const LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, changesListModel, config ) { |
| 13 |
config = config || {}; |
| 14 |
|
| 15 |
|
| 16 |
LiveUpdateButtonWidget.super.call( this, Object.assign( { |
| 17 |
label: mw.msg( 'rcfilters-liveupdates-button' ) |
| 18 |
}, config ) ); |
| 19 |
|
| 20 |
this.controller = controller; |
| 21 |
this.model = changesListModel; |
| 22 |
|
| 23 |
|
| 24 |
this.connect( this, { click: 'onClick' } ); |
| 25 |
this.model.connect( this, { liveUpdateChange: 'onLiveUpdateChange' } ); |
| 26 |
|
| 27 |
this.$element.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' ); |
| 28 |
|
| 29 |
this.setState( false ); |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
OO.inheritClass( LiveUpdateButtonWidget, OO.ui.ToggleButtonWidget ); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
LiveUpdateButtonWidget.prototype.onClick = function () { |
| 42 |
this.controller.toggleLiveUpdate(); |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
LiveUpdateButtonWidget.prototype.setState = function ( enable ) { |
| 51 |
this.setValue( enable ); |
| 52 |
this.setIcon( enable ? 'stop' : 'play' ); |
| 53 |
this.setTitle( mw.msg( |
| 54 |
enable ? |
| 55 |
'rcfilters-liveupdates-button-title-on' : |
| 56 |
'rcfilters-liveupdates-button-title-off' |
| 57 |
) ); |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
LiveUpdateButtonWidget.prototype.onLiveUpdateChange = function ( enable ) { |
| 66 |
this.setState( enable ); |
| 67 |
}; |
| 68 |
|
| 69 |
module.exports = LiveUpdateButtonWidget; |