' )
.attr( 'id', 'mwe-upwiz-stepdiv-' + this.name )
.addClass( 'mwe-upwiz-stepdiv' )
.hide();
$( '#mwe-upwiz-content' ).append( this.$div );
this.$arrow = $( '
' )
.attr( 'id', 'mwe-upwiz-step-' + this.name )
.append(
$( '' ).text( mw.message( 'mwe-upwiz-step-' + this.name ).text() )
);
$( '#mwe-upwiz-steps' ).append( this.$arrow );
// this will make sure that buttons will only be added if they've been
// set in the controller, otherwise there's nowhere to go...
this.nextButtonPromise = $.Deferred();
this.previousButtonPromise = $.Deferred();
};
OO.mixinClass( uw.ui.Step, OO.EventEmitter );
/**
* Initialize this step.
*
* @param {mw.UploadWizardUpload[]} uploads
*/
uw.ui.Step.prototype.load = function ( uploads ) {
var offset = $( 'h1:first' ).offset();
this.movedFrom = false;
this.uploads = uploads;
this.$div.append( this.$buttons ).show();
$( '#mwe-upwiz-steps' ).arrowStepsHighlight( this.$arrow );
$( 'html, body' ).animate( {
scrollTop: offset.top,
scrollLeft: offset.left
}, 'slow' );
};
/**
* Cleanup this step.
*/
uw.ui.Step.prototype.unload = function () {
this.movedFrom = true;
this.$div.children().detach();
};
uw.ui.Step.prototype.enableNextButton = function () {
this.nextButtonPromise.resolve();
};
uw.ui.Step.prototype.enablePreviousButton = function () {
this.previousButtonPromise.resolve();
};
/**
* Add a 'next' button to the step's button container
*/
uw.ui.Step.prototype.addNextButton = function () {
var ui = this;
this.nextButton = new OO.ui.ButtonWidget( {
classes: [ 'mwe-upwiz-button-next' ],
label: mw.message( 'mwe-upwiz-next' ).text(),
flags: [ 'progressive', 'primary' ]
} ).on( 'click', function () {
ui.emit( 'next-step' );
} );
this.nextButtonPromise.done( function () {
ui.$buttons.append( ui.nextButton.$element );
} );
};
/**
* Add a 'previous' button to the step's button container
*/
uw.ui.Step.prototype.addPreviousButton = function () {
var ui = this;
this.previousButton = new OO.ui.ButtonWidget( {
classes: [ 'mwe-upwiz-button-previous' ],
label: mw.message( 'mwe-upwiz-previous' ).text()
} ).on( 'click', function () {
ui.emit( 'previous-step' );
} );
this.previousButtonPromise.done( function () {
ui.$buttons.append( ui.previousButton.$element );
} );
};
}( mediaWiki, jQuery, mediaWiki.uploadWizard, OO ) );