Merge pull request #11631 from edx/fedx/upgrade-libraries
Upgrade Underscore.js and Underscore.string.js
This commit is contained in:
@@ -115,7 +115,7 @@ describe "ThreadResponseShowView", ->
|
||||
expect(@view.$(".posted-details").text()).not.toMatch("marked as answer")
|
||||
|
||||
it "allows a moderator to mark an answer in a question thread", ->
|
||||
DiscussionUtil.loadRoles({"Moderator": parseInt(window.user.id)})
|
||||
DiscussionUtil.loadRoles({"Moderator": [parseInt(window.user.id)]})
|
||||
@thread.set({
|
||||
"thread_type": "question",
|
||||
"user_id": (parseInt(window.user.id) + 1).toString()
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
class @DiscussionFilter
|
||||
|
||||
# TODO: this helper class duplicates functionality in DiscussionThreadListView.filterTopics
|
||||
# for use with a very similar category dropdown in the New Post form. The two menus' implementations
|
||||
# should be merged into a single reusable view.
|
||||
|
||||
@filterDrop: (e) ->
|
||||
$drop = $(e.target).parents('.topic-menu-wrapper')
|
||||
query = $(e.target).val()
|
||||
$items = $drop.find('.topic-menu-item')
|
||||
|
||||
if(query.length == 0)
|
||||
$items.removeClass('hidden')
|
||||
return;
|
||||
|
||||
$items.addClass('hidden')
|
||||
$items.each (i) ->
|
||||
|
||||
path = $(this).parents(".topic-menu-item").andSelf()
|
||||
pathTitles = path.children(".topic-title").map((i, elem) -> $(elem).text()).get()
|
||||
pathText = pathTitles.join(" / ").toLowerCase()
|
||||
|
||||
if query.split(" ").every((term) -> pathText.search(term.toLowerCase()) != -1)
|
||||
$(this).removeClass('hidden')
|
||||
# show children
|
||||
$(this).find('.topic-menu-item').removeClass('hidden');
|
||||
# show parents
|
||||
$(this).parents('.topic-menu-item').removeClass('hidden');
|
||||
@@ -19,7 +19,7 @@
|
||||
this.threadType = this.model.get('thread_type');
|
||||
this.topicId = this.model.get('commentable_id');
|
||||
this.context = options.context || 'course';
|
||||
_.bindAll(this);
|
||||
_.bindAll(this, 'updateHandler', 'cancelHandler');
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ if Backbone?
|
||||
|
||||
@searchAlertCollection.on "add", (searchAlert) =>
|
||||
content = _.template(
|
||||
$("#search-alert-template").html(),
|
||||
$("#search-alert-template").html())(
|
||||
{'message': searchAlert.attributes.message, 'cid': searchAlert.cid}
|
||||
)
|
||||
)
|
||||
@$(".search-alerts").append(content)
|
||||
@$("#search-alert-" + searchAlert.cid + " a.dismiss").bind "click", searchAlert, (event) =>
|
||||
@removeSearchAlert(event.data.cid)
|
||||
@@ -491,7 +491,7 @@ if Backbone?
|
||||
message = interpolate(
|
||||
_.escape(gettext('Show posts by %(username)s.')),
|
||||
{"username":
|
||||
_.template('<a class="link-jump" href="<%= url %>"><%- username %></a>', {
|
||||
_.template('<a class="link-jump" href="<%= url %>"><%- username %></a>')({
|
||||
url: DiscussionUtil.urlFor("user_profile", response.users[0].id),
|
||||
username: response.users[0].username
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'click .post-topic-button': 'toggleTopicDropdown',
|
||||
'click .topic-menu-wrapper': 'handleTopicEvent',
|
||||
'click .topic-filter-label': 'ignoreClick',
|
||||
'keyup .topic-filter-input': this.DiscussionFilter.filterDrop
|
||||
'keyup .topic-filter-input': 'filterDrop'
|
||||
},
|
||||
|
||||
attributes: {
|
||||
@@ -17,7 +17,9 @@
|
||||
this.course_settings = options.course_settings;
|
||||
this.currentTopicId = options.topicId;
|
||||
this.maxNameWidth = 100;
|
||||
_.bindAll(this);
|
||||
_.bindAll(this,
|
||||
'toggleTopicDropdown', 'handleTopicEvent', 'hideTopicDropdown', 'ignoreClick'
|
||||
);
|
||||
return this;
|
||||
},
|
||||
|
||||
@@ -34,7 +36,7 @@
|
||||
render: function() {
|
||||
var context = _.clone(this.course_settings.attributes);
|
||||
context.topics_html = this.renderCategoryMap(this.course_settings.get('category_map'));
|
||||
this.$el.html(_.template($('#topic-template').html(), context));
|
||||
this.$el.html(_.template($('#topic-template').html())(context));
|
||||
this.dropdownButton = this.$('.post-topic-button');
|
||||
this.topicMenu = this.$('.topic-menu-wrapper');
|
||||
this.selectedTopic = this.$('.js-selected-topic');
|
||||
@@ -187,6 +189,38 @@
|
||||
}
|
||||
}
|
||||
return name;
|
||||
},
|
||||
|
||||
// TODO: this helper class duplicates functionality in DiscussionThreadListView.filterTopics
|
||||
// for use with a very similar category dropdown in the New Post form. The two menus' implementations
|
||||
// should be merged into a single reusable view.
|
||||
filterDrop: function (e) {
|
||||
var $drop, $items, query;
|
||||
$drop = $(e.target).parents('.topic-menu-wrapper');
|
||||
query = $(e.target).val();
|
||||
$items = $drop.find('.topic-menu-item');
|
||||
|
||||
if (query.length === 0) {
|
||||
$items.removeClass('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
$items.addClass('hidden');
|
||||
$items.each(function (_index, item) {
|
||||
var path, pathText, pathTitles;
|
||||
path = $(item).parents(".topic-menu-item").andSelf();
|
||||
pathTitles = path.children(".topic-title").map(function (_, elem) {
|
||||
return $(elem).text();
|
||||
}).get();
|
||||
pathText = pathTitles.join(" / ").toLowerCase();
|
||||
if (query.split(" ").every(function (term) {
|
||||
return pathText.search(term.toLowerCase()) !== -1;
|
||||
})) {
|
||||
$(item).removeClass('hidden');
|
||||
$(item).find('.topic-menu-item').removeClass('hidden');
|
||||
$(item).parents('.topic-menu-item').removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ if Backbone?
|
||||
mode: @mode,
|
||||
form_id: @mode + (if @topicId then "-" + @topicId else "")
|
||||
})
|
||||
@$el.html(_.template($("#new-post-template").html(), context))
|
||||
@$el.html(_.template($("#new-post-template").html())(context))
|
||||
threadTypeTemplate = _.template($("#thread-type-template").html());
|
||||
if $('.js-group-select').is(':disabled')
|
||||
$('.group-selector-wrapper').addClass('disabled')
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
* underlying server API.
|
||||
*/
|
||||
getPage: function () {
|
||||
// TODO: this.currentPage is currently returning a function sometimes when it is called.
|
||||
// It is possible it always did this, but we either need to investigate more, or just wait until
|
||||
// we replace this code with the pattern library.
|
||||
return this.currentPage + (this.isZeroIndexed ? 1 : 0);
|
||||
},
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@
|
||||
if (!validateTotalKeyLength(key_field_selectors)) {
|
||||
$(selectors.errorWrapper).addClass(classes.shown).removeClass(classes.hiding);
|
||||
$(selectors.errorMessage).html(
|
||||
'<p>' + _.template(message_tpl, {limit: MAX_SUM_KEY_LENGTH}) + '</p>'
|
||||
'<p>' + _.template(message_tpl)({limit: MAX_SUM_KEY_LENGTH}) + '</p>'
|
||||
);
|
||||
$(selectors.save).addClass(classes.disabled);
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
|
||||
function($, _, str, SystemFeedbackView) {
|
||||
str = str || _.str;
|
||||
|
||||
var Alert = SystemFeedbackView.extend({
|
||||
options: $.extend({}, SystemFeedbackView.prototype.options, {
|
||||
type: "alert"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
|
||||
function($, _, str, SystemFeedbackView) {
|
||||
str = str || _.str;
|
||||
|
||||
var Notification = SystemFeedbackView.extend({
|
||||
options: $.extend({}, SystemFeedbackView.prototype.options, {
|
||||
type: "notification",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
|
||||
function($, _, str, SystemFeedbackView) {
|
||||
str = str || _.str;
|
||||
|
||||
var Prompt = SystemFeedbackView.extend({
|
||||
options: $.extend({}, SystemFeedbackView.prototype.options, {
|
||||
type: "prompt",
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.html(_.template(paginatedViewTemplate, {type: this.type}));
|
||||
this.$el.html(_.template(paginatedViewTemplate)({type: this.type}));
|
||||
this.assign(this.listView, '.' + this.type + '-list');
|
||||
if (this.headerView) {
|
||||
this.assign(this.headerView, '.' + this.type + '-paging-header');
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
this.$el.removeClass('hidden');
|
||||
}
|
||||
}
|
||||
this.$el.html(_.template(paging_footer_template, {
|
||||
this.$el.html(_.template(paging_footer_template)({
|
||||
current_page: this.collection.getPage(),
|
||||
total_pages: this.collection.totalPages
|
||||
}));
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
context, true
|
||||
);
|
||||
}
|
||||
this.$el.html(_.template(headerTemplate, {
|
||||
this.$el.html(_.template(headerTemplate)({
|
||||
message: message,
|
||||
srInfo: this.srInfo,
|
||||
sortableFields: this.collection.sortableFields,
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(_.template(searchFieldTemplate, {
|
||||
this.$el.html(_.template(searchFieldTemplate)({
|
||||
type: this.type,
|
||||
searchString: this.collection.searchString,
|
||||
searchLabel: this.label
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
* by the access view, but doing it here helps keep the
|
||||
* utility self-contained.
|
||||
*/
|
||||
if (_.isUndefined(_s)) {
|
||||
_s = _.str;
|
||||
}
|
||||
_.mixin( _s.exports() );
|
||||
|
||||
utils = (function(){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% if (!readOnly) { %>
|
||||
<ul class="<%= contentType %>-actions-list">
|
||||
<% _.each(primaryActions, function(action) { print(_.template($('#forum-action-' + action).html(), {})) }) %>
|
||||
<% _.each(primaryActions, function(action) { print(_.template($('#forum-action-' + action).html())({})) }) %>
|
||||
<li class="actions-item is-visible">
|
||||
<div class="more-wrapper">
|
||||
<a href="javascript:void(0)" class="action-button action-more" role="button" aria-haspopup="true" aria-controls="action-menu-<%= contentId %>">
|
||||
@@ -9,7 +9,7 @@
|
||||
</a>
|
||||
<div class="actions-dropdown" id="action-menu-<%= contentType %>" aria-expanded="false">
|
||||
<ul class="actions-dropdown-list">
|
||||
<% _.each(secondaryActions, function(action) { print(_.template($('#forum-action-' + action).html(), {})) }) %>
|
||||
<% _.each(secondaryActions, function(action) { print(_.template($('#forum-action-' + action).html())({})) }) %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="response-body"><%- body %></div>
|
||||
<%=
|
||||
_.template(
|
||||
$('#forum-actions').html(),
|
||||
$('#forum-actions').html())(
|
||||
{
|
||||
contentId: cid,
|
||||
contentType: 'comment',
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="response-header-actions">
|
||||
<%=
|
||||
_.template(
|
||||
$('#forum-actions').html(),
|
||||
$('#forum-actions').html())(
|
||||
{
|
||||
contentId: cid,
|
||||
contentType: 'response',
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="post-header-actions post-extended-content">
|
||||
<%=
|
||||
_.template(
|
||||
$('#forum-actions').html(),
|
||||
$('#forum-actions').html())(
|
||||
{
|
||||
contentId: cid,
|
||||
contentType: 'post',
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
var interpolate_ntext = function (singular, plural, count, values) {
|
||||
var text = count === 1 ? singular : plural;
|
||||
return _.template(text, values, {interpolate: /\{(.+?)\}/g});
|
||||
return _.template(text, {interpolate: /\{(.+?)\}/g})(values);
|
||||
};
|
||||
this.interpolate_ntext = interpolate_ntext;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* @returns the text with placeholder values filled in
|
||||
*/
|
||||
var interpolate_text = function (text, values) {
|
||||
return _.template(text, values, {interpolate: /\{(.+?)\}/g});
|
||||
return _.template(text, {interpolate: /\{(.+?)\}/g})(values);
|
||||
};
|
||||
this.interpolate_text = interpolate_text;
|
||||
}).call(this, _);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
|
||||
this.hide();
|
||||
_.bindAll(this);
|
||||
_.bindAll(this, 'show', 'hide', 'showTooltip', 'moveTooltip', 'hideTooltip', 'click');
|
||||
this.bindEvents();
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
common/static/js/vendor/underscore.string.min.js
vendored
Symbolic link
1
common/static/js/vendor/underscore.string.min.js
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../node_modules/underscore.string/dist/underscore.string.min.js
|
||||
Reference in New Issue
Block a user