Commit 1ceb8a0d by Peter Fogg Committed by cahrens

Optimize finish_auth_factory.

TNL-2602
parent 4f0ab6f9
...@@ -1275,9 +1275,6 @@ student_account_js = [ ...@@ -1275,9 +1275,6 @@ student_account_js = [
'js/src/accessibility_tools.js', 'js/src/accessibility_tools.js',
'js/src/ie_shim.js', 'js/src/ie_shim.js',
'js/src/string_utils.js', 'js/src/string_utils.js',
'js/student_account/enrollment.js',
'js/student_account/emailoptin.js',
'js/student_account/shoppingcart.js',
'js/student_account/models/LoginModel.js', 'js/student_account/models/LoginModel.js',
'js/student_account/models/RegisterModel.js', 'js/student_account/models/RegisterModel.js',
'js/student_account/models/PasswordResetModel.js', 'js/student_account/models/PasswordResetModel.js',
......
...@@ -373,18 +373,6 @@ ...@@ -373,18 +373,6 @@
'js/models/notification', 'jquery.fileupload' 'js/models/notification', 'jquery.fileupload'
] ]
}, },
'js/student_account/enrollment': {
exports: 'edx.student.account.EnrollmentInterface',
deps: ['jquery', 'jquery.cookie']
},
'js/student_account/emailoptin': {
exports: 'edx.student.account.EmailOptInInterface',
deps: ['jquery', 'jquery.cookie']
},
'js/student_account/shoppingcart': {
exports: 'edx.student.account.ShoppingCartInterface',
deps: ['jquery', 'jquery.cookie', 'underscore']
},
// Student account registration/login // Student account registration/login
// Loaded explicitly until these are converted to RequireJS // Loaded explicitly until these are converted to RequireJS
'js/student_account/views/FormView': { 'js/student_account/views/FormView': {
......
...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'], ...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'],
function( AjaxHelpers, EmailOptInInterface ) { function( AjaxHelpers, EmailOptInInterface ) {
'use strict'; 'use strict';
describe( 'edx.student.account.EmailOptInInterface', function() { describe( 'EmailOptInInterface', function() {
var COURSE_KEY = 'edX/DemoX/Fall', var COURSE_KEY = 'edX/DemoX/Fall',
EMAIL_OPT_IN = 'True', EMAIL_OPT_IN = 'True',
......
...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'], ...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
function( AjaxHelpers, EnrollmentInterface ) { function( AjaxHelpers, EnrollmentInterface ) {
'use strict'; 'use strict';
describe( 'edx.student.account.EnrollmentInterface', function() { describe( 'EnrollmentInterface', function() {
var COURSE_KEY = 'edX/DemoX/Fall', var COURSE_KEY = 'edX/DemoX/Fall',
ENROLL_URL = '/api/commerce/v0/baskets/', ENROLL_URL = '/api/commerce/v0/baskets/',
......
...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart' ...@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'
function(AjaxHelpers, ShoppingCartInterface) { function(AjaxHelpers, ShoppingCartInterface) {
'use strict'; 'use strict';
describe( 'edx.student.account.ShoppingCartInterface', function() { describe( 'ShoppingCartInterface', function() {
var COURSE_KEY = "edX/DemoX/Fall", var COURSE_KEY = "edX/DemoX/Fall",
ADD_COURSE_URL = "/shoppingcart/add/course/edX/DemoX/Fall/", ADD_COURSE_URL = "/shoppingcart/add/course/edX/DemoX/Fall/",
......
var edx = edx || {}; ;(function (define) {
(function($) {
'use strict'; 'use strict';
define(['jquery', 'jquery.cookie'], function($) {
edx.student = edx.student || {}; var EmailOptInInterface = {
edx.student.account = edx.student.account || {};
edx.student.account.EmailOptInInterface = {
urls: { urls: {
emailOptInUrl: '/user_api/v1/preferences/email_opt_in/' emailOptInUrl: '/user_api/v1/preferences/email_opt_in/'
...@@ -31,4 +27,7 @@ var edx = edx || {}; ...@@ -31,4 +27,7 @@ var edx = edx || {};
}); });
} }
}; };
})(jQuery);
return EmailOptInInterface;
});
}).call(this, define || RequireJS.define);
var edx = edx || {}; ;(function (define) {
(function($) {
'use strict'; 'use strict';
define(['jquery', 'jquery.cookie'], function($) {
edx.student = edx.student || {}; var EnrollmentInterface = {
edx.student.account = edx.student.account || {};
edx.student.account.EnrollmentInterface = {
urls: { urls: {
baskets: '/api/commerce/v0/baskets/', baskets: '/api/commerce/v0/baskets/',
...@@ -32,8 +28,7 @@ var edx = edx || {}; ...@@ -32,8 +28,7 @@ var edx = edx || {};
data: data, data: data,
headers: this.headers, headers: this.headers,
context: this context: this
}) }).fail(function( jqXHR ) {
.fail(function( jqXHR ) {
var responseData = JSON.parse(jqXHR.responseText); var responseData = JSON.parse(jqXHR.responseText);
if ( jqXHR.status === 403 && responseData.user_message_url ) { if ( jqXHR.status === 403 && responseData.user_message_url ) {
// Check if we've been blocked from the course // Check if we've been blocked from the course
...@@ -47,8 +42,7 @@ var edx = edx || {}; ...@@ -47,8 +42,7 @@ var edx = edx || {};
this.redirect( redirectUrl ); this.redirect( redirectUrl );
} }
} }
}) }).done(function() {
.done(function() {
// If we successfully enrolled, redirect the user // If we successfully enrolled, redirect the user
// to the next page (usually the student dashboard or payment flow) // to the next page (usually the student dashboard or payment flow)
if ( redirectUrl ) { if ( redirectUrl ) {
...@@ -65,4 +59,7 @@ var edx = edx || {}; ...@@ -65,4 +59,7 @@ var edx = edx || {};
window.location.href = url; window.location.href = url;
} }
}; };
})(jQuery);
return EnrollmentInterface;
});
}).call(this, define || RequireJS.define);
/** /**
* Use the shopping cart to purchase courses. * Use the shopping cart to purchase courses.
*/ */
;(function (define) {
var edx = edx || {};
(function($) {
'use strict'; 'use strict';
define(['jquery', 'jquery.cookie'], function($) {
edx.student = edx.student || {}; var ShoppingCartInterface = {
edx.student.account = edx.student.account || {};
edx.student.account.ShoppingCartInterface = {
urls: { urls: {
viewCart: "/shoppingcart/", viewCart: "/shoppingcart/",
addCourse: "/shoppingcart/add/course/" addCourse: "/shoppingcart/add/course/"
...@@ -46,4 +40,6 @@ var edx = edx || {}; ...@@ -46,4 +40,6 @@ var edx = edx || {};
} }
}; };
})(jQuery); return ShoppingCartInterface;
});
}).call(this, define || RequireJS.define);
...@@ -26,18 +26,14 @@ ...@@ -26,18 +26,14 @@
;(function (define, undefined) { ;(function (define, undefined) {
'use strict'; 'use strict';
define([ define([
'jquery',
'underscore', 'underscore',
'backbone', 'backbone',
'gettext', 'gettext',
'js/student_account/emailoptin', 'js/student_account/emailoptin',
'js/student_account/enrollment', 'js/student_account/enrollment',
'js/student_account/shoppingcart' 'js/student_account/shoppingcart'
], function (_, Backbone, gettext, emailOptInInterface, enrollmentInterface, shoppingCartInterface) { ], function ($, _, Backbone, gettext, emailOptInInterface, enrollmentInterface, shoppingCartInterface) {
// These are not yet converted to requireJS:
var edx = window.edx || {};
emailOptInInterface = emailOptInInterface || edx.student.account.EmailOptInInterface;
enrollmentInterface = enrollmentInterface || edx.student.account.EnrollmentInterface;
shoppingCartInterface = shoppingCartInterface || edx.student.account.ShoppingCartInterface;
var FinishAuthView = Backbone.View.extend({ var FinishAuthView = Backbone.View.extend({
el: '#finish-auth-status', el: '#finish-auth-status',
......
(function (define) {
'use strict';
define("js/student_account/views/finish_auth_factory",
['jquery', 'underscore', 'backbone', 'js/student_account/views/FinishAuthView', 'utility'],
function ($, _, Backbone, FinishAuthView) {
return function() {
var view = new FinishAuthView({});
view.render();
};
}
);
}).call(this, define || RequireJS.define);
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
* done. * done.
*/ */
modules: getModulesList([ modules: getModulesList([
'teams/js/teams_tab_factory', 'js/student_account/views/account_settings_factory',
'js/student_account/views/finish_auth_factory',
'js/student_profile/views/learner_profile_factory', 'js/student_profile/views/learner_profile_factory',
'js/student_account/views/account_settings_factory' 'teams/js/teams_tab_factory'
]), ]),
/** /**
......
...@@ -5,32 +5,9 @@ ...@@ -5,32 +5,9 @@
<%block name="pagetitle">${_("Please Wait")}</%block> <%block name="pagetitle">${_("Please Wait")}</%block>
<%block name="headextra"> <%block name="headextra">
<%static:require_module module_name="js/student_account/views/finish_auth_factory" class_name="FinishAuthFactory">
<script> FinishAuthFactory();
(function (require, define) { </%static:require_module>
'use strict';
define("js/student_account/views/finish_auth_factory",
[
'jquery', 'underscore', 'backbone',
'js/student_account/views/FinishAuthView'
],
function ($, _, Backbone, FinishAuthView) {
return function() {
var view = new FinishAuthView({});
view.render();
};
}
);
require(["js/student_account/views/finish_auth_factory"],
function (factory) {
factory();
}
);
}).call(this, require || RequireJS.require, define || RequireJS.define);
</script>
</%block> </%block>
<div class="finish-auth"> <div class="finish-auth">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment