Files
edx-platform/lms/static/js/verify_student/views/progress_view.js
Will Daly 2ea2b8f674 Add JSON end-point for shoppingcart receipt information
Add enrollment confirmation page

Fix progress update

Add order info to the payment confirmation page.
2014-12-16 20:40:13 -05:00

68 lines
1.7 KiB
JavaScript

/**
* Show progress steps in the payment/verification flow.
*/
var edx = edx || {};
(function( $, _, Backbone, gettext ) {
'use strict';
edx.verify_student = edx.verify_student || {};
edx.verify_student.ProgressView = Backbone.View.extend({
template: '#progress-tpl',
initialize: function( obj ) {
this.displaySteps = obj.displaySteps || {};
this.currentStepIndex = obj.currentStepIndex || 0;
},
nextStep: function() {
this.currentStepIndex = Math.min(
this.currentStepIndex + 1,
this.displaySteps.length - 1
);
},
goToStep: function( stepName ) {
var stepIndex = _.indexOf(
_.pluck( this.displaySteps, 'name' ),
stepName
);
if ( stepIndex >= 0 ) {
this.currentStepIndex = stepIndex;
}
},
render: function() {
var renderedHtml, context;
context = {
steps: this.steps()
};
renderedHtml = _.template( $(this.template).html(), context );
$(this.el).html(renderedHtml);
},
steps: function() {
var i,
stepDescription,
steps = [];
for ( i = 0; i < this.displaySteps.length; i++ ) {
stepDescription = {
title: this.displaySteps[i].title,
isCurrent: (i === this.currentStepIndex ),
isComplete: (i < this.currentStepIndex )
};
steps.push(stepDescription);
}
return steps;
}
});
})( $, _, Backbone, gettext );