MarkTraceur has uploaded a new change for review.

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

Change subject: Move some details UI stuff out of the Wizard UI
......................................................................

Move some details UI stuff out of the Wizard UI

Just a little bit of work, also moves one event around to a saner
spot.

Bug: T78057
Change-Id: Ib3253fd3c70df3c1cb2df25ae8343dfa5f1978d8
---
M resources/controller/uw.controller.Details.js
M resources/mw.UploadWizard.js
M resources/ui/uw.ui.Details.js
M resources/ui/uw.ui.Wizard.js
4 files changed, 82 insertions(+), 75 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/04/178604/1

diff --git a/resources/controller/uw.controller.Details.js 
b/resources/controller/uw.controller.Details.js
index 1a4c260..c985c25 100644
--- a/resources/controller/uw.controller.Details.js
+++ b/resources/controller/uw.controller.Details.js
@@ -27,10 +27,12 @@
        function Details() {
                uw.controller.Step.call(
                        this,
-                       new uw.ui.Step( $( '#mwe-upwiz-stepdiv-details' ), $( 
'#mwe-upwiz-step-details' ) )
+                       new uw.ui.Details()
+                               .connect( this, {
+                                       'start-details': [ 'emit', 
'start-details' ],
+                                       'finalize-details-after-removal': [ 
'emit', 'start-details' ]
+                               } )
                );
-
-               this.ui = new uw.ui.Details();
        }
 
        oo.inheritClass( Details, uw.controller.Step );
diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js
index d59f99b..d11c892 100644
--- a/resources/mw.UploadWizard.js
+++ b/resources/mw.UploadWizard.js
@@ -18,6 +18,13 @@
                var maxSimPref = mw.user.options.get( 'upwiz_maxsimultaneous' ),
                        wizard = this;
 
+               function finalizeDetails() {
+                       if ( wizard.allowCloseWindow !== undefined ) {
+                               wizard.allowCloseWindow();
+                       }
+                       wizard.moveToStep( 'thanks' );
+               }
+
                if ( maxSimPref === 'default' ) {
                        this.maxSimultaneousConnections = 
mw.UploadWizard.config.maxSimultaneousConnections;
                } else if ( maxSimPref > 0 ) {
@@ -35,7 +42,24 @@
                                } ),
                        file: new uw.controller.Upload(),
                        deeds: new uw.controller.Deed(),
-                       details: new uw.controller.Details(),
+
+                       details: new uw.controller.Details()
+                               .on( 'start-details', function () {
+                                       wizard.detailsValid( function () {
+                                               
wizard.steps.details.ui.hideEndButtons();
+                                               wizard.detailsSubmit( function 
() {
+                                                       
wizard.detailsErrorCount();
+                                                       wizard.showNext( 
'details', 'complete', finalizeDetails );
+                                               } );
+                                       }, function () {
+                                               wizard.detailsErrorCount();
+                                       } );
+                               } )
+
+                               .on( 'finalize-details-after-removal', function 
() {
+                                       wizard.removeErrorUploads( 
finalizeDetails );
+                               } ),
+
                        thanks: new uw.controller.Thanks()
                };
        };
