From 230f252bad7ef9f7fcd30a5e89c4524804acd288 Mon Sep 17 00:00:00 2001 From: Daniel Friedman <dfriedman58@gmail.com> Date: Sat, 27 Feb 2016 12:24:09 -0500 Subject: [PATCH] Fix the way jquery and jquery-migrate are loaded Don't use symlinks to include node_modules --- cms/static/cms/js/require-config.js | 13 +++---------- cms/static/coffee/spec/main.coffee | 12 +++--------- cms/static/coffee/spec/main_squire.coffee | 3 ++- .../djangoapps/pipeline_mako/tests/test_render.py | 4 ++-- common/static/common/js/common_libraries.js | 1 + common/static/common/js/spec/main_requirejs.js | 5 ++++- common/static/js/vendor/jquery-migrate.min.js | 1 - common/static/js/vendor/jquery.min.js | 1 - lms/envs/common.py | 12 ++++++------ .../instructor_dashboard/membership_spec.coffee | 6 ------ lms/static/js/spec/main.js | 13 +++---------- lms/static/lms/js/build.js | 4 +--- lms/static/lms/js/require-config.js | 9 ++++----- .../test/fake_softwaresecure_response.html | 2 +- pavelib/assets.py | 2 ++ 15 files changed, 32 insertions(+), 56 deletions(-) delete mode 120000 common/static/js/vendor/jquery-migrate.min.js delete mode 120000 common/static/js/vendor/jquery.min.js diff --git a/cms/static/cms/js/require-config.js b/cms/static/cms/js/require-config.js index 80a07e68ce5..7404ef2b693 100644 --- a/cms/static/cms/js/require-config.js +++ b/cms/static/cms/js/require-config.js @@ -27,12 +27,8 @@ "mustache": "js/vendor/mustache", "codemirror": "js/vendor/codemirror-compressed", "codemirror/stex": "js/vendor/CodeMirror/stex", - // The jquery-migrate library was added in upgrading from - // jQuery 1.7.x to 2.2.x. This config allows developers - // to depend on "jquery" which opaquely requires both - // libraries. - "_jquery": "js/vendor/jquery.min", - "jquery": "js/vendor/jquery-migrate.min", + "jquery": "common/js/vendor/jquery", + "jquery-migrate": "common/js/vendor/jquery-migrate", "jquery.ui": "js/vendor/jquery-ui.min", "jquery.form": "js/vendor/jquery.form", "jquery.markitup": "js/vendor/markitup/jquery.markitup", @@ -117,10 +113,7 @@ "date": { exports: "Date" }, - "jquery": { - deps: ["_jquery"], - exports: "jQuery" - }, + "jquery-migrate": ['jquery'], "jquery.ui": { deps: ["jquery"], exports: "jQuery.ui" diff --git a/cms/static/coffee/spec/main.coffee b/cms/static/coffee/spec/main.coffee index d3c1fd468f2..b96ce21fe61 100644 --- a/cms/static/coffee/spec/main.coffee +++ b/cms/static/coffee/spec/main.coffee @@ -4,11 +4,8 @@ requirejs.config({ "gettext": "xmodule_js/common_static/js/test/i18n", "mustache": "xmodule_js/common_static/js/vendor/mustache", "codemirror": "xmodule_js/common_static/js/vendor/CodeMirror/codemirror", - # The jquery-migrate library was added in upgrading from - # jQuery 1.7.x to 2.2.x. This config allows developers to - # depend on "jquery" which opaquely requires both libraries. - "_jquery": "xmodule_js/common_static/js/vendor/jquery.min", - "jquery": "xmodule_js/common_static/js/vendor/jquery-migrate.min", + "jquery": "xmodule_js/common_static/common/js/vendor/jquery", + "jquery-migrate": "xmodule_js/common_static/common/js/vendor/jquery-migrate", "jquery.ui": "xmodule_js/common_static/js/vendor/jquery-ui.min", "jquery.form": "xmodule_js/common_static/js/vendor/jquery.form", "jquery.markitup": "xmodule_js/common_static/js/vendor/markitup/jquery.markitup", @@ -69,10 +66,7 @@ requirejs.config({ "date": { exports: "Date" }, - "jquery": { - deps: ["_jquery"], - exports: "jQuery" - }, + "jquery-migrate": ['jquery'], "jquery.ui": { deps: ["jquery"], exports: "jQuery.ui" diff --git a/cms/static/coffee/spec/main_squire.coffee b/cms/static/coffee/spec/main_squire.coffee index 83f7d95d98d..240d58a8a0b 100644 --- a/cms/static/coffee/spec/main_squire.coffee +++ b/cms/static/coffee/spec/main_squire.coffee @@ -5,7 +5,8 @@ requirejs.config({ "gettext": "xmodule_js/common_static/js/test/i18n", "mustache": "xmodule_js/common_static/js/vendor/mustache", "codemirror": "xmodule_js/common_static/js/vendor/CodeMirror/codemirror", - "jquery": "xmodule_js/common_static/js/vendor/jquery.min", + "jquery": "xmodule_js/common_static/common/js/vendor/jquery", + "jquery-migrate": "xmodule_js/common_static/common/js/vendor/jquery-migrate", "jquery.ui": "xmodule_js/common_static/js/vendor/jquery-ui.min", "jquery.form": "xmodule_js/common_static/js/vendor/jquery.form", "jquery.markitup": "xmodule_js/common_static/js/vendor/markitup/jquery.markitup", diff --git a/common/djangoapps/pipeline_mako/tests/test_render.py b/common/djangoapps/pipeline_mako/tests/test_render.py index 4c072075c50..1cef0015945 100644 --- a/common/djangoapps/pipeline_mako/tests/test_render.py +++ b/common/djangoapps/pipeline_mako/tests/test_render.py @@ -14,7 +14,7 @@ class RequireJSPathOverridesTest(TestCase): """Test RequireJS path overrides. """ OVERRIDES = { - 'jquery': 'js/vendor/jquery.min.js', + 'jquery': 'common/js/vendor/jquery.js', 'backbone': 'common/js/vendor/backbone.js', 'text': 'js/vendor/text.js' } @@ -24,7 +24,7 @@ class RequireJSPathOverridesTest(TestCase): "(function (require) {", "require.config({", "paths: {", - "'jquery': 'js/vendor/jquery.min',", + "'jquery': 'common/js/vendor/jquery',", "'text': 'js/vendor/text',", "'backbone': 'common/js/vendor/backbone'", "}", diff --git a/common/static/common/js/common_libraries.js b/common/static/common/js/common_libraries.js index 57ffa5ce1e8..dbbe3808116 100644 --- a/common/static/common/js/common_libraries.js +++ b/common/static/common/js/common_libraries.js @@ -3,6 +3,7 @@ define([ 'edx-ui-toolkit/js/utils/html-utils', 'domReady!', 'jquery', + 'jquery-migrate', 'backbone', 'underscore', 'gettext' diff --git a/common/static/common/js/spec/main_requirejs.js b/common/static/common/js/spec/main_requirejs.js index ea539c7f776..7004b93c58b 100644 --- a/common/static/common/js/spec/main_requirejs.js +++ b/common/static/common/js/spec/main_requirejs.js @@ -1,9 +1,12 @@ (function(requirejs, define) { + 'use strict'; + requirejs.config({ baseUrl: '/base/', paths: { 'gettext': 'js/test/i18n', - 'jquery': 'js/vendor/jquery.min', + 'jquery': 'common/js/vendor/jquery', + 'jquery-migrate': 'common/js/vendor/jquery-migrate', 'jquery.ui': 'js/vendor/jquery-ui.min', 'jquery.flot': 'js/vendor/flot/jquery.flot.min', 'jquery.form': 'js/vendor/jquery.form', diff --git a/common/static/js/vendor/jquery-migrate.min.js b/common/static/js/vendor/jquery-migrate.min.js deleted file mode 120000 index 9baf8c3b59c..00000000000 --- a/common/static/js/vendor/jquery-migrate.min.js +++ /dev/null @@ -1 +0,0 @@ -../../../../node_modules/jquery-migrate/dist/jquery-migrate.min.js \ No newline at end of file diff --git a/common/static/js/vendor/jquery.min.js b/common/static/js/vendor/jquery.min.js deleted file mode 120000 index f0c4795a02b..00000000000 --- a/common/static/js/vendor/jquery.min.js +++ /dev/null @@ -1 +0,0 @@ -../../../../node_modules/jquery/dist/jquery.min.js \ No newline at end of file diff --git a/lms/envs/common.py b/lms/envs/common.py index 40e8e49b299..c12fa134ddc 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1240,8 +1240,8 @@ proctoring_js = ( # In the future, we will likely refactor this to use # RequireJS and an optimizer. base_vendor_js = [ - 'js/vendor/jquery.min.js', - 'js/vendor/jquery-migrate.min.js', + 'common/js/vendor/jquery.js', + 'common/js/vendor/jquery-migrate.js', 'js/vendor/jquery.cookie.js', 'js/vendor/url.min.js', 'common/js/vendor/underscore.js', @@ -1353,16 +1353,16 @@ incourse_reverify_js = [ ccx_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/ccx/**/*.js')) certificates_web_view_js = [ - 'js/vendor/jquery.min.js', - 'js/vendor/jquery-migrate.min.js', + 'common/js/vendor/jquery.js', + 'common/js/vendor/jquery-migrate.js', 'js/vendor/jquery.cookie.js', 'js/src/logger.js', 'js/utils/facebook.js', ] credit_web_view_js = [ - 'js/vendor/jquery.min.js', - 'js/vendor/jquery-migrate.min.js', + 'common/js/vendor/jquery.js', + 'common/js/vendor/jquery-migrate.js', 'js/vendor/jquery.cookie.js', 'js/src/logger.js', ] diff --git a/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee b/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee index 185f3718559..bb2ba81a110 100644 --- a/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee +++ b/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee @@ -3,12 +3,6 @@ describe 'AutoEnrollment', -> loadFixtures 'coffee/fixtures/autoenrollment.html' @autoenrollment = new AutoEnrollmentViaCsv $('.auto_enroll_csv') - it 'binds to the enrollment_signup_button on click event', -> - expect(@autoenrollment.$enrollment_signup_button).toHandle 'click' - - it 'binds to the browse button on change event', -> - expect(@autoenrollment.$browse_button).toHandle 'change' - it 'binds the ajax call and the result will be success', -> spyOn($, "ajax").and.callFake((params) => params.success({row_errors: [], general_errors: [], warnings: []}) diff --git a/lms/static/js/spec/main.js b/lms/static/js/spec/main.js index 2f4f16261aa..3a135e7cc3f 100644 --- a/lms/static/js/spec/main.js +++ b/lms/static/js/spec/main.js @@ -8,12 +8,8 @@ paths: { 'gettext': 'xmodule_js/common_static/js/test/i18n', 'codemirror': 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror', - // The jquery-migrate library was added in upgrading from - // jQuery 1.7.x to 2.2.x. This config allows developers - // to depend on "jquery" which opaquely requires both - // libraries. - '_jquery': 'xmodule_js/common_static/js/vendor/jquery.min', - 'jquery': 'xmodule_js/common_static/js/vendor/jquery-migrate.min', + 'jquery': 'xmodule_js/common_static/common/js/vendor/jquery', + 'jquery-migrate': 'xmodule_js/common_static/common/js/vendor/jquery-migrate', 'jquery.ui': 'xmodule_js/common_static/js/vendor/jquery-ui.min', 'jquery.eventDrag': 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2', 'jquery.flot': 'xmodule_js/common_static/js/vendor/flot/jquery.flot.min', @@ -124,10 +120,7 @@ 'date': { exports: 'Date' }, - "jquery": { - deps: ["_jquery"], - exports: "jQuery" - }, + "jquery-migrate": ['jquery'], 'jquery.ui': { deps: ['jquery'], exports: 'jQuery.ui' diff --git a/lms/static/lms/js/build.js b/lms/static/lms/js/build.js index b1e4b1ecb6c..c75ec185855 100644 --- a/lms/static/lms/js/build.js +++ b/lms/static/lms/js/build.js @@ -65,10 +65,8 @@ paths: { 'gettext': 'empty:', 'coffee/src/ajax_prefix': 'empty:', - // '_jquery' is the name of the current jQuery in the - // platform, and 'jquery' refers to jquery-migrate. - '_jquery': 'empty:', 'jquery': 'empty:', + 'jquery-migrate': 'empty:', 'jquery.cookie': 'empty:', 'jquery.url': 'empty:', 'backbone': 'empty:', diff --git a/lms/static/lms/js/require-config.js b/lms/static/lms/js/require-config.js index 5709fc7d723..0d2a3a44758 100644 --- a/lms/static/lms/js/require-config.js +++ b/lms/static/lms/js/require-config.js @@ -28,6 +28,7 @@ } }; defineDependency("jQuery", "jquery"); + defineDependency("jQuery", "jquery-migrate"); defineDependency("_", "underscore"); defineDependency("s", "underscore.string"); // Underscore.string no longer installs itself directly on "_". For compatibility with existing @@ -68,8 +69,8 @@ // jQuery 1.7.x to 2.2.x. This config allows developers // to depend on "jquery" which opaquely requires both // libraries. - "_jquery": "js/vendor/jquery.min", - "jquery": "js/vendor/jquery-migrate.min", + "jquery": "common/js/vendor/jquery", + "jquery-migrate": "common/js/vendor/jquery-migrate", "jquery.cookie": "js/vendor/jquery.cookie", 'jquery.timeago': 'js/vendor/jquery.timeago', "jquery.url": "js/vendor/url.min", @@ -116,13 +117,11 @@ "date": { exports: "Date" }, -<<<<<<< HEAD -======= "jquery": { deps: ["_jquery"], exports: "jQuery" }, ->>>>>>> Upgrade jQuery 1.7.2 to 2.2.0 + "jquery-migrate": ['jquery'], "jquery.cookie": { deps: ["jquery"], exports: "jQuery.fn.cookie" diff --git a/lms/templates/verify_student/test/fake_softwaresecure_response.html b/lms/templates/verify_student/test/fake_softwaresecure_response.html index c4be837bee4..d32a9a0d400 100644 --- a/lms/templates/verify_student/test/fake_softwaresecure_response.html +++ b/lms/templates/verify_student/test/fake_softwaresecure_response.html @@ -21,7 +21,7 @@ </body> </html> -<script type="text/javascript" src="${static.url('js/vendor/jquery.min.js')}"></script> +<script type="text/javascript" src="${static.url('common/js/vendor/jquery.js')}"></script> <script type="text/javascript"> $(document).ready(function() { diff --git a/pavelib/assets.py b/pavelib/assets.py index 03d80fa5a5d..4254d2cee04 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -45,6 +45,8 @@ SASS_LOAD_PATHS = [ # A list of NPM installed libraries that should be copied into the common # static directory. NPM_INSTALLED_LIBRARIES = [ + 'jquery/dist/jquery.js', + 'jquery-migrate/dist/jquery-migrate.js', 'underscore/underscore.js', 'underscore.string/dist/underscore.string.js', 'picturefill/dist/picturefill.js', -- GitLab