jenkins-bot has submitted this change and it was merged.

Change subject: Hygiene: UploadTutorial should use events map
......................................................................


Hygiene: UploadTutorial should use events map

Change-Id: Ia7867a649cf88ed8728db5d68e2a9a6d4331fc63
---
M javascripts/modules/uploads/UploadTutorial.js
M tests/qunit/modules/uploads/test_UploadTutorial.js
2 files changed, 24 insertions(+), 18 deletions(-)

Approvals:
  Bmansurov: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/javascripts/modules/uploads/UploadTutorial.js 
b/javascripts/modules/uploads/UploadTutorial.js
index 101c7c2..1017b08 100644
--- a/javascripts/modules/uploads/UploadTutorial.js
+++ b/javascripts/modules/uploads/UploadTutorial.js
@@ -18,6 +18,12 @@
                template: mw.template.get( 'mobile.uploads', 
'UploadTutorial.hogan' ),
                className: 'overlay carousel tutorial content-overlay',
 
+               /** @inheritdoc */
+               events: {
+                       'click .prev': 'onPreviousClick',
+                       'click .next': 'onNextClick',
+                       'click .button': 'onClickUploadButton'
+               },
                /**
                 * @inheritdoc
                 * @cfg {Object} defaults Default options hash.
@@ -59,8 +65,7 @@
 
                /** @inheritdoc */
                postRender: function ( options ) {
-                       var self = this,
-                               $button = this.$( '.button' );
+                       var $button = this.$( '.button' );
 
                        if ( options.funnel ) {
                                new LeadPhotoUploaderButton( {
@@ -68,20 +73,11 @@
                                        buttonCaption: buttonMsg,
                                        funnel: options.funnel
                                } );
-                               $button.on( 'click', function () {
-                                       // need timeout for the file dialog to 
open
-                                       setTimeout( $.proxy( self, 'hide' ), 0 
);
-                                       setTimeout( $.proxy( self, 'emit', 
'hide' ), 0 );
-                               } );
                        }
 
                        this.page = 0;
                        this.totalPages = options.pages.length;
-                       this.$( '.prev' ).on( 'click', $.proxy( this, 
'previous' ) );
-                       this.$( '.next' ).on( 'click', $.proxy( this, 'next' ) 
);
-
                        this._showCurrentPage();
-
                        Overlay.prototype.postRender.apply( this, arguments );
                },
 
@@ -97,10 +93,20 @@
                },
 
                /**
+                * Event that is fired when clicking the final button at the 
end of the tutorial.
+                * @method
+                */
+               onClickUploadButton: function () {
+                       // need timeout for the file dialog to open
+                       setTimeout( $.proxy( this, 'hide' ), 0 );
+                       setTimeout( $.proxy( this, 'emit', 'hide' ), 0 );
+               },
+
+               /**
                 * Show next page of the tutorial
                 * @method
                 */
-               next: function () {
+               onNextClick: function () {
                        this.page += 1;
                        this._showCurrentPage();
                },
@@ -109,7 +115,7 @@
                 * Show previous page of the tutorial
                 * @method
                 */
-               previous: function () {
+               onPreviousClick: function () {
                        this.page -= 1;
                        this._showCurrentPage();
                }
diff --git a/tests/qunit/modules/uploads/test_UploadTutorial.js 
b/tests/qunit/modules/uploads/test_UploadTutorial.js
index 2050e7b..62f01e2 100644
--- a/tests/qunit/modules/uploads/test_UploadTutorial.js
+++ b/tests/qunit/modules/uploads/test_UploadTutorial.js
@@ -22,16 +22,16 @@
                assert.ok( !uploadTutorial.$( '.cancel' ).length, 'Has no 
cancel button' );
        } );
 
-       QUnit.test( '#next', 3, function ( assert ) {
+       QUnit.test( '#onNextClick', 3, function ( assert ) {
                assert.ok( uploadTutorial.$( '.slide' ).eq( 0 ).hasClass( 
'active' ), 'Initialises to page 0' );
-               uploadTutorial.next();
+               uploadTutorial.onNextClick();
                assert.ok( !uploadTutorial.$( '.slide' ).eq( 0 ).hasClass( 
'active' ), 'Deactivates page 0' );
                assert.ok( uploadTutorial.$( '.slide' ).eq( 1 ).hasClass( 
'active' ), 'Progresses to page 1' );
        } );
 
-       QUnit.test( '#previous', 2, function ( assert ) {
-               uploadTutorial.next();
-               uploadTutorial.previous();
+       QUnit.test( '#onPreviousClick', 2, function ( assert ) {
+               uploadTutorial.onNextClick();
+               uploadTutorial.onPreviousClick();
                assert.ok( !uploadTutorial.$( '.slide' ).eq( 1 ).hasClass( 
'active' ), 'Deactivates page 1' );
                assert.ok( uploadTutorial.$( '.slide' ).eq( 0 ).hasClass( 
'active' ), 'Back to page 1' );
        } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7867a649cf88ed8728db5d68e2a9a6d4331fc63
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to