@@ -67,13 +91,6 @@
                 */
                createInterface: function () {
                        var wizard = this;
-
-                       function finalizeDetails() {
-                               if ( wizard.allowCloseWindow !== undefined ) {
-                                       wizard.allowCloseWindow();
-                               }
-                               wizard.moveToStep( 'thanks' );
-                       }
 
                        this.ui = new uw.ui.Wizard( this )
                                .on( 'reset-wizard', function () {
@@ -125,22 +142,6 @@
                                        if ( wizard.deedChooser.valid() ) {
                                                wizard.moveToStep( 'details' );
                                        }
-                               } )
-
-                               .on( 'start-details', function () {
-                                       wizard.detailsValid( function () {
-                                               
wizard.ui.hideDetailsEndButtons();
-                                               wizard.detailsSubmit( function 
() {
-                                                       
wizard.detailsErrorCount();
-                                                       wizard.showNext( 
'details', 'complete', finalizeDetails );
-                                               } );
-                                       }, function () {
-                                               wizard.detailsErrorCount();
-                                       } );
-                               } )
-
-                               .on( 'finalize-details-after-removal', function 
() {
-                                       wizard.removeErrorUploads( 
finalizeDetails );
                                } );
 
                        // check to see if the the skip tutorial preference or 
global setting is set
diff --git a/resources/ui/uw.ui.Details.js b/resources/ui/uw.ui.Details.js
index 39e7ed8..eae634e 100644
--- a/resources/ui/uw.ui.Details.js
+++ b/resources/ui/uw.ui.Details.js
@@ -25,11 +25,54 @@
         * @constructor
         */
        function Details() {
+               var details = this;
+
+               function startDetails() {
+                       var isPopupOpen = false;
+
+                       $( '.categoryInput' ).each( function () {
+                               if ( $( this ).data( 'popupOpen' ) === true ) {
+                                       isPopupOpen = true;
+                                       $( this ).bind( 'popupClose', 
startDetails );
+                               }
+                       });
+
+                       if ( isPopupOpen ) {
+                               return;
+                       }
+
+                       $( '.mwe-upwiz-hint' ).each( function () { $( this 
).tipsy( 'hide' ); } ); // close tipsy help balloons
+
+                       details.emit( 'start-details' );
+               }
+
                ui.Step.call(
                        this,
                        $( '#mwe-upwiz-stepdiv-details' ),
                        $( '#mwe-upwiz-step-details' )
                );
+
+               this.$nextSomeFailed = this.$div
+                       .find( '.mwe-upwiz-file-next-some-failed' )
+                       .hide();
+
+               this.$nextAllFailed = this.$div
+                       .find( '.mwe-upwiz-file-next-all-failed' )
+                       .hide();
+
+               this.$nextButton = this.$div
+                       .find( '.mwe-upwiz-start-next .mwe-upwiz-button-next' )
+                       .click( startDetails );
+
+               this.$nextButtonDespiteFailures = this.$div
+                       .find( '.mwe-upwiz-buttons 
.mwe-upwiz-button-next-despite-failures' )
+                       .click( function () {
+                               details.emit( 'finalize-details-after-removal' 
);
+                       } );
+
+               this.$retryButton = this.$div
+                       .find( '.mwe-upwiz-buttons .mwe-upwiz-button-retry' )
+                       .click( startDetails );
        }
 
        oo.inheritClass( Details, ui.Step );
@@ -46,5 +89,14 @@
                this.$div.find( '.mwe-upwiz-start-next' ).show();
        };
 
+       /**
+        * Hide buttons for moving to the next step.
+        */
+       DP.hideEndButtons = function () {
+               this.$div
+                       .find( '.mwe-upwiz-buttons .mwe-upwiz-file-endchoice' )
+                       .hide();
+       };
+
        ui.Details = Details;
 }( mediaWiki, jQuery, mediaWiki.uploadWizard.ui, OO ) );
diff --git a/resources/ui/uw.ui.Wizard.js b/resources/ui/uw.ui.Wizard.js
index 3c4e138..9459b63 100644
--- a/resources/ui/uw.ui.Wizard.js
+++ b/resources/ui/uw.ui.Wizard.js
@@ -40,7 +40,6 @@
                this.initTutorial();
                this.initUpload();
                this.initDeeds();
-               this.initDetails();
        }
 
        oo.inheritClass( UploadWizardInterface, oo.EventEmitter );
@@ -252,57 +251,10 @@
        };
 
        /**
-        * Initialize the details step interface.
-        */
-       UWIP.initDetails = function () {
-               var ui = this;
-
-               function startDetails() {
-                       var isPopupOpen = false;
-
-                       $( '.categoryInput' ).each( function () {
-                               if ( $( this ).data( 'popupOpen' ) === true ) {
-                                       isPopupOpen = true;
-                                       $( this ).bind( 'popupClose', 
startDetails );
-                               }
-                       });
-
-                       if ( isPopupOpen ) {
-                               return;
-                       }
-
-                       $( '.mwe-upwiz-hint' ).each( function () { $( this 
).tipsy( 'hide' ); } ); // close tipsy help balloons
-
-                       ui.emit( 'start-details' );
-               }
-
-               $( '#mwe-upwiz-stepdiv-details 
.mwe-upwiz-file-next-some-failed' ).hide();
-               $( '#mwe-upwiz-stepdiv-details .mwe-upwiz-file-next-all-failed' 
).hide();
-
-               $( '#mwe-upwiz-stepdiv-details .mwe-upwiz-start-next 
.mwe-upwiz-button-next' )
-                       .click( startDetails );
-
-               $( '#mwe-upwiz-stepdiv-details .mwe-upwiz-buttons 
.mwe-upwiz-button-next-despite-failures' )
-                       .click( function () {
-                               ui.emit( 'finalize-details-after-removal' );
-                       } );
-
-               $( '#mwe-upwiz-stepdiv-details .mwe-upwiz-buttons 
.mwe-upwiz-button-retry' )
-                       .click( startDetails );
-       };
-
-       /**
         * Hide the button choices at the end of the file step.
         */
        UWIP.hideFileEndButtons = function () {
                $( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons 
.mwe-upwiz-file-endchoice' ).hide();
-       };
-
-       /**
-        * Hide the button choices at the end of the details step.
-        */
-       UWIP.hideDetailsEndButtons = function () {
-               $( '#mwe-upwiz-stepdiv-details .mwe-upwiz-buttons 
.mwe-upwiz-file-endchoice' ).hide();
        };
 
        ui.Wizard = UploadWizardInterface;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3253fd3c70df3c1cb2df25ae8343dfa5f1978d8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>

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

Reply via email to