diff --git a/cms/static/cms/js/require-config.js b/cms/static/cms/js/require-config.js index d026b4936c..b5f4cf3955 100644 --- a/cms/static/cms/js/require-config.js +++ b/cms/static/cms/js/require-config.js @@ -27,7 +27,8 @@ "mustache": "js/vendor/mustache", "codemirror": "js/vendor/codemirror-compressed", "codemirror/stex": "js/vendor/CodeMirror/stex", - "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.form": "js/vendor/jquery.form", "jquery.markitup": "js/vendor/markitup/jquery.markitup", @@ -37,7 +38,7 @@ "jquery.timepicker": "js/vendor/timepicker/jquery.timepicker", "jquery.cookie": "js/vendor/jquery.cookie", "jquery.qtip": "js/vendor/jquery.qtip.min", - "jquery.scrollTo": "js/vendor/jquery.scrollTo-1.4.2-min", + "jquery.scrollTo": "common/js/vendor/jquery.scrollTo", "jquery.flot": "js/vendor/flot/jquery.flot.min", "jquery.fileupload": "js/vendor/jQuery-File-Upload/js/jquery.fileupload", "jquery.fileupload-process": "js/vendor/jQuery-File-Upload/js/jquery.fileupload-process", @@ -112,6 +113,7 @@ "date": { exports: "Date" }, + "jquery-migrate": ['jquery'], "jquery.ui": { deps: ["jquery"], exports: "jQuery.ui" @@ -146,7 +148,7 @@ }, "jquery.scrollTo": { deps: ["jquery"], - exports: "jQuery.fn.scrollTo", + exports: "jQuery.fn.scrollTo" }, "jquery.flot": { deps: ["jquery"], diff --git a/cms/static/coffee/spec/main.coffee b/cms/static/coffee/spec/main.coffee index 73fe664d8d..d9c3f91265 100644 --- a/cms/static/coffee/spec/main.coffee +++ b/cms/static/coffee/spec/main.coffee @@ -4,14 +4,15 @@ 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", "jquery.leanModal": "xmodule_js/common_static/js/vendor/jquery.leanModal", "jquery.ajaxQueue": "xmodule_js/common_static/js/vendor/jquery.ajaxQueue", "jquery.smoothScroll": "xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min", - "jquery.scrollTo": "xmodule_js/common_static/js/vendor/jquery.scrollTo-1.4.2-min", + "jquery.scrollTo": "common/js/vendor/jquery.scrollTo", "jquery.timepicker": "xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker", "jquery.cookie": "xmodule_js/common_static/js/vendor/jquery.cookie", "jquery.qtip": "xmodule_js/common_static/js/vendor/jquery.qtip.min", @@ -65,6 +66,7 @@ requirejs.config({ "date": { exports: "Date" }, + "jquery-migrate": ['jquery'], "jquery.ui": { deps: ["jquery"], exports: "jQuery.ui" diff --git a/cms/static/coffee/spec/main_spec.coffee b/cms/static/coffee/spec/main_spec.coffee index 39098691ea..ed6b6b6d6e 100644 --- a/cms/static/coffee/spec/main_spec.coffee +++ b/cms/static/coffee/spec/main_spec.coffee @@ -33,7 +33,7 @@ require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_h server && server.restore() it "successful AJAX request does not pop an error notification", -> - server = AjaxHelpers.server([200, {}, '']) + server = AjaxHelpers.server([200, {"Content-Type": "application/json"}, "{}"]) expect($("#page-notification")).toBeEmpty() $.ajax("/test") @@ -42,7 +42,7 @@ require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_h expect($("#page-notification")).toBeEmpty() it "AJAX request with error should pop an error notification", -> - server = AjaxHelpers.server([500, {}, '']) + server = AjaxHelpers.server([500, {"Content-Type": "application/json"}, "{}"]) $.ajax("/test") server.respond() @@ -50,7 +50,7 @@ require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_h expect($("#page-notification")).toContainElement('div.wrapper-notification-error') it "can override AJAX request with error so it does not pop an error notification", -> - server = AjaxHelpers.server([500, {}, '']) + server = AjaxHelpers.server([500, {"Content-Type": "application/json"}, "{}"]) $.ajax url: "/test" diff --git a/cms/static/coffee/spec/main_squire.coffee b/cms/static/coffee/spec/main_squire.coffee index 3e86a658c1..5bea6ba849 100644 --- a/cms/static/coffee/spec/main_squire.coffee +++ b/cms/static/coffee/spec/main_squire.coffee @@ -5,13 +5,14 @@ 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": "common/js/vendor/jquery", + "jquery-migrate": "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", "jquery.leanModal": "xmodule_js/common_static/js/vendor/jquery.leanModal", "jquery.smoothScroll": "xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min", - "jquery.scrollTo": "xmodule_js/common_static/js/vendor/jquery.scrollTo-1.4.2-min", + "jquery.scrollTo": "common/js/vendor/jquery.scrollTo", "jquery.timepicker": "xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker", "jquery.cookie": "xmodule_js/common_static/js/vendor/jquery.cookie", "jquery.qtip": "xmodule_js/common_static/js/vendor/jquery.qtip.min", diff --git a/cms/static/coffee/spec/models/section_spec.coffee b/cms/static/coffee/spec/models/section_spec.coffee index 82fd1c9b3f..8e7438f5ba 100644 --- a/cms/static/coffee/spec/models/section_spec.coffee +++ b/cms/static/coffee/spec/models/section_spec.coffee @@ -34,7 +34,7 @@ define ["js/models/section", "common/js/spec_helpers/ajax_helpers", "js/utils/mo }) it "show/hide a notification when it saves to the server", -> - server = AjaxHelpers.server([200, {}, '']) + server = AjaxHelpers.server([200, {"Content-Type": "application/json"}, "{}"]) @model.save() expect(Section.prototype.showNotification).toHaveBeenCalled() @@ -43,7 +43,7 @@ define ["js/models/section", "common/js/spec_helpers/ajax_helpers", "js/utils/mo it "don't hide notification when saving fails", -> # this is handled by the global AJAX error handler - server = AjaxHelpers.server([500, {}, '']) + server = AjaxHelpers.server([500, {"Content-Type": "application/json"}, "{}"]) @model.save() server.respond() diff --git a/cms/static/coffee/spec/views/assets_spec.coffee b/cms/static/coffee/spec/views/assets_spec.coffee index 6c82b2e3e2..012539ac7c 100644 --- a/cms/static/coffee/spec/views/assets_spec.coffee +++ b/cms/static/coffee/spec/views/assets_spec.coffee @@ -84,7 +84,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"], expect(@confirmationSpies.constructor).not.toHaveBeenCalled() expect(@collection.contains(@model)).toBeTruthy() # return a success response - requests[0].respond(200) + requests[0].respond(204) expect(@confirmationSpies.constructor).toHaveBeenCalled() expect(@confirmationSpies.show).toHaveBeenCalled() savingOptions = @confirmationSpies.constructor.calls.mostRecent().args[0] @@ -118,7 +118,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"], expect(savingOptions.title).toMatch("Saving") expect(@model.get("locked")).toBeFalsy() # return a success response - requests[0].respond(200) + requests[0].respond(204) expect(@savingSpies.hide).toHaveBeenCalled() expect(@model.get("locked")).toBeTruthy() diff --git a/cms/static/coffee/spec/views/textbook_spec.coffee b/cms/static/coffee/spec/views/textbook_spec.coffee index b2a251fb6d..bc855b621d 100644 --- a/cms/static/coffee/spec/views/textbook_spec.coffee +++ b/cms/static/coffee/spec/views/textbook_spec.coffee @@ -87,7 +87,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js savingOptions = @savingSpies.constructor.calls.mostRecent().args[0] expect(savingOptions.title).toMatch(/Deleting/) # return a success response - requests[0].respond(200) + requests[0].respond(204) expect(@savingSpies.hide).toHaveBeenCalled() expect(@collection.contains(@model)).toBeFalsy() diff --git a/cms/static/js/certificates/spec/views/certificate_details_spec.js b/cms/static/js/certificates/spec/views/certificate_details_spec.js index 2552e52262..7d2a81d59d 100644 --- a/cms/static/js/certificates/spec/views/certificate_details_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_details_spec.js @@ -58,6 +58,20 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails }; beforeEach(function() { + window.course = new Course({ + id: '5', + name: 'Course Name', + url_name: 'course_name', + org: 'course_org', + num: 'course_num', + revision: 'course_rev' + }); + window.certWebPreview = new CertificatePreview({ + course_modes: ['honor', 'test'], + certificate_web_view_url: '/users/1/courses/orgX/009/2016' + }); + window.CMS.User = {isGlobalStaff: true}; + TemplateHelpers.installTemplates(['certificate-details', 'signatory-details', 'signatory-editor', 'signatory-actions'], true); window.course = new Course({ @@ -99,6 +113,12 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails delete window.CMS.User; }); + afterEach(function() { + delete window.course; + delete window.CMS.User; + }); + + describe('The Certificate Details view', function() { it('should parse a JSON string collection into a Backbone model collection', function () { @@ -234,7 +254,7 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails this.view.$(SELECTORS.signatory_panel_save).click(); ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/); - requests[0].respond(200); + requests[0].respond(204); ViewHelpers.verifyNotificationHidden(notificationSpy); expect(this.view.$(SELECTORS.signatory_name_value)).toContainText('New Signatory Test Name'); diff --git a/cms/static/js/certificates/spec/views/certificate_preview_spec.js b/cms/static/js/certificates/spec/views/certificate_preview_spec.js index 2c03c7ba0d..205b5fdf1c 100644 --- a/cms/static/js/certificates/spec/views/certificate_preview_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_preview_spec.js @@ -28,8 +28,6 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel }; beforeEach(function() { - appendSetFixtures('
'); - window.course = new Course({ id: '5', name: 'Course Name', @@ -40,6 +38,8 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel }); window.CMS.User = {isGlobalStaff: true}; + TemplateHelpers.installTemplate('certificate-web-preview', true); + appendSetFixtures(''); this.view = new CertificatePreview({ el: $('.preview-certificate'), course_modes: ['test1', 'test2', 'test3'], diff --git a/cms/static/js/spec/utils/drag_and_drop_spec.js b/cms/static/js/spec/utils/drag_and_drop_spec.js index cd061795fc..cb4b504cf1 100644 --- a/cms/static/js/spec/utils/drag_and_drop_spec.js +++ b/cms/static/js/spec/utils/drag_and_drop_spec.js @@ -331,7 +331,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat expect(savingOptions.title).toMatch(/Saving/); expect($('#unit-1')).toHaveClass('was-dropped'); expect(request.requestBody).toEqual('{"children":["fourth-unit-id","first-unit-id"]}'); - request.respond(200); + request.respond(204); expect(this.savingSpies.hide).toHaveBeenCalled(); this.clock.tick(1001); expect($('#unit-1')).not.toHaveClass('was-dropped'); @@ -360,7 +360,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat expect(request.requestBody).toEqual( '{"children":["second-unit-id","first-unit-id","third-unit-id"]}' ); - request.respond(200); + request.respond(204); this.clock.tick(1001); expect($('#unit-1')).not.toHaveClass('was-dropped'); // parent diff --git a/cms/static/js/spec/views/group_configuration_spec.js b/cms/static/js/spec/views/group_configuration_spec.js index db924cfb62..0f53baad57 100644 --- a/cms/static/js/spec/views/group_configuration_spec.js +++ b/cms/static/js/spec/views/group_configuration_spec.js @@ -491,21 +491,6 @@ define([ AjaxHelpers.expectNoRequests(requests); }); - it('should have appropriate class names on focus/blur', function (done) { - var groupInput = this.view.$(SELECTORS.inputGroupName).first(), - groupFields = this.view.$(SELECTORS.groupFields); - - groupInput.focus(); - jasmine.waitUntil(function() { - return groupFields.hasClass('is-focused'); - }).then(function () { - groupInput.blur(); - jasmine.waitUntil(function() { - return !groupFields.hasClass('is-focused'); - }).then(done); - }); - }); - describe('removes all newly created groups on cancel', function () { it('if the model has a non-empty groups', function() { var groups = this.model.get('groups'); diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index 9277a20282..5de589c5cf 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -253,6 +253,16 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/components/u ]) ]); + // Create a mock Course object as the JS now expects it. + window.course = new Course({ + id: '333', + name: 'Course Name', + url_name: 'course_name', + org: 'course_org', + num: 'course_num', + revision: 'course_rev' + }); + }); afterEach(function () { diff --git a/cms/static/js/spec/views/pages/index_spec.js b/cms/static/js/spec/views/pages/index_spec.js index 4d857e151c..243aac1024 100644 --- a/cms/static/js/spec/views/pages/index_spec.js +++ b/cms/static/js/spec/views/pages/index_spec.js @@ -101,7 +101,7 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers var values_with_blank = values.slice(); values_with_blank[i] = ''; fillInLibraryFields.apply(this, values_with_blank); - expect($('.create-library li.field.text input[value=]').parent()).toHaveClass('error'); + expect($('.create-library li.field.text input').parent()).toHaveClass('error'); expect($('.new-library-save')).toHaveClass('is-disabled'); expect($('.new-library-save')).toHaveAttr('aria-disabled', 'true'); $('.new-library-save').click(); diff --git a/cms/static/js/spec/views/pages/library_users_spec.js b/cms/static/js/spec/views/pages/library_users_spec.js index 1c779486de..3c6a4cb384 100644 --- a/cms/static/js/spec/views/pages/library_users_spec.js +++ b/cms/static/js/spec/views/pages/library_users_spec.js @@ -5,11 +5,11 @@ define([ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) { "use strict"; describe("Library Instructor Access Page", function () { - const changeRoleUrl = "dummy_change_role_url/@@EMAIL@@"; + var changeRoleUrl = "dummy_change_role_url/@@EMAIL@@"; var team_member_fixture = readFixtures("team-member.underscore"); function setRole(email, role){ - var user_li = $("li.user-item[data-email="+ email + "]"); + var user_li = $('li.user-item[data-email="'+ email + '"]'); var role_action = $("li.action-role a.make-"+role, user_li); expect(role_action).toBeVisible(); role_action.click(); @@ -48,7 +48,7 @@ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) { }); it("can give a user permission to use the library", function () { - const email = 'other@example.com'; + var email = 'other@example.com'; var requests = AjaxHelpers.requests(this); var reloadSpy = spyOn(ViewUtils, 'reload'); $('.create-user-button').click(); @@ -61,7 +61,7 @@ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) { }); it("can promote user", function() { - const email = "staff@example.com"; + var email = "staff@example.com"; var requests = AjaxHelpers.requests(this); var reloadSpy = spyOn(ViewUtils, 'reload'); setRole("staff@example.com", 'staff'); diff --git a/cms/static/js/spec/views/settings/main_spec.js b/cms/static/js/spec/views/settings/main_spec.js index ff5a7ce788..b9c1818e5d 100644 --- a/cms/static/js/spec/views/settings/main_spec.js +++ b/cms/static/js/spec/views/settings/main_spec.js @@ -144,7 +144,7 @@ define([ // select the entrance-exam-enabled checkbox. grade requirement section should be visible. entrance_exam_enabled_field - .attr('checked', 'true') + .prop('checked', true) .trigger('change'); this.view.render(); @@ -152,7 +152,7 @@ define([ // deselect the entrance-exam-enabled checkbox. grade requirement section should be hidden. entrance_exam_enabled_field - .removeAttr('checked') + .prop('checked', false) .trigger('change'); expect(this.view.$(SELECTORS.grade_requirement_div)).toBeHidden(); @@ -173,7 +173,7 @@ define([ // select the entrance-exam-enabled checkbox. entrance_exam_enabled_field - .attr('checked', 'true') + .prop('checked', true) .trigger('change'); // input a valid value for entrance exam minimum score. diff --git a/cms/static/js/spec/views/xblock_spec.js b/cms/static/js/spec/views/xblock_spec.js index 9777008f05..d192517626 100644 --- a/cms/static/js/spec/views/xblock_spec.js +++ b/cms/static/js/spec/views/xblock_spec.js @@ -99,7 +99,7 @@ define(["jquery", "URI", "common/js/spec_helpers/ajax_helpers", "common/js/compo mimetype: "application/javascript", kind: "url", data: missingJavaScriptUrl }] ]); - expect(promise.isRejected()).toBe(true); + expect(promise.state()).toBe("rejected"); }); it('Triggers an event to the runtime when a notification-action-button is clicked', function () { diff --git a/cms/static/js/views/course_info_update.js b/cms/static/js/views/course_info_update.js index 0a3c0277c0..938579b825 100644 --- a/cms/static/js/views/course_info_update.js +++ b/cms/static/js/views/course_info_update.js @@ -10,8 +10,8 @@ define(["js/views/validation", "codemirror", "js/models/course_update", // collection is CourseUpdateCollection events: { "click .new-update-button" : "onNew", - "click #course-update-view .save-button" : "onSave", - "click #course-update-view .cancel-button" : "onCancel", + "click .save-button" : "onSave", + "click .cancel-button" : "onCancel", "click .post-actions > .edit-button" : "onEdit", "click .post-actions > .delete-button" : "onDelete" }, diff --git a/cms/static/js/views/experiment_group_edit.js b/cms/static/js/views/experiment_group_edit.js index c513b1a4d5..6e87553023 100644 --- a/cms/static/js/views/experiment_group_edit.js +++ b/cms/static/js/views/experiment_group_edit.js @@ -12,8 +12,8 @@ function(BaseView, _, str, gettext, groupEditTemplate) { events: { 'click .action-close': 'removeGroup', 'change .group-name': 'changeName', - 'focus .groups-fields input': 'onFocus', - 'blur .groups-fields input': 'onBlur' + 'focus .group-name': 'onFocus', + 'blur .group-name': 'onBlur' }, className: function() { diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 2aee819b4a..ee4a202d88 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -215,7 +215,6 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', } }); - AbstractEditor = BaseView.extend({ tagName: 'section', templateName: null, @@ -328,6 +327,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', }; } }); + TimedExaminationPreferenceEditor = AbstractEditor.extend({ templateName: 'timed-examination-preference-editor', className: 'edit-settings-timed-examination', @@ -496,6 +496,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', }; } }); + AccessEditor = AbstractEditor.extend({ templateName: 'access-editor', className: 'edit-settings-access', @@ -548,13 +549,14 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', }; } }); + GradingEditor = AbstractEditor.extend({ templateName: 'grading-editor', className: 'edit-settings-grading', afterRender: function () { AbstractEditor.prototype.afterRender.call(this); - this.setValue(this.model.get('format')); + this.setValue(this.model.get('format') || 'notgraded'); }, setValue: function (value) { diff --git a/cms/static/js/views/video/translations_editor.js b/cms/static/js/views/video/translations_editor.js index 6b8dfd97af..39da06c41b 100644 --- a/cms/static/js/views/video/translations_editor.js +++ b/cms/static/js/views/video/translations_editor.js @@ -89,7 +89,7 @@ function($, _, AbstractEditor, FileUpload, UploadDialog) { items = this.$el.find('ol').find('.list-settings-item'); _.each(items, function(element, index) { - var key = $(element).find('select').val(), + var key = $(element).find('select option:selected').val(), value = $(element).find('.input').val(); // Keys should be unique, so if our keys are duplicated and diff --git a/cms/static/karma_cms.conf.js b/cms/static/karma_cms.conf.js index b2048623aa..edfb65d9f4 100644 --- a/cms/static/karma_cms.conf.js +++ b/cms/static/karma_cms.conf.js @@ -13,6 +13,11 @@ var options = { libraryFiles: [], + libraryFilesToInclude: [ + {pattern: 'common/js/vendor/jquery.js', included: true}, + {pattern: 'common/js/vendor/jquery-migrate.js', included: true} + ], + // Make sure the patterns in sourceFiles and specFiles do not match the same file. // Otherwise Istanbul which is used for coverage tracking will cause tests to not run. sourceFiles: [ diff --git a/cms/static/karma_cms_squire.conf.js b/cms/static/karma_cms_squire.conf.js index 469a3891e8..093e51bb55 100644 --- a/cms/static/karma_cms_squire.conf.js +++ b/cms/static/karma_cms_squire.conf.js @@ -13,6 +13,11 @@ var options = { libraryFiles: [], + libraryFilesToInclude: [ + {pattern: 'common/js/vendor/jquery.js', included: true}, + {pattern: 'common/js/vendor/jquery-migrate.js', included: true} + ], + // Make sure the patterns in sourceFiles and specFiles do not match the same file. // Otherwise Istanbul which is used for coverage tracking will cause tests to not run. sourceFiles: [ diff --git a/common/djangoapps/pipeline_mako/__init__.py b/common/djangoapps/pipeline_mako/__init__.py index d8987550a4..754976d509 100644 --- a/common/djangoapps/pipeline_mako/__init__.py +++ b/common/djangoapps/pipeline_mako/__init__.py @@ -93,12 +93,12 @@ def render_require_js_path_overrides(path_overrides): # pylint: disable=invalid For example: - "js/vendor/jquery.min.js" --> "js/vendor/jquery.min.abcd1234" + "js/vendor/jquery.js" --> "js/vendor/jquery.abcd1234" To achive this we will add overrided paths in requirejs config at runtime. So that any reference to 'jquery' in a JavaScript module - will cause RequireJS to load '/static/js/vendor/jquery.min.abcd1234.js' + will cause RequireJS to load '/static/js/vendor/jquery.abcd1234.js' If running in DEBUG mode (as in devstack), the resolved JavaScript URLs won't contain hashes, so the new paths will match the original paths. diff --git a/common/djangoapps/pipeline_mako/tests/test_render.py b/common/djangoapps/pipeline_mako/tests/test_render.py index 4c072075c5..1cef001594 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/lib/xmodule/xmodule/js/karma_xmodule.conf.js b/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js index 6ff01d6856..5ee38962a7 100644 --- a/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js +++ b/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js @@ -28,7 +28,8 @@ var options = { {pattern: 'common_static/edx-ui-toolkit/js/utils/global-loader.js', included: true}, {pattern: 'common_static/js/vendor/CodeMirror/codemirror.js', included: true}, {pattern: 'common_static/js/vendor/draggabilly.js'}, - {pattern: 'common_static/js/vendor/jquery.min.js', included: true}, + {pattern: 'common_static/common/js/vendor/jquery.js', included: true}, + {pattern: 'common_static/common/js/vendor/jquery-migrate.js', included: true}, {pattern: 'common_static/js/vendor/jquery.cookie.js', included: true}, {pattern: 'common_static/js/vendor/jquery.leanModal.js', included: true}, {pattern: 'common_static/js/vendor/jquery.timeago.js', included: true}, diff --git a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee index 9c6a396cc8..0e0b29f776 100644 --- a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee @@ -289,9 +289,9 @@ describe 'Problem', -> $('#input_example_1').replaceWith(html) @problem.checkAnswersAndCheckButton true @checkDisabled true - $('#input_1_1_1').attr('checked', true).trigger('click') + $('#input_1_1_1').click() @checkDisabled false - $('#input_1_1_1').attr('checked', false).trigger('click') + $('#input_1_1_1').click() @checkDisabled true it 'should become enabled after a radiobutton is checked', -> diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js index f3293cf0e4..b8cf3065b1 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js @@ -343,7 +343,7 @@ expect(parseIntAttribute(item, 'data-index')).toEqual(index); expect(parseIntAttribute(item, 'data-start')).toEqual(captionsData.start[index]); - expect(item.attr('tabindex')).toEqual(0); + expect(item.attr('tabindex')).toEqual('0'); expect(item.text().trim()).toEqual(captionsData.text[index]); }); }); @@ -432,7 +432,7 @@ expect(parseIntAttribute(item, 'data-index')).toEqual(index); expect(parseIntAttribute(item, 'data-start')).toEqual(captionsData.start[index]); - expect(item.attr('tabindex')).toEqual(0); + expect(item.attr('tabindex')).toEqual('0'); expect(item.text().trim()).toEqual(text); }); }).always(done); @@ -842,7 +842,7 @@ function (index, item) { expect(parseIntAttribute($(item), 'data-index')).toEqual(index); expect(parseIntAttribute($(item), 'data-start')).toEqual(captionsData.start[index]); - expect($(item).attr('tabindex')).toEqual(0); + expect($(item).attr('tabindex')).toEqual('0'); expect($(item).text().trim()).toEqual(captionsData.text[index]); }); }); diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_focus_grabber_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_focus_grabber_spec.js index 8dd9bceb40..8d465b15a9 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_focus_grabber_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_focus_grabber_spec.js @@ -49,8 +49,8 @@ }); it('from the start, focus grabbers are disabled', function () { - expect(state.focusGrabber.elFirst.attr('tabindex')).toBe(-1); - expect(state.focusGrabber.elLast.attr('tabindex')).toBe(-1); + expect(state.focusGrabber.elFirst.attr('tabindex')).toBe('-1'); + expect(state.focusGrabber.elLast.attr('tabindex')).toBe('-1'); }); it( diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_play_placeholder_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_play_placeholder_spec.js index b7119dd9b4..4532742dee 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_play_placeholder_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_play_placeholder_spec.js @@ -55,7 +55,7 @@ expect(btnPlay).not.toHaveClass('is-hidden'); expect(btnPlay).toHaveAttrs({ 'aria-hidden': 'false', - 'tabindex': 0 + 'tabindex': '0' }); state.videoPlayPlaceholder.hide(); @@ -63,7 +63,7 @@ expect(btnPlay).toHaveClass('is-hidden'); expect(btnPlay).toHaveAttrs({ 'aria-hidden': 'true', - 'tabindex': -1 + 'tabindex': '-1' }); }); diff --git a/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee b/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee index e12faa7842..8f1d0dbaae 100644 --- a/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee @@ -39,15 +39,15 @@ class @Annotatable # the associated problem. The reply buttons are part of the tooltip # content. It's important that the tooltips be configured to render # as descendants of the annotation module and *not* the document.body. - @$el.delegate @replySelector, 'click', @onClickReply + @$el.on 'click', @replySelector, @onClickReply # Initialize handler for 'return to annotation' events triggered from problems. # 1) There are annotationinput capa problems rendered on the page # 2) Each one has an embedded return link (see annotation capa problem template). # Since the capa problem injects HTML content via AJAX, the best we can do is - # is let the click events bubble up to the body and handle them there. - $('body').delegate @problemReturnSelector, 'click', @onClickReturn - + # is let the click events bubble up to the body and handle them there. + $(document).on 'click', @problemReturnSelector, @onClickReturn + initTips: () -> # tooltips are used to display annotations for highlighted text spans @$(@spanSelector).each (index, el) => @@ -91,8 +91,9 @@ class @Annotatable onMoveTip: (event, api, position) => ### - This method handles an edge case in which a tooltip is displayed above - a non-overlapping span like this: + This method handles a vertical positioning bug in Firefox as + well as an edge case in which a tooltip is displayed above a + non-overlapping span like this: (( TOOLTIP )) \/ @@ -115,28 +116,33 @@ class @Annotatable # we want to choose the largest of the two non-overlapping spans and display # the tooltip above the center of it (see api.options.position settings) focus_rect = (if rects[0].width > rects[1].width then rects[0] else rects[1]) - rect_center = focus_rect.left + (focus_rect.width / 2) - rect_top = focus_rect.top - tip_width = $(tip).width() - tip_height = $(tip).height() + else + # always compute the new position because Firefox doesn't + # properly vertically position the tooltip + focus_rect = rects[0] - # tooltip is positioned relative to its container, so we need to factor in offsets - container_offset = $(container).offset() - offset_left = -container_offset.left - offset_top = $(document).scrollTop() - container_offset.top + rect_center = focus_rect.left + (focus_rect.width / 2) + rect_top = focus_rect.top + tip_width = $(tip).width() + tip_height = $(tip).height() - tip_left = offset_left + rect_center - (tip_width / 2) - tip_top = offset_top + rect_top - tip_height + adjust_y + # tooltip is positioned relative to its container, so we need to factor in offsets + container_offset = $(container).offset() + offset_left = -container_offset.left + offset_top = $(document).scrollTop() - container_offset.top - # make sure the new tip position doesn't clip the edges of the screen - win_width = $(window).width() - if tip_left < offset_left - tip_left = offset_left - else if tip_left + tip_width > win_width + offset_left - tip_left = win_width + offset_left - tip_width + tip_left = offset_left + rect_center - (tip_width / 2) + tip_top = offset_top + rect_top - tip_height + adjust_y - # final step: update the position object (used by qtip2 to show the tip after the move event) - $.extend position, 'left': tip_left, 'top': tip_top + # make sure the new tip position doesn't clip the edges of the screen + win_width = $(window).width() + if tip_left < offset_left + tip_left = offset_left + else if tip_left + tip_width > win_width + offset_left + tip_left = win_width + offset_left - tip_width + + # final step: update the position object (used by qtip2 to show the tip after the move event) + $.extend position, 'left': tip_left, 'top': tip_top getSpanForProblemReturn: (el) -> problem_id = $(@problemReturnSelector).index(el) @@ -144,7 +150,7 @@ class @Annotatable getProblem: (el) -> problem_id = @getProblemId(el) - $(@problemSelector).has(@problemInputSelector).eq(problem_id) + $(@problemInputSelector).eq(problem_id) getProblemId: (el) -> $(el).data('problem-id') @@ -208,7 +214,7 @@ class @Annotatable onAfter: @_once => after?.call this, el offset: offset }) if $(el).length > 0 - + afterScrollToProblem: (problem_el) -> problem_el.effect 'highlight', {}, 500 diff --git a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee index 4e4ece3d2d..60b82fde90 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee @@ -129,7 +129,8 @@ if Backbone? isPrivilegedUser: DiscussionUtil.isPrivilegedUser() }) ) - @$(".forum-nav-sort-control").val(@collection.sort_preference) + @$(".forum-nav-sort-control option").removeProp("selected") + @$(".forum-nav-sort-control option[value=#{@collection.sort_preference}]").prop("selected", true) $(window).bind "load scroll resize", @updateSidebar @@ -524,5 +525,3 @@ if Backbone? type: "POST" error: () => $('input.email-setting').attr('checked','checked') - - diff --git a/common/static/common/js/common_libraries.js b/common/static/common/js/common_libraries.js index 57ffa5ce1e..dbbe380811 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 55facc0937..6e12043729 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', @@ -11,7 +14,7 @@ 'jquery.leanModal': 'js/vendor/jquery.leanModal', 'jquery.ajaxQueue': 'js/vendor/jquery.ajaxQueue', 'jquery.smoothScroll': 'js/vendor/jquery.smooth-scroll.min', - 'jquery.scrollTo': 'js/vendor/jquery.scrollTo-1.4.2-min', + 'jquery.scrollTo': 'common/js/vendor/jquery.scrollTo', 'jquery.timepicker': 'js/vendor/timepicker/jquery.timepicker', 'jquery.cookie': 'js/vendor/jquery.cookie', 'jquery.qtip': 'js/vendor/jquery.qtip.min', diff --git a/common/static/js/vendor/jquery.min.js b/common/static/js/vendor/jquery.min.js deleted file mode 100644 index 16ad06c5ac..0000000000 --- a/common/static/js/vendor/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.7.2 jquery.com | jquery.org/license */ -(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e| t |