diff --git a/cms/static/cms/js/build.js b/cms/static/cms/js/build.js
index ca5f98eaf7..fd90513c2a 100644
--- a/cms/static/cms/js/build.js
+++ b/cms/static/cms/js/build.js
@@ -16,7 +16,7 @@
var getModulesList = function(modules) {
var result = [getModule(commonLibrariesPath)];
- return result.concat(modules.map(function (moduleName) {
+ return result.concat(modules.map(function(moduleName) {
return getModule(moduleName, true);
}));
};
@@ -171,4 +171,5 @@
*/
logLevel: 1
};
-}())
+}()) // eslint-disable-line semi
+// A semicolon on the line above will break the requirejs optimizer
diff --git a/cms/static/cms/js/require-config.js b/cms/static/cms/js/require-config.js
index ebce5dc0f1..45aadf6498 100644
--- a/cms/static/cms/js/require-config.js
+++ b/cms/static/cms/js/require-config.js
@@ -1,4 +1,4 @@
-;(function(require, define) {
+(function(require, define) {
'use strict';
if (window) {
@@ -210,12 +210,12 @@
window.MathJax.Hub.Config({
tex2jax: {
inlineMath: [
- ['\\(','\\)'],
- ['[mathjaxinline]','[/mathjaxinline]']
+ ['\\(', '\\)'],
+ ['[mathjaxinline]', '[/mathjaxinline]']
],
displayMath: [
- ['\\[','\\]'],
- ['[mathjax]','[/mathjax]']
+ ['\\[', '\\]'],
+ ['[mathjax]', '[/mathjax]']
]
}
});
diff --git a/cms/static/cms/js/spec/main_spec.js b/cms/static/cms/js/spec/main_spec.js
index e61d25d444..ed01a312b2 100644
--- a/cms/static/cms/js/spec/main_spec.js
+++ b/cms/static/cms/js/spec/main_spec.js
@@ -2,81 +2,81 @@
(function(sandbox) {
'use strict';
- require(["jquery", "backbone", "cms/js/main", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "jquery.cookie"],
+ require(['jquery', 'backbone', 'cms/js/main', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'jquery.cookie'],
function($, Backbone, main, AjaxHelpers) {
- describe("CMS", function() {
- it("should initialize URL", function() {
- expect(window.CMS.URL).toBeDefined();
- });
- });
- describe("main helper", function() {
- beforeEach(function() {
- this.previousAjaxSettings = $.extend(true, {}, $.ajaxSettings);
- spyOn($, "cookie").and.callFake(function(param) {
- if (param === "csrftoken") {
- return "stubCSRFToken";
- }
+ describe('CMS', function() {
+ it('should initialize URL', function() {
+ expect(window.CMS.URL).toBeDefined();
+ });
});
- return main();
- });
- afterEach(function() {
- $.ajaxSettings = this.previousAjaxSettings;
- return $.ajaxSettings;
- });
- it("turn on Backbone emulateHTTP", function() {
- expect(Backbone.emulateHTTP).toBeTruthy();
- });
- it("setup AJAX CSRF token", function() {
- expect($.ajaxSettings.headers["X-CSRFToken"]).toEqual("stubCSRFToken");
- });
- });
- describe("AJAX Errors", function() {
- var server;
- server = null;
- beforeEach(function() {
- appendSetFixtures(sandbox({
- id: "page-notification"
- }));
- });
- afterEach(function() {
- return server && server.restore();
- });
- it("successful AJAX request does not pop an error notification", function() {
- server = AjaxHelpers.server([
- 200, {
- "Content-Type": "application/json"
- }, "{}"
- ]);
- expect($("#page-notification")).toBeEmpty();
- $.ajax("/test");
- expect($("#page-notification")).toBeEmpty();
- server.respond();
- expect($("#page-notification")).toBeEmpty();
- });
- it("AJAX request with error should pop an error notification", function() {
- server = AjaxHelpers.server([
- 500, {
- "Content-Type": "application/json"
- }, "{}"
- ]);
- $.ajax("/test");
- server.respond();
- expect($("#page-notification")).not.toBeEmpty();
- expect($("#page-notification")).toContainElement('div.wrapper-notification-error');
- });
- it("can override AJAX request with error so it does not pop an error notification", function() {
- server = AjaxHelpers.server([
- 500, {
- "Content-Type": "application/json"
- }, "{}"
- ]);
- $.ajax({
- url: "/test",
- notifyOnError: false
+ describe('main helper', function() {
+ beforeEach(function() {
+ this.previousAjaxSettings = $.extend(true, {}, $.ajaxSettings);
+ spyOn($, 'cookie').and.callFake(function(param) {
+ if (param === 'csrftoken') {
+ return 'stubCSRFToken';
+ }
+ });
+ return main();
+ });
+ afterEach(function() {
+ $.ajaxSettings = this.previousAjaxSettings;
+ return $.ajaxSettings;
+ });
+ it('turn on Backbone emulateHTTP', function() {
+ expect(Backbone.emulateHTTP).toBeTruthy();
+ });
+ it('setup AJAX CSRF token', function() {
+ expect($.ajaxSettings.headers['X-CSRFToken']).toEqual('stubCSRFToken');
+ });
+ });
+ describe('AJAX Errors', function() {
+ var server;
+ server = null;
+ beforeEach(function() {
+ appendSetFixtures(sandbox({
+ id: 'page-notification'
+ }));
+ });
+ afterEach(function() {
+ return server && server.restore();
+ });
+ it('successful AJAX request does not pop an error notification', function() {
+ server = AjaxHelpers.server([
+ 200, {
+ 'Content-Type': 'application/json'
+ }, '{}'
+ ]);
+ expect($('#page-notification')).toBeEmpty();
+ $.ajax('/test');
+ expect($('#page-notification')).toBeEmpty();
+ server.respond();
+ expect($('#page-notification')).toBeEmpty();
+ });
+ it('AJAX request with error should pop an error notification', function() {
+ server = AjaxHelpers.server([
+ 500, {
+ 'Content-Type': 'application/json'
+ }, '{}'
+ ]);
+ $.ajax('/test');
+ server.respond();
+ expect($('#page-notification')).not.toBeEmpty();
+ expect($('#page-notification')).toContainElement('div.wrapper-notification-error');
+ });
+ it('can override AJAX request with error so it does not pop an error notification', function() {
+ server = AjaxHelpers.server([
+ 500, {
+ 'Content-Type': 'application/json'
+ }, '{}'
+ ]);
+ $.ajax({
+ url: '/test',
+ notifyOnError: false
+ });
+ server.respond();
+ expect($('#page-notification')).toBeEmpty();
+ });
});
- server.respond();
- expect($("#page-notification")).toBeEmpty();
});
- });
- });
}).call(this, sandbox);
diff --git a/cms/static/cms/js/xblock/cms.runtime.v1.js b/cms/static/cms/js/xblock/cms.runtime.v1.js
index 6c5e73aaf3..6b07ec80e1 100644
--- a/cms/static/cms/js/xblock/cms.runtime.v1.js
+++ b/cms/static/cms/js/xblock/cms.runtime.v1.js
@@ -24,7 +24,6 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
StudioRuntime = {};
BaseRuntime.v1 = (function(_super) {
-
__extends(v1, _super);
v1.prototype.handlerUrl = function(element, handlerName, suffix, query) {
@@ -150,11 +149,9 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
};
return v1;
-
})(XBlock.Runtime.v1);
PreviewRuntime.v1 = (function(_super) {
-
__extends(v1, _super);
function v1() {
@@ -164,11 +161,9 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
v1.prototype.handlerPrefix = '/preview/xblock';
return v1;
-
})(BaseRuntime.v1);
StudioRuntime.v1 = (function(_super) {
-
__extends(v1, _super);
function v1() {
@@ -178,7 +173,6 @@ define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/m
v1.prototype.handlerPrefix = '/xblock';
return v1;
-
})(BaseRuntime.v1);
// Install the runtime's into the global namespace
diff --git a/cms/static/js/base.js b/cms/static/js/base.js
index 94c6cc2648..ed2c75f7bf 100644
--- a/cms/static/js/base.js
+++ b/cms/static/js/base.js
@@ -1,19 +1,19 @@
require([
- "domReady",
- "jquery",
- "underscore",
- "gettext",
- "common/js/components/views/feedback_notification",
- "common/js/components/views/feedback_prompt",
- "js/utils/date_utils",
- "js/utils/module",
- "js/utils/handle_iframe_binding",
- "edx-ui-toolkit/js/dropdown-menu/dropdown-menu-view",
- "jquery.ui",
- "jquery.leanModal",
- "jquery.form",
- "jquery.smoothScroll"
- ],
+ 'domReady',
+ 'jquery',
+ 'underscore',
+ 'gettext',
+ 'common/js/components/views/feedback_notification',
+ 'common/js/components/views/feedback_prompt',
+ 'js/utils/date_utils',
+ 'js/utils/module',
+ 'js/utils/handle_iframe_binding',
+ 'edx-ui-toolkit/js/dropdown-menu/dropdown-menu-view',
+ 'jquery.ui',
+ 'jquery.leanModal',
+ 'jquery.form',
+ 'jquery.smoothScroll'
+],
function(
domReady,
$,
@@ -27,113 +27,110 @@ require([
DropdownMenuView
)
{
+ var $body;
-var $body;
+ domReady(function() {
+ var dropdownMenuView;
-domReady(function() {
- var dropdownMenuView;
-
- $body = $('body');
+ $body = $('body');
- $body.on('click', '.embeddable-xml-input', function() {
- $(this).select();
- });
+ $body.on('click', '.embeddable-xml-input', function() {
+ $(this).select();
+ });
- $body.addClass('js');
+ $body.addClass('js');
- // alerts/notifications - manual close
- $('.action-alert-close, .alert.has-actions .nav-actions a').bind('click', hideAlert);
- $('.action-notification-close').bind('click', hideNotification);
+ // alerts/notifications - manual close
+ $('.action-alert-close, .alert.has-actions .nav-actions a').bind('click', hideAlert);
+ $('.action-notification-close').bind('click', hideNotification);
- // nav - dropdown related
- $body.click(function(e) {
- $('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
- $('.nav-dd .nav-item .title').removeClass('is-selected');
- });
+ // nav - dropdown related
+ $body.click(function(e) {
+ $('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
+ $('.nav-dd .nav-item .title').removeClass('is-selected');
+ });
- $('.nav-dd .nav-item, .filterable-column .nav-item').click(function(e) {
+ $('.nav-dd .nav-item, .filterable-column .nav-item').click(function(e) {
+ $subnav = $(this).find('.wrapper-nav-sub');
+ $title = $(this).find('.title');
- $subnav = $(this).find('.wrapper-nav-sub');
- $title = $(this).find('.title');
-
- if ($subnav.hasClass('is-shown')) {
- $subnav.removeClass('is-shown');
- $title.removeClass('is-selected');
- } else {
- $('.nav-dd .nav-item .title').removeClass('is-selected');
- $('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
- $title.addClass('is-selected');
- $subnav.addClass('is-shown');
+ if ($subnav.hasClass('is-shown')) {
+ $subnav.removeClass('is-shown');
+ $title.removeClass('is-selected');
+ } else {
+ $('.nav-dd .nav-item .title').removeClass('is-selected');
+ $('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
+ $title.addClass('is-selected');
+ $subnav.addClass('is-shown');
// if propagation is not stopped, the event will bubble up to the
// body element, which will close the dropdown.
- e.stopPropagation();
- }
- });
+ e.stopPropagation();
+ }
+ });
- // general link management - new window/tab
- $('a[rel="external"]:not([title])').attr('title', gettext('This link will open in a new browser window/tab'));
- $('a[rel="external"]').attr('target', '_blank');
+ // general link management - new window/tab
+ $('a[rel="external"]:not([title])').attr('title', gettext('This link will open in a new browser window/tab'));
+ $('a[rel="external"]').attr('target', '_blank');
- // general link management - lean modal window
- $('a[rel="modal"]').attr('title', gettext('This link will open in a modal window')).leanModal({
- overlay: 0.50,
- closeButton: '.action-modal-close'
- });
- $('.action-modal-close').click(function(e) {
- (e).preventDefault();
- });
+ // general link management - lean modal window
+ $('a[rel="modal"]').attr('title', gettext('This link will open in a modal window')).leanModal({
+ overlay: 0.50,
+ closeButton: '.action-modal-close'
+ });
+ $('.action-modal-close').click(function(e) {
+ (e).preventDefault();
+ });
- // general link management - smooth scrolling page links
- $('a[rel*="view"][href^="#"]').bind('click', smoothScrollLink);
+ // general link management - smooth scrolling page links
+ $('a[rel*="view"][href^="#"]').bind('click', smoothScrollLink);
- IframeUtils.iframeBinding();
+ IframeUtils.iframeBinding();
- // disable ajax caching in IE so that backbone fetches work
- if ($.browser.msie) {
- $.ajaxSetup({ cache: false });
- }
+ // disable ajax caching in IE so that backbone fetches work
+ if ($.browser.msie) {
+ $.ajaxSetup({cache: false});
+ }
- //Initiate the edx tool kit dropdown menu
- if ($('.js-header-user-menu').length){
- dropdownMenuView = new DropdownMenuView({
- el: '.js-header-user-menu'
+ // Initiate the edx tool kit dropdown menu
+ if ($('.js-header-user-menu').length) {
+ dropdownMenuView = new DropdownMenuView({
+ el: '.js-header-user-menu'
+ });
+ dropdownMenuView.postRender();
+ }
});
- dropdownMenuView.postRender();
- }
-});
-function smoothScrollLink(e) {
- (e).preventDefault();
+ function smoothScrollLink(e) {
+ (e).preventDefault();
- $.smoothScroll({
- offset: -200,
- easing: 'swing',
- speed: 1000,
- scrollElement: null,
- scrollTarget: $(this).attr('href')
- });
-}
+ $.smoothScroll({
+ offset: -200,
+ easing: 'swing',
+ speed: 1000,
+ scrollElement: null,
+ scrollTarget: $(this).attr('href')
+ });
+ }
-function smoothScrollTop(e) {
- (e).preventDefault();
+ function smoothScrollTop(e) {
+ (e).preventDefault();
- $.smoothScroll({
- offset: -200,
- easing: 'swing',
- speed: 1000,
- scrollElement: null,
- scrollTarget: $('#view-top')
- });
-}
+ $.smoothScroll({
+ offset: -200,
+ easing: 'swing',
+ speed: 1000,
+ scrollElement: null,
+ scrollTarget: $('#view-top')
+ });
+ }
-function hideNotification(e) {
- (e).preventDefault();
- $(this).closest('.wrapper-notification').removeClass('is-shown').addClass('is-hiding').attr('aria-hidden', 'true');
-}
+ function hideNotification(e) {
+ (e).preventDefault();
+ $(this).closest('.wrapper-notification').removeClass('is-shown').addClass('is-hiding').attr('aria-hidden', 'true');
+ }
-function hideAlert(e) {
- (e).preventDefault();
- $(this).closest('.wrapper-alert').removeClass('is-shown');
-}
-
-}); // end require()
+ function hideAlert(e) {
+ (e).preventDefault();
+ $(this).closest('.wrapper-alert').removeClass('is-shown');
+ }
+ }); // end require()
diff --git a/cms/static/js/certificates/collections/certificates.js b/cms/static/js/certificates/collections/certificates.js
index 778a43f7ed..e567514d21 100644
--- a/cms/static/js/certificates/collections/certificates.js
+++ b/cms/static/js/certificates/collections/certificates.js
@@ -29,7 +29,7 @@ function(Backbone, gettext, Certificate) {
} catch (ex) {
// If it didn't parse, and `certificate_info` is an object then return as it is
// otherwise return empty array
- if (typeof certificate_info === 'object'){
+ if (typeof certificate_info === 'object') {
return_array = certificate_info;
}
else {
@@ -44,28 +44,28 @@ function(Backbone, gettext, Certificate) {
return return_array;
},
- onModelRemoved: function () {
+ onModelRemoved: function() {
// remove the certificate web preview UI.
- if(window.certWebPreview && this.length === 0) {
+ if (window.certWebPreview && this.length === 0) {
window.certWebPreview.remove();
}
this.toggleAddNewItemButtonState();
},
- onModelAdd: function () {
+ onModelAdd: function() {
this.toggleAddNewItemButtonState();
},
toggleAddNewItemButtonState: function() {
// user can create a new item e.g certificate; if not exceeded the maxAllowed limit.
- if(this.length >= this.maxAllowed) {
- $(".action-add").addClass('action-add-hidden');
+ if (this.length >= this.maxAllowed) {
+ $('.action-add').addClass('action-add-hidden');
} else {
- $(".action-add").removeClass('action-add-hidden');
+ $('.action-add').removeClass('action-add-hidden');
}
},
- parse: function (certificatesJson) {
+ parse: function(certificatesJson) {
// Transforms the provided JSON into a Certificates collection
var modelArray = this.certificate_array(certificatesJson);
diff --git a/cms/static/js/certificates/factories/certificates_page_factory.js b/cms/static/js/certificates/factories/certificates_page_factory.js
index 39d7941f42..cb935ddb06 100644
--- a/cms/static/js/certificates/factories/certificates_page_factory.js
+++ b/cms/static/js/certificates/factories/certificates_page_factory.js
@@ -20,7 +20,7 @@ define([
],
function($, CertificatesCollection, Certificate, CertificatesPage, CertificatePreview) {
'use strict';
- return function (certificatesJson, certificateUrl, courseOutlineUrl, course_modes, certificate_web_view_url,
+ return function(certificatesJson, certificateUrl, courseOutlineUrl, course_modes, certificate_web_view_url,
is_active, certificate_activation_handler_url) {
// Initialize the model collection, passing any necessary options to the constructor
var certificatesCollection = new CertificatesCollection(certificatesJson, {
@@ -31,7 +31,7 @@ function($, CertificatesCollection, Certificate, CertificatesPage, CertificatePr
// associating the certificate_preview globally.
// need to show / hide this view in some other places.
- if(!window.certWebPreview && certificate_web_view_url) {
+ if (!window.certWebPreview && certificate_web_view_url) {
window.certWebPreview = new CertificatePreview({
course_modes: course_modes,
certificate_web_view_url: certificate_web_view_url,
diff --git a/cms/static/js/certificates/models/certificate.js b/cms/static/js/certificates/models/certificate.js
index 5518867312..a440d569d6 100644
--- a/cms/static/js/certificates/models/certificate.js
+++ b/cms/static/js/certificates/models/certificate.js
@@ -1,15 +1,15 @@
// Backbone.js Application Model: Certificate
define([
- 'underscore',
- 'backbone',
- 'backbone-relational',
- 'backbone.associations',
- 'gettext',
- 'cms/js/main',
- 'js/certificates/models/signatory',
- 'js/certificates/collections/signatories'
- ],
+ 'underscore',
+ 'backbone',
+ 'backbone-relational',
+ 'backbone.associations',
+ 'gettext',
+ 'cms/js/main',
+ 'js/certificates/models/signatory',
+ 'js/certificates/collections/signatories'
+],
function(_, Backbone, BackboneRelational, BackboneAssociations, gettext, CoffeeSrcMain,
SignatoryModel, SignatoryCollection) {
'use strict';
@@ -78,7 +78,7 @@ define([
attributes: {name: true}
};
}
- var allSignatoriesValid = _.every(attrs.signatories.models, function(signatory){
+ var allSignatoriesValid = _.every(attrs.signatories.models, function(signatory) {
return signatory.isValid();
});
if (!allSignatoriesValid) {
diff --git a/cms/static/js/certificates/spec/custom_matchers.js b/cms/static/js/certificates/spec/custom_matchers.js
index 38e21459e0..cd960f469f 100644
--- a/cms/static/js/certificates/spec/custom_matchers.js
+++ b/cms/static/js/certificates/spec/custom_matchers.js
@@ -3,13 +3,13 @@
define(['jquery'], function($) { // eslint-disable-line no-unused-vars
'use strict';
- return function () {
+ return function() {
jasmine.addMatchers({
- toBeCorrectValuesInModel: function () {
+ toBeCorrectValuesInModel: function() {
// Assert the value being tested has key values which match the provided values
return {
- compare: function (actual, values) {
- var passed = _.every(values, function (value, key) {
+ compare: function(actual, values) {
+ var passed = _.every(values, function(value, key) {
return actual.get(key) === value;
}.bind(this));
diff --git a/cms/static/js/certificates/spec/models/certificate_spec.js b/cms/static/js/certificates/spec/models/certificate_spec.js
index bfd229feab..6c37488859 100644
--- a/cms/static/js/certificates/spec/models/certificate_spec.js
+++ b/cms/static/js/certificates/spec/models/certificate_spec.js
@@ -11,7 +11,7 @@ function(CertificateModel, CertificateCollection) {
beforeEach(function() {
this.newModelOptions = {add: true};
this.model = new CertificateModel({editing: true}, this.newModelOptions);
- this.collection = new CertificateCollection([ this.model ], {certificateUrl: '/outline'});
+ this.collection = new CertificateCollection([this.model], {certificateUrl: '/outline'});
});
describe('Basic', function() {
@@ -39,18 +39,16 @@ function(CertificateModel, CertificateCollection) {
describe('Validation', function() {
it('requires a name', function() {
- var model = new CertificateModel({ name: '' }, this.newModelOptions);
+ var model = new CertificateModel({name: ''}, this.newModelOptions);
expect(model.isValid()).toBeFalsy();
});
it('can pass validation', function() {
- var model = new CertificateModel({ name: 'foo' }, this.newModelOptions);
+ var model = new CertificateModel({name: 'foo'}, this.newModelOptions);
expect(model.isValid()).toBeTruthy();
});
-
});
});
-
});
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 863fac166f..4a58c5d97e 100644
--- a/cms/static/js/certificates/spec/views/certificate_details_spec.js
+++ b/cms/static/js/certificates/spec/views/certificate_details_spec.js
@@ -41,15 +41,15 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
inputSignatoryTitle: '.signatory-title-input',
inputSignatoryOrganization: '.signatory-organization-input'
};
- var verifyAndConfirmPrompt = function(promptSpy, promptText){
+ var verifyAndConfirmPrompt = function(promptSpy, promptText) {
ViewHelpers.verifyPromptShowing(promptSpy, gettext(promptText));
ViewHelpers.confirmPrompt(promptSpy);
ViewHelpers.verifyPromptHidden(promptSpy);
};
describe('Certificate Details Spec:', function() {
- var setValuesToInputs = function (view, values) {
- _.each(values, function (value, selector) {
+ var setValuesToInputs = function(view, values) {
+ _.each(values, function(value, selector) {
if (SELECTORS[selector]) {
view.$(SELECTORS[selector]).val(value);
view.$(SELECTORS[selector]).trigger('change');
@@ -96,8 +96,8 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
is_active: true
}, this.newModelOptions);
- this.collection = new CertificatesCollection([ this.model ], {
- certificateUrl: '/certificates/'+ window.course.id
+ this.collection = new CertificatesCollection([this.model], {
+ certificateUrl: '/certificates/' + window.course.id
});
this.model.set('id', 0);
this.view = new CertificateDetailsView({
@@ -120,44 +120,43 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
describe('The Certificate Details view', function() {
-
- it('should parse a JSON string collection into a Backbone model collection', function () {
- var course_title = "Test certificate course title override 2";
+ it('should parse a JSON string collection into a Backbone model collection', function() {
+ var course_title = 'Test certificate course title override 2';
var CERTIFICATE_JSON = '[{"course_title": "' + course_title + '", "signatories":"[]"}]';
this.collection.parse(CERTIFICATE_JSON);
var model = this.collection.at(1);
expect(model.get('course_title')).toEqual(course_title);
});
- it('should parse a JSON object collection into a Backbone model collection', function () {
- var course_title = "Test certificate course title override 2";
+ it('should parse a JSON object collection into a Backbone model collection', function() {
+ var course_title = 'Test certificate course title override 2';
var CERTIFICATE_JSON_OBJECT = [{
- "course_title" : course_title,
- "signatories" : "[]"
+ 'course_title': course_title,
+ 'signatories': '[]'
}];
this.collection.parse(CERTIFICATE_JSON_OBJECT);
var model = this.collection.at(1);
expect(model.get('course_title')).toEqual(course_title);
});
- it('should have empty certificate collection if there is an error parsing certifcate JSON', function () {
+ it('should have empty certificate collection if there is an error parsing certifcate JSON', function() {
var CERTIFICATE_INVALID_JSON = '[{"course_title": Test certificate course title override, "signatories":"[]"}]'; // eslint-disable-line max-len
var collection_length = this.collection.length;
this.collection.parse(CERTIFICATE_INVALID_JSON);
- //collection length should remain the same since we have error parsing JSON
+ // collection length should remain the same since we have error parsing JSON
expect(this.collection.length).toEqual(collection_length);
});
- it('should display the certificate course title override', function () {
+ it('should display the certificate course title override', function() {
expect(this.view.$(SELECTORS.course_title)).toExist();
expect(this.view.$(SELECTORS.course_title)).toContainText('Test Course Title Override');
});
- it('should present an Edit action', function () {
+ it('should present an Edit action', function() {
expect(this.view.$('.edit')).toExist();
});
- it('should change to "edit" mode when clicking the Edit button and confirming the prompt', function(){
+ it('should change to "edit" mode when clicking the Edit button and confirming the prompt', function() {
expect(this.view.$('.action-edit .edit')).toExist();
var promptSpy = ViewHelpers.createPromptSpy();
this.view.$('.action-edit .edit').click();
@@ -165,67 +164,64 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
expect(this.model.get('editing')).toBe(true);
});
- it('should not show confirmation prompt when clicked on "edit" in case of inactive certificate', function(){
+ it('should not show confirmation prompt when clicked on "edit" in case of inactive certificate', function() {
this.model.set('is_active', false);
expect(this.view.$('.action-edit .edit')).toExist();
this.view.$('.action-edit .edit').click();
expect(this.model.get('editing')).toBe(true);
});
- it('should not present a Edit action if user is not global staff and certificate is active', function () {
+ it('should not present a Edit action if user is not global staff and certificate is active', function() {
window.CMS.User = {isGlobalStaff: false};
appendSetFixtures(this.view.render().el);
expect(this.view.$('.action-edit .edit')).not.toExist();
});
- it('should present a Delete action', function () {
+ it('should present a Delete action', function() {
expect(this.view.$('.action-delete .delete')).toExist();
});
- it('should not present a Delete action if user is not global staff and certificate is active', function () {
+ it('should not present a Delete action if user is not global staff and certificate is active', function() {
window.CMS.User = {isGlobalStaff: false};
appendSetFixtures(this.view.render().el);
expect(this.view.$('.action-delete .delete')).not.toExist();
});
- it('should prompt the user when when clicking the Delete button', function(){
+ it('should prompt the user when when clicking the Delete button', function() {
expect(this.view.$('.action-delete .delete')).toExist();
this.view.$('.action-delete .delete').click();
});
- it('should scroll to top after rendering if necessary', function () {
+ it('should scroll to top after rendering if necessary', function() {
$.smoothScroll = jasmine.createSpy('jQuery.smoothScroll');
appendSetFixtures(this.view.render().el);
expect($.smoothScroll).toHaveBeenCalled();
});
-
});
- describe('Signatory details', function(){
-
+ describe('Signatory details', function() {
beforeEach(function() {
this.view.render();
});
- it('displays certificate signatories details', function(){
+ it('displays certificate signatories details', function() {
this.view.$('.show-details').click();
expect(this.view.$(SELECTORS.signatory_name_value)).toContainText('');
expect(this.view.$(SELECTORS.signatory_title_value)).toContainText('');
expect(this.view.$(SELECTORS.signatory_organization_value)).toContainText('');
});
- it('should present Edit action on signaotry', function () {
+ it('should present Edit action on signaotry', function() {
expect(this.view.$(SELECTORS.edit_signatory)).toExist();
});
- it('should not present Edit action on signaotry if user is not global staff and certificate is active', function () {
+ it('should not present Edit action on signaotry if user is not global staff and certificate is active', function() {
window.CMS.User = {isGlobalStaff: false};
this.view.render();
expect(this.view.$(SELECTORS.edit_signatory)).not.toExist();
});
it('supports in-line editing of signatory information', function() {
-
this.view.$(SELECTORS.edit_signatory).click();
expect(this.view.$(SELECTORS.inputSignatoryName)).toExist();
expect(this.view.$(SELECTORS.inputSignatoryTitle)).toExist();
@@ -233,7 +229,6 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
});
it('correctly persists changes made during in-line signatory editing', function() {
-
var requests = AjaxHelpers.requests(this),
notificationSpy = ViewHelpers.createNotificationSpy();
diff --git a/cms/static/js/certificates/spec/views/certificate_editor_spec.js b/cms/static/js/certificates/spec/views/certificate_editor_spec.js
index f674a9d56b..39416e56a8 100644
--- a/cms/static/js/certificates/spec/views/certificate_editor_spec.js
+++ b/cms/static/js/certificates/spec/views/certificate_editor_spec.js
@@ -37,14 +37,14 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
note: '.wrapper-delete-button',
addSignatoryButton: '.action-add-signatory',
signatoryDeleteButton: '.signatory-panel-delete',
- uploadSignatureButton:'.action-upload-signature',
+ uploadSignatureButton: '.action-upload-signature',
uploadDialog: 'form.upload-dialog',
uploadDialogButton: '.action-upload',
uploadDialogFileInput: 'form.upload-dialog input[type=file]',
saveCertificateButton: 'button.action-primary'
};
- var clickDeleteItem = function (that, promptText, element, url) {
+ var clickDeleteItem = function(that, promptText, element, url) {
var requests = AjaxHelpers.requests(that),
promptSpy = ViewHelpers.createPromptSpy(),
notificationSpy = ViewHelpers.createNotificationSpy();
@@ -53,7 +53,7 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
ViewHelpers.verifyPromptShowing(promptSpy, promptText);
ViewHelpers.confirmPrompt(promptSpy);
ViewHelpers.verifyPromptHidden(promptSpy);
- if (!_.isUndefined(url) && !_.isEmpty(url)){
+ if (!_.isUndefined(url) && !_.isEmpty(url)) {
AjaxHelpers.expectJsonRequest(requests, 'POST', url);
expect(_.last(requests).requestHeaders['X-HTTP-Method-Override']).toBe('DELETE');
ViewHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
@@ -62,7 +62,7 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
}
};
- var showConfirmPromptAndClickCancel = function (view, element, promptText) {
+ var showConfirmPromptAndClickCancel = function(view, element, promptText) {
var promptSpy = ViewHelpers.createPromptSpy();
view.$(element).click();
ViewHelpers.verifyPromptShowing(promptSpy, promptText);
@@ -70,15 +70,15 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
ViewHelpers.verifyPromptHidden(promptSpy);
};
- var uploadFile = function (file_path, requests){
+ var uploadFile = function(file_path, requests) {
$(SELECTORS.uploadDialogFileInput).change();
$(SELECTORS.uploadDialogButton).click();
AjaxHelpers.respondWithJson(requests, {asset: {url: file_path}});
};
describe('Certificate editor view', function() {
- var setValuesToInputs = function (view, values) {
- _.each(values, function (value, selector) {
+ var setValuesToInputs = function(view, values) {
+ _.each(values, function(value, selector) {
if (SELECTORS[selector]) {
view.$(SELECTORS[selector]).val(value);
view.$(SELECTORS[selector]).trigger('change');
@@ -86,8 +86,8 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
});
};
var basicModalTpl = readFixtures('basic-modal.underscore'),
- modalButtonTpl = readFixtures('modal-button.underscore'),
- uploadDialogTpl = readFixtures('upload-dialog.underscore');
+ modalButtonTpl = readFixtures('modal-button.underscore'),
+ uploadDialogTpl = readFixtures('upload-dialog.underscore');
beforeEach(function() {
TemplateHelpers.installTemplates(['certificate-editor', 'signatory-editor'], true);
@@ -110,8 +110,8 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
}, this.newModelOptions);
- this.collection = new CertificatesCollection([ this.model ], {
- certificateUrl: '/certificates/'+ window.course.id
+ this.collection = new CertificatesCollection([this.model], {
+ certificateUrl: '/certificates/' + window.course.id
});
this.model.set('id', 0);
this.view = new CertificateEditorView({
@@ -127,20 +127,20 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
delete window.CMS.User;
});
- describe('Basic', function () {
- beforeEach(function(){
+ describe('Basic', function() {
+ beforeEach(function() {
appendSetFixtures(
- $("");
- } else if (kind === "url") {
+ } else if (mimetype === 'application/javascript') {
+ if (kind === 'text') {
+ head.append('');
+ } else if (kind === 'url') {
return ViewUtils.loadJavaScript(data);
}
- } else if (mimetype === "text/html") {
- if (placement === "head") {
+ } else if (mimetype === 'text/html') {
+ if (placement === 'head') {
head.append(data);
}
}
@@ -224,10 +224,10 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie
},
fireNotificationActionEvent: function(event) {
- var eventName = $(event.currentTarget).data("notification-action");
+ var eventName = $(event.currentTarget).data('notification-action');
if (eventName) {
event.preventDefault();
- this.notifyRuntime(eventName, this.model.get("id"));
+ this.notifyRuntime(eventName, this.model.get('id'));
}
}
});
diff --git a/cms/static/js/views/xblock_editor.js b/cms/static/js/views/xblock_editor.js
index e549fa6b54..e2a52672ea 100644
--- a/cms/static/js/views/xblock_editor.js
+++ b/cms/static/js/views/xblock_editor.js
@@ -2,10 +2,9 @@
* XBlockEditorView displays the authoring view of an xblock, and allows the user to switch between
* the available modes.
*/
-define(["jquery", "underscore", "gettext", "js/views/xblock", "js/views/metadata", "js/collections/metadata",
- "jquery.inputnumber"],
- function ($, _, gettext, XBlockView, MetadataView, MetadataCollection) {
-
+define(['jquery', 'underscore', 'gettext', 'js/views/xblock', 'js/views/metadata', 'js/collections/metadata',
+ 'jquery.inputnumber'],
+ function($, _, gettext, XBlockView, MetadataView, MetadataCollection) {
var XBlockEditorView = XBlockView.extend({
// takes XBlockInfo as a model
@@ -40,8 +39,8 @@ define(["jquery", "underscore", "gettext", "js/views/xblock", "js/views/metadata
getDefaultModes: function() {
return [
- { id: 'editor', name: gettext("Editor")},
- { id: 'settings', name: gettext("Settings")}
+ {id: 'editor', name: gettext('Editor')},
+ {id: 'settings', name: gettext('Settings')}
];
},
@@ -134,7 +133,7 @@ define(["jquery", "underscore", "gettext", "js/views/xblock", "js/views/metadata
metadataNameElements = this.$('[data-metadata-name]');
for (i = 0; i < metadataNameElements.length; i++) {
element = metadataNameElements[i];
- metadataName = $(element).data("metadata-name");
+ metadataName = $(element).data('metadata-name');
metadata[metadataName] = element.value;
}
return metadata;
diff --git a/cms/static/js/views/xblock_outline.js b/cms/static/js/views/xblock_outline.js
index 2d4e04398d..6e58b1c67d 100644
--- a/cms/static/js/views/xblock_outline.js
+++ b/cms/static/js/views/xblock_outline.js
@@ -13,10 +13,9 @@
* - scroll_offset - the scroll offset to use for the locator being shown
* - edit_display_name - true if the shown xblock's display name should be in inline edit mode
*/
-define(["jquery", "underscore", "gettext", "js/views/baseview", "common/js/components/utils/view_utils",
- "js/views/utils/xblock_utils", "js/views/xblock_string_field_editor"],
+define(['jquery', 'underscore', 'gettext', 'js/views/baseview', 'common/js/components/utils/view_utils',
+ 'js/views/utils/xblock_utils', 'js/views/xblock_string_field_editor'],
function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, XBlockStringFieldEditor) {
-
var XBlockOutlineView = BaseView.extend({
// takes XBlockInfo as a model
@@ -49,7 +48,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "common/js/compo
// need to add the current model's id/locator to the set of expanded locators
if (this.model.get('is_header_visible') !== null && !this.model.get('is_header_visible')) {
var locator = this.model.get('id');
- if(!_.isUndefined(this.expandedLocators) && !this.expandedLocators.contains(locator)) {
+ if (!_.isUndefined(this.expandedLocators) && !this.expandedLocators.contains(locator)) {
this.expandedLocators.add(locator);
this.refresh();
}
@@ -216,7 +215,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "common/js/compo
onSync: function(event) {
if (ViewUtils.hasChangedAttributes(this.model, ['visibility_state', 'child_info', 'display_name'])) {
- this.onXBlockChange();
+ this.onXBlockChange();
}
},
@@ -246,7 +245,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "common/js/compo
if (locatorElement.length > 0) {
ViewUtils.setScrollOffset(locatorElement, scrollOffset);
} else {
- console.error("Failed to show item with locator " + locatorToShow + "");
+ console.error('Failed to show item with locator ' + locatorToShow + '');
}
if (editDisplayName) {
locatorElement.find('> div[class$="header"] .xblock-field-value-edit').click();
diff --git a/cms/static/js/views/xblock_string_field_editor.js b/cms/static/js/views/xblock_string_field_editor.js
index ad9de8fdaa..d9eeb14fce 100644
--- a/cms/static/js/views/xblock_string_field_editor.js
+++ b/cms/static/js/views/xblock_string_field_editor.js
@@ -5,9 +5,8 @@
* XBlock field's value if it has been changed. If the user presses Escape, then any changes will
* be removed and the input hidden again.
*/
-define(["js/views/baseview", "js/views/utils/xblock_utils"],
- function (BaseView, XBlockViewUtils) {
-
+define(['js/views/baseview', 'js/views/utils/xblock_utils'],
+ function(BaseView, XBlockViewUtils) {
var XBlockStringFieldEditor = BaseView.extend({
events: {
'click .xblock-field-value-edit': 'showInput',
@@ -42,7 +41,7 @@ define(["js/views/baseview", "js/views/utils/xblock_utils"],
return this.$('.xblock-field-value');
},
- getInput: function () {
+ getInput: function() {
return this.$('.xblock-field-input');
},
diff --git a/cms/static/js/views/xblock_validation.js b/cms/static/js/views/xblock_validation.js
index 4733c30f9d..a0e6bcf010 100644
--- a/cms/static/js/views/xblock_validation.js
+++ b/cms/static/js/views/xblock_validation.js
@@ -1,5 +1,5 @@
-define(["jquery", "underscore", "js/views/baseview", "gettext"],
- function ($, _, BaseView, gettext) {
+define(['jquery', 'underscore', 'js/views/baseview', 'gettext'],
+ function($, _, BaseView, gettext) {
/**
* View for xblock validation messages as displayed in Studio.
*/
@@ -12,7 +12,7 @@ define(["jquery", "underscore", "js/views/baseview", "gettext"],
this.root = options.root;
},
- render: function () {
+ render: function() {
this.$el.html(this.template({
validation: this.model,
additionalClasses: this.getAdditionalClasses(),
@@ -27,7 +27,7 @@ define(["jquery", "underscore", "js/views/baseview", "gettext"],
* @param messageType
* @returns string representation of css class that will render the correct icon, or null if unknown type
*/
- getIcon: function (messageType) {
+ getIcon: function(messageType) {
if (messageType === this.model.ERROR) {
return 'fa-exclamation-circle';
}
@@ -42,16 +42,16 @@ define(["jquery", "underscore", "js/views/baseview", "gettext"],
* @param messageType
* @returns string display name (translated)
*/
- getDisplayName: function (messageType) {
+ getDisplayName: function(messageType) {
if (messageType === this.model.WARNING || messageType === this.model.NOT_CONFIGURED) {
// Translators: This message will be added to the front of messages of type warning,
// e.g. "Warning: this component has not been configured yet".
- return gettext("Warning");
+ return gettext('Warning');
}
else if (messageType === this.model.ERROR) {
// Translators: This message will be added to the front of messages of type error,
// e.g. "Error: required field is missing".
- return gettext("Error");
+ return gettext('Error');
}
return null;
},
@@ -62,13 +62,12 @@ define(["jquery", "underscore", "js/views/baseview", "gettext"],
*
* @returns string of additional css classes (or empty string)
*/
- getAdditionalClasses: function () {
- if (this.root && this.model.get("summary").type === this.model.NOT_CONFIGURED &&
- this.model.get("messages").length === 0) {
-
- return "no-container-content";
+ getAdditionalClasses: function() {
+ if (this.root && this.model.get('summary').type === this.model.NOT_CONFIGURED &&
+ this.model.get('messages').length === 0) {
+ return 'no-container-content';
}
- return "";
+ return '';
}
});
diff --git a/cms/static/js/xblock/authoring.js b/cms/static/js/xblock/authoring.js
index d9abe7d6a6..ffeed552b9 100644
--- a/cms/static/js/xblock/authoring.js
+++ b/cms/static/js/xblock/authoring.js
@@ -21,7 +21,7 @@
// Cohort partitions (user is allowed to select more than one)
element.find('.field-visibility-content-group input:checked').each(function(index, input) {
- checkboxValues = $(input).val().split("-");
+ checkboxValues = $(input).val().split('-');
partitionId = parseInt(checkboxValues[0], 10);
groupId = parseInt(checkboxValues[1], 10);
@@ -61,7 +61,7 @@
VisibilityEditorView.prototype.collectFieldData = function collectFieldData() {
return {
metadata: {
- "group_access": this.getGroupAccess()
+ 'group_access': this.getGroupAccess()
}
};
};
diff --git a/cms/static/js/xblock_asides/structured_tags.js b/cms/static/js/xblock_asides/structured_tags.js
index 2fe124e30a..40e6c3e0a8 100644
--- a/cms/static/js/xblock_asides/structured_tags.js
+++ b/cms/static/js/xblock_asides/structured_tags.js
@@ -2,10 +2,9 @@
'use strict';
function StructuredTagsView(runtime, element) {
-
var $element = $(element);
- $element.find("select").each(function() {
+ $element.find('select').each(function() {
var loader = this;
var sts = $(this).attr('structured-tags-select-init');
diff --git a/cms/static/karma_cms_squire.conf.js b/cms/static/karma_cms_squire.conf.js
index 97361e1a71..d861dc99ca 100644
--- a/cms/static/karma_cms_squire.conf.js
+++ b/cms/static/karma_cms_squire.conf.js
@@ -41,6 +41,6 @@ var options = {
]
};
-module.exports = function (config) {
+module.exports = function(config) {
configModule.configure(config, options);
};