Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/203863

Change subject: Hygiene: Write ButtonWithSpinner as a View
......................................................................

Hygiene: Write ButtonWithSpinner as a View

Bug: T95490
Change-Id: Ie1bcd7180f565f77b9ec0506248ea3c25525fea5
---
M javascripts/ButtonWithSpinner.js
1 file changed, 37 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/63/203863/1

diff --git a/javascripts/ButtonWithSpinner.js b/javascripts/ButtonWithSpinner.js
index 11d47c3..e093d85 100644
--- a/javascripts/ButtonWithSpinner.js
+++ b/javascripts/ButtonWithSpinner.js
@@ -1,40 +1,47 @@
 ( function ( M ) {
-       /**
+       var ButtonWithSpinner,
+               View = M.require( 'View' );
+
+       function OOuiButtonWithSpinner( config ) {
+               OOuiButtonWithSpinner.super.call( this, config );
+       };
+       OO.inheritClass( OOuiButtonWithSpinner, OO.ui.ButtonWidget );
+
+       /*
         * Button with a spinner indicator
         * Behaves the same as OO.ui.Button widget. Also defines custom methods 
that show and hide
         * the spinner.
-        * @param {Object} config
+        * @Class ButtonWithSpinner
+        * @extends {Class}
+        * @uses {OO.ui}
         * @constructor
         */
-       var ButtonWithSpinner = function ( config ) {
-               ButtonWithSpinner.super.call( this, config );
-       };
-       OO.inheritClass( ButtonWithSpinner, OO.ui.ButtonWidget );
+       ButtonWithSpinner = View.extend( $.extend( {
+               initialize: OOuiButtonWithSpinner,
+               /**
+                * Hide the spinner and show the default label
+                */
+               showSpinner: function () {
+                       var originalWidth = this.$button.width();
 
-       /**
-        * Show the spinner and hide the label (and save the label for future 
use)
-        */
-       ButtonWithSpinner.prototype.showSpinner = function () {
-               var originalWidth = this.$button.width();
-
-               this.defaultLabel = this.getLabel();
-               // Don't let the button width change
-               this.$button.width( originalWidth );
-               this
-                       .setIndicator( 'spinner' )
-                       .setLabel( '' )
-                       .setDisabled( true );
-       };
-
-       /**
-        * Hide the spinner and show the default label
-        */
-       ButtonWithSpinner.prototype.hideSpinner = function () {
-               this
-                       .setIndicator( null )
-                       .setLabel( this.defaultLabel )
-                       .setDisabled( false );
-       };
+                       this.defaultLabel = this.getLabel();
+                       // Don't let the button width change
+                       this.$button.width( originalWidth );
+                       this
+                               .setIndicator( 'spinner' )
+                               .setLabel( '' )
+                               .setDisabled( true );
+               },
+               /**
+                * Show the spinner and hide the label (and save the label for 
future use)
+                */
+               hideSpinner: function () {
+                       this
+                               .setIndicator( null )
+                               .setLabel( this.defaultLabel )
+                               .setDisabled( false );
+               }
+       }, OO.ui.ButtonWidget.prototype ) );
 
        M.define( 'ButtonWithSpinner', ButtonWithSpinner );
 } ( mw.mobileFrontend ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/203863
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1bcd7180f565f77b9ec0506248ea3c25525fea5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to