RCFilters: show new changes
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.LiveUpdateButtonWidget.js
index 90ee4d7..67c113d 100644 (file)
@@ -6,9 +6,10 @@
         *
         * @constructor
         * @param {mw.rcfilters.Controller} controller
-        * @param {Object} config Configuration object
+        * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel
+        * @param {Object} [config] Configuration object
         */
-       mw.rcfilters.ui.LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, config ) {
+       mw.rcfilters.ui.LiveUpdateButtonWidget = function MwRcfiltersUiLiveUpdateButtonWidget( controller, changesListModel, config ) {
                config = config || {};
 
                // Parent
                }, config ) );
 
                this.controller = controller;
+               this.model = changesListModel;
 
                // Events
-               this.connect( this, { change: 'onChange' } );
+               this.connect( this, { click: 'onClick' } );
+               this.model.connect( this, { liveUpdateChange: 'onLiveUpdateChange' } );
 
                this.$element.addClass( 'mw-rcfilters-ui-liveUpdateButtonWidget' );
        };
        /* Methods */
 
        /**
-        * Respond to the button being toggled.
-        * @param {boolean} enable Whether the button is now pressed/enabled
+        * Respond to the button being clicked
         */
-       mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onChange = function ( enable ) {
-               this.controller.toggleLiveUpdate( enable );
+       mw.rcfilters.ui.LiveUpdateButtonWidget.prototype.onClick = function () {
+               this.controller.toggleLiveUpdate();
+       };
+
+       /**
+        * 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.setValue( enable );
+               this.setIcon( enable ? 'stop' : 'play' );
        };
 
 }( mediaWiki ) );