Skip to content

Commit

Permalink
Merge pull request #11631 from edx/fedx/upgrade-libraries
Browse files Browse the repository at this point in the history
Upgrade Underscore.js and Underscore.string.js
  • Loading branch information
andy-armstrong committed Mar 18, 2016
2 parents f3d000e + e5c7fdd commit 76b8e2e
Show file tree
Hide file tree
Showing 91 changed files with 229 additions and 488 deletions.
4 changes: 2 additions & 2 deletions cms/static/js/certificates/views/signatory_editor.js
Expand Up @@ -129,9 +129,9 @@ function ($, _, Backbone, gettext,
if (event && event.preventDefault) { event.preventDefault(); }
var model = this.model;
var self = this;
var titleText = gettext('Delete "<%= signatoryName %>" from the list of signatories?');
var titleTextTemplate = _.template(gettext('Delete "<%= signatoryName %>" from the list of signatories?'));
var confirm = new PromptView.Warning({
title: _.template(titleText, {signatoryName: model.get('name')}),
title: titleTextTemplate({signatoryName: model.get('name')}),
message: gettext('This action cannot be undone.'),
actions: {
primary: {
Expand Down
7 changes: 4 additions & 3 deletions cms/static/js/models/settings/course_grader.js
Expand Up @@ -66,9 +66,10 @@ var CourseGrader = Backbone.Model.extend({
else attrs.drop_count = intDropCount;
}
if (_.has(attrs, 'min_count') && _.has(attrs, 'drop_count') && !_.has(errors, 'min_count') && !_.has(errors, 'drop_count') && attrs.drop_count > attrs.min_count) {
errors.drop_count = _.template(
gettext("Cannot drop more <% attrs.types %> than will assigned."),
attrs, {variable: 'attrs'});
var template = _.template(
gettext("Cannot drop more <%= types %> assignments than are assigned.")
);
errors.drop_count = template({types: attrs.type});
}
if (!_.isEmpty(errors)) return errors;
}
Expand Down
5 changes: 2 additions & 3 deletions cms/static/js/models/uploads.js
Expand Up @@ -15,8 +15,7 @@ var FileUpload = Backbone.Model.extend({
validate: function(attrs, options) {
if(attrs.selectedFile && !this.checkTypeValidity(attrs.selectedFile)) {
return {
message: _.template(
gettext("Only <%= fileTypes %> files can be uploaded. Please select a file ending in <%= fileExtensions %> to upload."),
message: _.template(gettext("Only <%= fileTypes %> files can be uploaded. Please select a file ending in <%= fileExtensions %> to upload."))( // jshint ignore:line
this.formatValidTypes()
),
attributes: {selectedFile: true}
Expand Down Expand Up @@ -64,7 +63,7 @@ var FileUpload = Backbone.Model.extend({
}
var or = gettext('or');
var formatTypes = function(types) {
return _.template('<%= initial %> <%= or %> <%= last %>', {
return _.template('<%= initial %> <%= or %> <%= last %>')({
initial: _.initial(types).join(', '),
or: or,
last: _.last(types)
Expand Down
12 changes: 6 additions & 6 deletions cms/static/js/utils/drag_and_drop.js
Expand Up @@ -359,12 +359,12 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "draggabilly",
makeDraggable: function (element, options) {
var draggable;
options = _.defaults({
type: null,
handleClass: null,
droppableClass: null,
parentLocationSelector: null,
refresh: null,
ensureChildrenRendered: null
type: undefined,
handleClass: undefined,
droppableClass: undefined,
parentLocationSelector: undefined,
refresh: undefined,
ensureChildrenRendered: undefined
}, options);

if ($(element).data('droppable-class') !== options.droppableClass) {
Expand Down
2 changes: 1 addition & 1 deletion cms/static/js/views/assets.js
Expand Up @@ -67,7 +67,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/models/asset
ViewUtils.hideLoadingIndicator();

// Create the table
this.$el.html(_.template(asset_library_template, {typeData: this.typeData}));
this.$el.html(_.template(asset_library_template)({typeData: this.typeData}));
tableBody = this.$('#asset-table-body');
this.tableBody = tableBody;
this.pagingHeader = new PagingHeader({view: this, el: $('#asset-paging-header')});
Expand Down
8 changes: 4 additions & 4 deletions cms/static/js/views/edit_chapter.js
@@ -1,3 +1,5 @@
/*global course */

define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gettext", "js/models/uploads", "js/views/uploads"],
function(BaseView, _, str, $, gettext, FileUploadModel, UploadDialogView) {
_.str = str; // used in template
Expand Down Expand Up @@ -52,10 +54,8 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette
asset_path: this.$("input.chapter-asset-path").val()
});
var msg = new FileUploadModel({
title: _.template(
gettext("Upload a new PDF to “<%= name %>”"),
{name: window.course.escape('name')}
),
title: _.template(gettext("Upload a new PDF to “<%= name %>”"))(
{name: course.escape('name')}),
message: gettext("Please select a PDF file to upload."),
mimeTypes: ['application/pdf']
});
Expand Down
12 changes: 7 additions & 5 deletions cms/static/js/views/manage_users_and_roles.js
Expand Up @@ -54,8 +54,8 @@ define(['jquery', 'underscore', 'gettext', "js/views/baseview",
title: messages.alreadyMember.title,
message: _.template(
messages.alreadyMember.messageTpl,
{email: email, container: containerName},
{interpolate: /\{(.+?)}/g}
{interpolate: /\{(.+?)}/g})(
{email: email, container: containerName}
),
actions: {
primary: {
Expand Down Expand Up @@ -140,7 +140,9 @@ define(['jquery', 'underscore', 'gettext', "js/views/baseview",
roles = _.object(_.pluck(this.roles, 'key'), _.pluck(this.roles, "name")),
adminRoleCount = this.getAdminRoleCount(),
viewHelpers = {
format: function (template, data) { return _.template(template, data, {interpolate: /\{(.+?)}/g}); }
format: function (template, data) {
return _.template(template, {interpolate: /\{(.+?)}/g})(data);
}
};
for (var i = 0; i < this.users.length; i++) {
var user = this.users[i],
Expand Down Expand Up @@ -284,8 +286,8 @@ define(['jquery', 'underscore', 'gettext', "js/views/baseview",
title: self.messages.deleteUser.title,
message: _.template(
self.messages.deleteUser.messageTpl,
{email: email, container: self.containerName},
{interpolate: /\{(.+?)}/g}
{interpolate: /\{(.+?)}/g})(
{email: email, container: self.containerName}
),
actions: {
primary: {
Expand Down
242 changes: 0 additions & 242 deletions cms/static/js/views/overview.js

This file was deleted.

4 changes: 1 addition & 3 deletions cms/static/js/views/paging_header.js
Expand Up @@ -22,9 +22,7 @@ define(["underscore", "backbone", "gettext", "text!templates/paging-header.under
currentPage = collection.currentPage,
lastPage = collection.totalPages - 1,
messageHtml = this.messageHtml();
this.$el.html(_.template(paging_header_template, {
messageHtml: messageHtml
}));
this.$el.html(_.template(paging_header_template)({ messageHtml: messageHtml}));
this.$(".previous-page-link").toggleClass("is-disabled", currentPage === 0).attr('aria-disabled', currentPage === 0);
this.$(".next-page-link").toggleClass("is-disabled", currentPage === lastPage).attr('aria-disabled', currentPage === lastPage);
return this;
Expand Down
7 changes: 3 additions & 4 deletions cms/static/js/views/show_textbook.js
Expand Up @@ -27,10 +27,9 @@ define(["js/views/baseview", "underscore", "gettext", "common/js/components/view
},
confirmDelete: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
var textbook = this.model, collection = this.model.collection;
var msg = new PromptView.Warning({
title: _.template(
gettext("Delete “<%= name %>”?"),
var textbook = this.model;
new PromptView.Warning({
title: _.template(gettext("Delete “<%= name %>”?"))(
{name: textbook.get('name')}
),
message: gettext("Deleting a textbook cannot be undone and once deleted any reference to it in your courseware's navigation will also be removed."),
Expand Down

0 comments on commit 76b8e2e

Please sign in to comment.