MarkTraceur has uploaded a new change for review.

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

Change subject: Replace IframeTransport callbacks with OOJS events
......................................................................

Replace IframeTransport callbacks with OOJS events

Bug: T77124
Change-Id: Ic6d9f9dc4098c28de2d0e79af6ca91929d239bf2
---
M UploadWizard.php
M resources/mw.ApiUploadHandler.js
M resources/mw.IframeTransport.js
3 files changed, 15 insertions(+), 19 deletions(-)


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

diff --git a/UploadWizard.php b/UploadWizard.php
index 1f5dc63..0b49595 100644
--- a/UploadWizard.php
+++ b/UploadWizard.php
@@ -103,6 +103,9 @@
 
 $wgResourceModules['ext.uploadWizard.iFrameTransport'] = array(
        'scripts' => 'mw.IframeTransport.js',
+       'dependencies' => array(
+               'oojs',
+       ),
 ) + $uploadWizardModuleInfo;
 
 $wgResourceModules['ext.uploadWizard.apiUploadHandler'] = array(
diff --git a/resources/mw.ApiUploadHandler.js b/resources/mw.ApiUploadHandler.js
index f35816f..d0e42c6 100644
--- a/resources/mw.ApiUploadHandler.js
+++ b/resources/mw.ApiUploadHandler.js
@@ -24,16 +24,12 @@
                this.configureForm();
 
                this.transport = new mw.IframeTransport(
-                       this.$form,
-                       function ( fraction ) {
-                               handler.upload.setTransportProgress( fraction );
-                       },
-
-                       function ( result ) {
-                               handler.upload.setTransported( result );
-                       }
-               );
-
+                       this.$form
+               ).on( 'progress', function ( fraction ) {
+                       handler.upload.setTransportProgress( fraction );
+               } ).on( 'transported', function ( result ) {
+                       handler.upload.setTransported( result );
+               } );
        };
 
        mw.ApiUploadHandler.prototype = {
diff --git a/resources/mw.IframeTransport.js b/resources/mw.IframeTransport.js
index 858e2bc..f741622 100644
--- a/resources/mw.IframeTransport.js
+++ b/resources/mw.IframeTransport.js
@@ -1,15 +1,14 @@
 ( function ( mw, $ ) {
        /**
+        * @class mw.IframeTransport
         * Represents a "transport" for files to upload; in this case an iframe.
         * XXX dubious whether this is really separated from 
"ApiUploadHandler", which does a lot of form config.
         *
         * The iframe is made to be the target of a form so that the existing 
page does not reload, even though it's a POST.
-        * @param form  jQuery selector for HTML form
-        * @param progressCb    callback to execute when we've started. (does 
not do float here because iframes can't
-        *                                              monitor fractional 
progress).
-        * @param transportedCb callback to execute when we've finished the 
upload
+        * @constructor
+        * @param {jQuery} $form HTML form with the upload data.
         */
-       mw.IframeTransport = function ( $form, progressCb, transportedCb ) {
+       mw.IframeTransport = function ( $form ) {
                var iframe,
                        transport = this;
 
@@ -23,8 +22,6 @@
                }
 
                this.$form = $form;
-               this.progressCb = progressCb;
-               this.transportedCb = transportedCb;
                this.setUpStatus = $.Deferred();
 
                this.iframeId = 'f_' + ( $( 'iframe' ).length + 1 );
@@ -84,7 +81,7 @@
 
                        // Set up the completion callback
                        this.$iframe.load( function () {
-                               transport.progressCb( 1.0 );
+                               transport.emit( 'progress', 1.0 );
                                transport.processIframeResult( this );
                        } );
                },
@@ -132,7 +129,7 @@
                        }
 
                        // Process the API result
-                       this.transportedCb( response );
+                       this.emit( 'transported', response );
                }
        };
 }( mediaWiki, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6d9f9dc4098c28de2d0e79af6ca91929d239bf2
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