Merge "[search] Fix method call on null value"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.Upload.Dialog.js
index de005f8..53afca8 100644 (file)
         *
         * The dialog's closing promise can be used to get details of the upload.
         *
+        * If you want to use a different OO.ui.BookletLayout, for example the
+        * mw.ForeignStructuredUpload.BookletLayout, like in the case of of the upload
+        * interface in VisualEditor, you can pass it in the {@link #cfg-bookletClass}:
+        *
+        *     var uploadDialog = new mw.Upload.Dialog( {
+        *         bookletClass: mw.ForeignStructuredUpload.BookletLayout
+        *     } );
+        *
+        *
         * @class mw.Upload.Dialog
         * @uses mw.Upload
+        * @uses mw.Upload.BookletLayout
         * @extends OO.ui.ProcessDialog
+        * @cfg {Function} [bookletClass=mw.Upload.BookletLayout] Booklet class to be
+        *     used for the steps
+        * @cfg {Object} [booklet] Booklet constructor configuration
         */
        mw.Upload.Dialog = function ( config ) {
+               // Config initialization
+               config = $.extend( {
+                       bookletClass: mw.Upload.BookletLayout
+               }, config );
+
                // Parent constructor
                mw.Upload.Dialog.parent.call( this, config );
+
+               // Initialize
+               this.bookletClass = config.bookletClass;
+               this.bookletConfig = config.booklet;
        };
 
        /* Setup */
         * @return {mw.Upload.BookletLayout} An upload booklet
         */
        mw.Upload.Dialog.prototype.createUploadBooklet = function () {
-               return new mw.Upload.BookletLayout();
+               return new this.bookletClass( $.extend( {
+                       $overlay: this.$overlay
+               }, this.bookletConfig ) );
        };
 
        /**
        mw.Upload.Dialog.prototype.getSetupProcess = function ( data ) {
                return mw.Upload.Dialog.parent.prototype.getSetupProcess.call( this, data )
                        .next( function () {
-                               this.uploadBooklet.initialize();
+                               return this.uploadBooklet.initialize();
                        }, this );
        };