From 4f0ab6f9c8ec797d053956e80dd6b4f38251163f Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 1 Jul 2015 15:21:45 -0400 Subject: [PATCH] Optimize account settings and learner profile. Also remove RequireJS dependency on mustache, and delete extra copy. --- lms/static/js/mustache.js | 613 ------------------ lms/static/js/spec/main.js | 2 - .../views/account_settings_fields.js | 4 +- .../views/learner_profile_factory.js | 3 +- lms/static/js/views/fields.js | 14 +- lms/static/lms/js/build.js | 4 +- .../discussion/_js_head_dependencies.html | 2 +- .../student_account/account_settings.html | 29 +- .../student_profile/learner_profile.html | 19 +- 9 files changed, 33 insertions(+), 657 deletions(-) delete mode 100644 lms/static/js/mustache.js diff --git a/lms/static/js/mustache.js b/lms/static/js/mustache.js deleted file mode 100644 index aab62f9ddc..0000000000 --- a/lms/static/js/mustache.js +++ /dev/null @@ -1,613 +0,0 @@ -/*! - * mustache.js - Logic-less {{mustache}} templates with JavaScript - * http://github.com/janl/mustache.js - */ - -var Mustache; - -(function (exports) { - if (typeof module !== "undefined") { - module.exports = exports; // CommonJS - } else if (typeof define === "function") { - define(exports); // AMD - } else { - Mustache = exports; // - + diff --git a/lms/templates/student_account/account_settings.html b/lms/templates/student_account/account_settings.html index b52600414d..e70e13194d 100644 --- a/lms/templates/student_account/account_settings.html +++ b/lms/templates/student_account/account_settings.html @@ -37,21 +37,16 @@ from microsite_configuration import microsite <%block name="headextra"> <%static:css group='style-course'/> - - - + + +<%block name="js_extra"> +<%static:require_module module_name="js/student_account/views/account_settings_factory" class_name="AccountSettingsFactory"> + var fieldsData = ${ json.dumps(fields) }; + var authData = ${ json.dumps(auth) }; + var platformName = ${ json.dumps(microsite.get_value('platform_name', settings.PLATFORM_NAME))}; + + AccountSettingsFactory( + fieldsData, authData, '${user_accounts_api_url}', '${user_preferences_api_url}', ${user.id}, platformName + ); + diff --git a/lms/templates/student_profile/learner_profile.html b/lms/templates/student_profile/learner_profile.html index bdc4530084..0539ef2122 100644 --- a/lms/templates/student_profile/learner_profile.html +++ b/lms/templates/student_profile/learner_profile.html @@ -34,16 +34,11 @@ from openedx.core.lib.json_utils import EscapedEdxJSONEncoder <%block name="headextra"> <%static:css group='style-course'/> - - - - - + + +<%block name="js_extra"> +<%static:require_module module_name="js/student_profile/views/learner_profile_factory" class_name="LearnerProfileFactory"> + var options = ${ json.dumps(data, cls=EscapedEdxJSONEncoder) }; + LearnerProfileFactory(options); +