Revert "fix: all auto fixable eslint issues (#31900)" (#32203)

This reverts commit 228180b1ef.
This commit is contained in:
Syed Ali Abbas Zaidi
2023-05-09 13:53:54 +05:00
committed by GitHub
parent 228180b1ef
commit adf879e8b2
354 changed files with 1489 additions and 1498 deletions

View File

@@ -11,7 +11,7 @@ function NextArrow(props) {
} = props;
const showArrow = slideCount - currentSlide > displayedSlides;
const opts = {
className: classNames('js-carousel-nav', 'carousel-arrow', 'next', 'btn btn-secondary', {active: showArrow}),
className: classNames('js-carousel-nav', 'carousel-arrow', 'next', 'btn btn-secondary', {'active': showArrow}),
onClick
};
@@ -32,7 +32,7 @@ function PrevArrow(props) {
const {currentSlide, onClick} = props;
const showArrow = currentSlide > 0;
const opts = {
className: classNames('js-carousel-nav', 'carousel-arrow', 'prev', 'btn btn-secondary', {active: showArrow}),
className: classNames('js-carousel-nav', 'carousel-arrow', 'prev', 'btn btn-secondary', {'active': showArrow}),
onClick
};
@@ -87,7 +87,7 @@ export default class ExperimentalCarousel extends React.Component {
},
tabIndex: tabIndex,
className: 'carousel-item'
};
}
return (
<div {...carouselLinkProps}>

View File

@@ -66,14 +66,14 @@
initialize: function(options) {
this.options = _.extend({}, this.options, options);
if (!this.options.type) {
throw `SystemFeedback: type required (given ${// eslint-disable-line no-throw-literal
JSON.stringify(this.options)})`;
throw 'SystemFeedback: type required (given ' // eslint-disable-line no-throw-literal
+ JSON.stringify(this.options) + ')';
}
if (!this.options.intent) {
throw `SystemFeedback: intent required (given ${// eslint-disable-line no-throw-literal
JSON.stringify(this.options)})`;
throw 'SystemFeedback: intent required (given ' // eslint-disable-line no-throw-literal
+ JSON.stringify(this.options) + ')';
}
this.setElement($(`#page-${this.options.type}`));
this.setElement($('#page-' + this.options.type));
// handle single "secondary" action
if (this.options.actions && this.options.actions.secondary
&& !_.isArray(this.options.actions.secondary)) {
@@ -154,13 +154,13 @@
// there can be only one active view of a given type at a time: only
// one alert, only one notification, only one prompt. Therefore, we'll
// use a singleton approach.
var singleton = SystemFeedback[`active_${this.options.type}`];
var singleton = SystemFeedback['active_' + this.options.type];
if (singleton && singleton !== this) {
singleton.stopListening();
singleton.undelegateEvents();
}
HtmlUtils.setHtml(this.$el, HtmlUtils.template(systemFeedbackTemplate)(this.options));
SystemFeedback[`active_${this.options.type}`] = this;
SystemFeedback['active_' + this.options.type] = this;
return this;
},

View File

@@ -30,14 +30,14 @@
initialize: function() {
var ItemListView = this.listViewClass.extend({
tagName: 'div',
className: `${this.type}-container`,
className: this.type + '-container',
itemViewClass: this.itemViewClass
});
this.listView = new ItemListView({collection: this.collection});
this.headerView = this.createHeaderView();
this.footerView = this.createFooterView();
this.collection.on('page_changed', function() {
this.$(`.sr-is-focusable.sr-${this.type}-view`).focus();
this.$('.sr-is-focusable.sr-' + this.type + '-view').focus();
}, this);
},
@@ -61,12 +61,12 @@
render: function() {
HtmlUtils.setHtml(this.$el, HtmlUtils.template(this.viewTemplate)({type: this.type}));
this.assign(this.listView, `.${this.type}-list`);
this.assign(this.listView, '.' + this.type + '-list');
if (this.headerView) {
this.assign(this.headerView, `.${this.type}-paging-header`);
this.assign(this.headerView, '.' + this.type + '-paging-header');
}
if (this.footerView) {
this.assign(this.footerView, `.${this.type}-paging-footer`);
this.assign(this.footerView, '.' + this.type + '-paging-footer');
}
return this;
},

View File

@@ -21,7 +21,7 @@
HtmlUtils
) {
var getTabPanelId = function(id) {
return `tabpanel-${id}`;
return 'tabpanel-' + id;
};
var TabPanelView = Backbone.View.extend({
@@ -164,7 +164,7 @@
if (index === 0) {
$tab = $(focused).parent().find('.tab').last();
} else {
$tab = $(focused).parent().find(`.tab:eq(${index})`).prev();
$tab = $(focused).parent().find('.tab:eq(' + index + ')').prev();
}
$panel = $($tab).data('index');
@@ -180,7 +180,7 @@
if (index === total) {
$tab = $(focused).parent().find('.tab').first();
} else {
$tab = $(focused).parent().find(`.tab:eq(${index})`).next();
$tab = $(focused).parent().find('.tab:eq(' + index + ')').next();
}
$panel = $($tab).data('index');
@@ -229,10 +229,10 @@
if (typeof tabNameOrIndex === 'string') {
tab = this.urlMap[tabNameOrIndex];
$element = this.$(`button[data-url=${tabNameOrIndex}]`);
$element = this.$('button[data-url=' + tabNameOrIndex + ']');
} else {
tab = this.tabs[tabNameOrIndex];
$element = this.$(`button[data-index=${tabNameOrIndex}]`);
$element = this.$('button[data-index=' + tabNameOrIndex + ']');
}
return {tab: tab, element: $element};
}

View File

@@ -208,7 +208,7 @@
Content.prototype.incrementVote = function(increment) {
var newVotes;
newVotes = _.clone(this.get('votes'));
newVotes.up_count += increment;
newVotes.up_count = newVotes.up_count + increment;
return this.set('votes', newVotes);
};
@@ -237,13 +237,13 @@
return DiscussionUtil.urlFor('create_comment', this.id);
},
unvote: function() {
return DiscussionUtil.urlFor(`undo_vote_for_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('undo_vote_for_' + (this.get('type')), this.id);
},
upvote: function() {
return DiscussionUtil.urlFor(`upvote_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('upvote_' + (this.get('type')), this.id);
},
downvote: function() {
return DiscussionUtil.urlFor(`downvote_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('downvote_' + (this.get('type')), this.id);
},
close: function() {
return DiscussionUtil.urlFor('openclose_thread', this.id);
@@ -261,10 +261,10 @@
return DiscussionUtil.urlFor('unfollow_thread', this.id);
},
flagAbuse: function() {
return DiscussionUtil.urlFor(`flagAbuse_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('flagAbuse_' + (this.get('type')), this.id);
},
unFlagAbuse: function() {
return DiscussionUtil.urlFor(`unFlagAbuse_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('unFlagAbuse_' + (this.get('type')), this.id);
},
pinThread: function() {
return DiscussionUtil.urlFor('pin_thread', this.id);
@@ -350,13 +350,13 @@
return DiscussionUtil.urlFor('create_sub_comment', this.id);
},
unvote: function() {
return DiscussionUtil.urlFor(`undo_vote_for_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('undo_vote_for_' + (this.get('type')), this.id);
},
upvote: function() {
return DiscussionUtil.urlFor(`upvote_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('upvote_' + (this.get('type')), this.id);
},
downvote: function() {
return DiscussionUtil.urlFor(`downvote_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('downvote_' + (this.get('type')), this.id);
},
endorse: function() {
return DiscussionUtil.urlFor('endorse_comment', this.id);
@@ -368,10 +368,10 @@
return DiscussionUtil.urlFor('delete_comment', this.id);
},
flagAbuse: function() {
return DiscussionUtil.urlFor(`flagAbuse_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('flagAbuse_' + (this.get('type')), this.id);
},
unFlagAbuse: function() {
return DiscussionUtil.urlFor(`unFlagAbuse_${this.get('type')}`, this.id);
return DiscussionUtil.urlFor('unFlagAbuse_' + (this.get('type')), this.id);
}
};

View File

@@ -12,7 +12,7 @@
DiscussionUtil.rightKey = 39;
DiscussionUtil.getTemplate = function(id) {
return $(`script#${id}`).html();
return $('script#' + id).html();
};
DiscussionUtil.setUser = function(user) {
@@ -33,7 +33,7 @@
userId = this.user ? this.user.id : void 0;
}
if(_.isUndefined(this.roleIds)) {
this.roleIds = {};
this.roleIds = {}
}
staff = _.union(this.roleIds.Moderator, this.roleIds.Administrator);
return _.include(staff, parseInt(userId));
@@ -77,46 +77,44 @@
DiscussionUtil.generateDiscussionLink = function(cls, txt, handler) {
return $('<a>')
.addClass('discussion-link').attr('href', '#')
.addClass(cls)
.text(txt)
.click(function() { return handler(this); });
.addClass(cls).text(txt).click(function() { return handler(this); });
};
DiscussionUtil.urlFor = function(name, param, param1, param2) {
return {
follow_discussion: `/courses/${$$course_id}/discussion/${param}/follow`,
unfollow_discussion: `/courses/${$$course_id}/discussion/${param}/unfollow`,
create_thread: `/courses/${$$course_id}/discussion/${param}/threads/create`,
update_thread: `/courses/${$$course_id}/discussion/threads/${param}/update`,
create_comment: `/courses/${$$course_id}/discussion/threads/${param}/reply`,
delete_thread: `/courses/${$$course_id}/discussion/threads/${param}/delete`,
flagAbuse_thread: `/courses/${$$course_id}/discussion/threads/${param}/flagAbuse`,
unFlagAbuse_thread: `/courses/${$$course_id}/discussion/threads/${param}/unFlagAbuse`,
flagAbuse_comment: `/courses/${$$course_id}/discussion/comments/${param}/flagAbuse`,
unFlagAbuse_comment: `/courses/${$$course_id}/discussion/comments/${param}/unFlagAbuse`,
upvote_thread: `/courses/${$$course_id}/discussion/threads/${param}/upvote`,
downvote_thread: `/courses/${$$course_id}/discussion/threads/${param}/downvote`,
pin_thread: `/courses/${$$course_id}/discussion/threads/${param}/pin`,
un_pin_thread: `/courses/${$$course_id}/discussion/threads/${param}/unpin`,
undo_vote_for_thread: `/courses/${$$course_id}/discussion/threads/${param}/unvote`,
follow_thread: `/courses/${$$course_id}/discussion/threads/${param}/follow`,
unfollow_thread: `/courses/${$$course_id}/discussion/threads/${param}/unfollow`,
update_comment: `/courses/${$$course_id}/discussion/comments/${param}/update`,
endorse_comment: `/courses/${$$course_id}/discussion/comments/${param}/endorse`,
create_sub_comment: `/courses/${$$course_id}/discussion/comments/${param}/reply`,
delete_comment: `/courses/${$$course_id}/discussion/comments/${param}/delete`,
upvote_comment: `/courses/${$$course_id}/discussion/comments/${param}/upvote`,
downvote_comment: `/courses/${$$course_id}/discussion/comments/${param}/downvote`,
undo_vote_for_comment: `/courses/${$$course_id}/discussion/comments/${param}/unvote`,
upload: `/courses/${$$course_id}/discussion/upload`,
users: `/courses/${$$course_id}/discussion/users`,
search: `/courses/${$$course_id}/discussion/forum/search`,
retrieve_discussion: `/courses/${$$course_id}/discussion/forum/${param}/inline`,
retrieve_single_thread: `/courses/${$$course_id}/discussion/forum/${param}/threads/${param1}`,
openclose_thread: `/courses/${$$course_id}/discussion/threads/${param}/close`,
user_profile: `/courses/${$$course_id}/discussion/forum/users/${param}`,
followed_threads: `/courses/${$$course_id}/discussion/forum/users/${param}/followed`,
threads: `/courses/${$$course_id}/discussion/forum`,
follow_discussion: '/courses/' + $$course_id + '/discussion/' + param + '/follow',
unfollow_discussion: '/courses/' + $$course_id + '/discussion/' + param + '/unfollow',
create_thread: '/courses/' + $$course_id + '/discussion/' + param + '/threads/create',
update_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/update',
create_comment: '/courses/' + $$course_id + '/discussion/threads/' + param + '/reply',
delete_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/delete',
flagAbuse_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/flagAbuse',
unFlagAbuse_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/unFlagAbuse',
flagAbuse_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/flagAbuse',
unFlagAbuse_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/unFlagAbuse',
upvote_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/upvote',
downvote_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/downvote',
pin_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/pin',
un_pin_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/unpin',
undo_vote_for_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/unvote',
follow_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/follow',
unfollow_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/unfollow',
update_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/update',
endorse_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/endorse',
create_sub_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/reply',
delete_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/delete',
upvote_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/upvote',
downvote_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/downvote',
undo_vote_for_comment: '/courses/' + $$course_id + '/discussion/comments/' + param + '/unvote',
upload: '/courses/' + $$course_id + '/discussion/upload',
users: '/courses/' + $$course_id + '/discussion/users',
search: '/courses/' + $$course_id + '/discussion/forum/search',
retrieve_discussion: '/courses/' + $$course_id + '/discussion/forum/' + param + '/inline',
retrieve_single_thread: '/courses/' + $$course_id + '/discussion/forum/' + param + '/threads/' + param1,
openclose_thread: '/courses/' + $$course_id + '/discussion/threads/' + param + '/close',
user_profile: '/courses/' + $$course_id + '/discussion/forum/users/' + param,
followed_threads: '/courses/' + $$course_id + '/discussion/forum/users/' + param + '/followed',
threads: '/courses/' + $$course_id + '/discussion/forum',
enable_notifications: '/notification_prefs/enable/',
disable_notifications: '/notification_prefs/disable/',
notifications_status: '/notification_prefs/status/'
@@ -314,11 +312,11 @@
return this.processEachMathAndCode(htmlSnippet, function(s, type) {
if (type === 'display') {
return s.replace(RE_DISPLAYMATH, function($0, $1) {
return `\\[${$1}\\]`;
return '\\[' + $1 + '\\]';
});
} else if (type === 'inline') {
return s.replace(RE_INLINEMATH, function($0, $1) {
return `\\(${$1}\\)`;
return '\\(' + $1 + '\\)';
});
} else {
return s;
@@ -328,10 +326,10 @@
DiscussionUtil.makeWmdEditor = function($content, $local, cls_identifier) {
var appended_id, editor, elem, id, imageUploadUrl, placeholder, _processor;
elem = $local(`.${cls_identifier}`);
elem = $local('.' + cls_identifier);
placeholder = elem.data('placeholder');
id = elem.data('id');
appended_id = `-${cls_identifier}-${id}`;
appended_id = '-' + cls_identifier + '-' + id;
imageUploadUrl = this.urlFor('upload');
_processor = function(self) {
return function(text) {
@@ -340,25 +338,25 @@
};
};
editor = Markdown.makeWmdEditor(elem, appended_id, imageUploadUrl, _processor(this));
this.wmdEditors[`${cls_identifier}-${id}`] = editor;
this.wmdEditors['' + cls_identifier + '-' + id] = editor;
if (placeholder) {
elem.find(`#wmd-input${appended_id}`).attr('placeholder', placeholder);
elem.find('#wmd-input' + appended_id).attr('placeholder', placeholder);
}
return editor;
};
DiscussionUtil.getWmdEditor = function($content, $local, cls_identifier) {
var elem, id;
elem = $local(`.${cls_identifier}`);
elem = $local('.' + cls_identifier);
id = elem.attr('data-id');
return this.wmdEditors[`${cls_identifier}-${id}`];
return this.wmdEditors['' + cls_identifier + '-' + id];
};
DiscussionUtil.getWmdInput = function($content, $local, cls_identifier) {
var elem, id;
elem = $local(`.${cls_identifier}`);
elem = $local('.' + cls_identifier);
id = elem.attr('data-id');
return $local(`#wmd-input-${cls_identifier}-${id}`);
return $local('#wmd-input-' + cls_identifier + '-' + id);
};
DiscussionUtil.getWmdContent = function($content, $local, cls_identifier) {
@@ -397,7 +395,7 @@
while (true) {
if (RE_INLINEMATH.test(htmlString)) {
htmlString = htmlString.replace(RE_INLINEMATH, function($0, $1, $2, $3) {
processedHtmlString += $1 + processor(`$${$2}$`, 'inline');
processedHtmlString += $1 + processor('$' + $2 + '$', 'inline');
return $3;
});
} else if (RE_DISPLAYMATH.test(htmlString)) {
@@ -405,7 +403,7 @@
/*
corrected mathjax rendering in preview
*/
processedHtmlString += $1 + processor(`$$${$2}$$`, 'display');
processedHtmlString += $1 + processor('$$' + $2 + '$$', 'display');
return $3;
});
} else {
@@ -418,7 +416,7 @@
htmlString = htmlString.replace(new RegExp(ESCAPED_DOLLAR, 'g'), '\\$');
htmlString = htmlString.replace(/\\\\\\\\/g, ESCAPED_BACKSLASH);
htmlString = htmlString.replace(/\\begin\{([a-z]*\*?)\}([\s\S]*?)\\end\{\1\}/img, function($0, $1, $2) {
return processor(`\\begin{${$1}}${$2}\\end{${$1}}`);
return processor(('\\begin{' + $1 + '}') + $2 + ('\\end{' + $1 + '}'));
});
htmlString = htmlString.replace(new RegExp(ESCAPED_BACKSLASH, 'g'), '\\\\\\\\');
htmlString = htmlString.replace(new RegExp(LATEX_SCRIPT, 'g'), '{}');

View File

@@ -236,10 +236,10 @@
var funcName, selector;
selector = event[0];
funcName = event[1];
obj[`click ${selector}`] = function(event) {
obj['click ' + selector] = function(event) {
return this[funcName](event);
};
obj[`keydown ${selector}`] = function(event) {
obj['keydown ' + selector] = function(event) {
return DiscussionUtil.activateOnSpace(event, this[funcName]);
};
return obj;

View File

@@ -51,8 +51,8 @@
loadDiscussions: function($elem, error) {
var discussionId = this.$el.data('discussion-id'),
url = `${DiscussionUtil.urlFor('retrieve_discussion', discussionId)}?page=${this.page}`
+ `&sort_key=${this.defaultSortKey}` + `&sort_order=${this.defaultSortOrder}`,
url = DiscussionUtil.urlFor('retrieve_discussion', discussionId) + ('?page=' + this.page)
+ ('&sort_key=' + this.defaultSortKey) + ('&sort_order=' + this.defaultSortOrder),
self = this;
DiscussionUtil.safeAjax({
@@ -154,7 +154,7 @@
});
this.threadView.render();
this.listenTo(this.threadView.showView, 'thread:_delete', this.navigateToAllPosts);
this.$(`.forum-nav-thread[data-id='${threadId}']`).removeClass('never-read');
this.$(".forum-nav-thread[data-id='" + threadId + "']").removeClass('never-read');
this.threadListView.$el.addClass('is-hidden');
this.$('.inline-thread').removeClass('is-hidden');
},

View File

@@ -37,7 +37,7 @@
this.container.append(this.$el);
this.$submitBtn = this.$('.post-update');
this.addField($threadTypeSelector);
this.$(`#${formId}-post-type-${this.threadType}`).attr('checked', true);
this.$('#' + formId + '-post-type-' + this.threadType).attr('checked', true);
// Only allow the topic field for course threads, as standalone threads
// cannot be moved.
if (this.isTabMode()) {

View File

@@ -122,13 +122,13 @@
css_class: searchAlert.attributes.css_class
});
edx.HtmlUtils.append(self.$('.search-alerts'), content);
return self.$(`#search-alert-${searchAlert.cid} .dismiss`)
return self.$('#search-alert-' + searchAlert.cid + ' .dismiss')
.bind('click', searchAlert, function(event) {
return self.removeSearchAlert(event.data.cid);
});
});
this.searchAlertCollection.on('remove', function(searchAlert) {
return self.$(`#search-alert-${searchAlert.cid}`).remove();
return self.$('#search-alert-' + searchAlert.cid).remove();
});
this.searchAlertCollection.on('reset', function() {
return self.$('.search-alerts').empty();
@@ -163,7 +163,7 @@
this.clearSearchAlerts();
threadId = thread.get('id');
$content = this.renderThread(thread);
$currentElement = this.$(`.forum-nav-thread[data-id=${threadId}]`);
$currentElement = this.$('.forum-nav-thread[data-id=' + threadId + ']');
active = $currentElement.has('.forum-nav-thread-link.is-active').length !== 0;
$currentElement.replaceWith($content);
this.showMetadataAccordingToSort();
@@ -203,7 +203,7 @@
this.$('.forum-nav-filter-main').addClass('is-hidden');
}
this.$('.forum-nav-sort-control option').removeProp('selected');
this.$(`.forum-nav-sort-control option[value=${this.collection.sort_preference}]`)
this.$('.forum-nav-sort-control option[value=' + this.collection.sort_preference + ']')
.prop('selected', true);
this.displayedCollection.on('reset', this.renderThreads);
this.displayedCollection.on('thread:remove', this.renderThreads);
@@ -308,7 +308,7 @@
lastThread = ref ? ref.get('id') : void 0;
if (lastThread) {
this.once('threads:rendered', function() {
var classSelector = `.forum-nav-thread[data-id='${lastThread}'] + .forum-nav-thread `
var classSelector = ".forum-nav-thread[data-id='" + lastThread + "'] + .forum-nav-thread "
+ '.forum-nav-thread-link';
return $(classSelector).focus();
});
@@ -383,14 +383,14 @@
DiscussionThreadListView.prototype.setActiveThread = function(threadId) {
var $srElem;
this.$('.forum-nav-thread-link').find('.sr').remove();
this.$(`.forum-nav-thread[data-id!='${threadId}'] .forum-nav-thread-link`)
this.$(".forum-nav-thread[data-id!='" + threadId + "'] .forum-nav-thread-link")
.removeClass('is-active');
$srElem = edx.HtmlUtils.joinHtml(
edx.HtmlUtils.HTML('<span class="sr">'),
edx.HtmlUtils.ensureHtml(gettext('Current conversation')),
edx.HtmlUtils.HTML('</span>')
).toString();
this.$(`.forum-nav-thread[data-id='${threadId}'] .forum-nav-thread-link`)
this.$(".forum-nav-thread[data-id='" + threadId + "'] .forum-nav-thread-link")
.addClass('is-active').find('.forum-nav-thread-wrapper-1')
.prepend($srElem);
};

View File

@@ -34,7 +34,7 @@
this.startHeader = options.startHeader;
this.is_commentable_divided = options.is_commentable_divided;
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error(`invalid mode: ${this.mode}`);
throw new Error('invalid mode: ' + this.mode);
}
};

View File

@@ -86,7 +86,7 @@
this.options = _.extend({}, options);
this.startHeader = options.startHeader;
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error(`invalid mode: ${this.mode}`);
throw new Error('invalid mode: ' + this.mode);
}
this.readOnly = $('.discussion-module').data('read-only');
this.model.collection.on('reset', function(collection) {

View File

@@ -34,7 +34,7 @@
if (this.getCurrentTopicId()) {
this.setTopic(this.$('.post-topic option').filter(
`[data-discussion-id="${this.getCurrentTopicId()}"]`
'[data-discussion-id="' + this.getCurrentTopicId() + '"]'
));
} else if ($general.length > 0) {
this.setTopic($general.first());
@@ -101,7 +101,7 @@
if (topicElement) {
name = topicElement.html();
_.each(topicElement.parents('optgroup'), function(item) {
name = `${$(item).attr('label')} / ${name}`;
name = $(item).attr('label') + ' / ' + name;
});
return name;
} else {

View File

@@ -39,7 +39,7 @@
this.mode = options.mode || 'inline';
this.startHeader = options.startHeader;
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error(`invalid mode: ${this.mode}`);
throw new Error('invalid mode: ' + this.mode);
}
this.course_settings = options.course_settings;
this.is_commentable_divided = options.is_commentable_divided;
@@ -58,7 +58,7 @@
is_discussion_division_enabled: this.course_settings.get('is_discussion_division_enabled'),
mode: this.mode,
startHeader: this.startHeader,
form_id: this.mode + (this.topicId ? `-${this.topicId}` : '')
form_id: this.mode + (this.topicId ? '-' + this.topicId : '')
});
edx.HtmlUtils.setHtml(
this.$el,

View File

@@ -82,7 +82,7 @@
};
ThreadResponseView.prototype.render = function() {
this.$el.addClass(`response_${this.model.get('id')}`);
this.$el.addClass('response_' + this.model.get('id'));
edx.HtmlUtils.setHtml(this.$el, edx.HtmlUtils.HTML(this.renderTemplate()));
this.delegateEvents();
this.renderShowView();

View File

@@ -3,8 +3,8 @@
initialized we can't override the ExceptionFormatter as Jasmine then uses the stored reference to the function */
(function() {
/* globals jasmineRequire */
'use strict';
'use strict';
var OldExceptionFormatter = jasmineRequire.ExceptionFormatter(),
oldExceptionFormatter = new OldExceptionFormatter(),

View File

@@ -40,11 +40,9 @@
var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../');
var webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js'));
// The following crazy bit is to work around the webpack.optimize.CommonsChunkPlugin
@@ -92,7 +90,7 @@ delete webpackConfig[0].entry;
* @return {String}
*/
function junitNameFormatter(browser, result) {
return `${result.suite[0]}: ${result.description}`;
return result.suite[0] + ': ' + result.description;
}
/**
@@ -101,7 +99,7 @@ function junitNameFormatter(browser, result) {
* @return {String}
*/
function junitClassNameFormatter(browser) {
return `Javascript.${browser.name.split(' ')[0]}`;
return 'Javascript.' + browser.name.split(' ')[0];
}
/**
@@ -186,10 +184,10 @@ function junitSettings(config) {
function defaultNormalizeFunc(appRoot, pattern) { // eslint-disable-line no-shadow
var pat = pattern;
if (pat.match(/^common\/js/)) {
pat = path.join(appRoot, `/common/static/${pat}`);
pat = path.join(appRoot, '/common/static/' + pat);
} else if (pat.match(/^xmodule_js\/common_static/)) {
pat = path.join(appRoot, `/common/static/${
pat.replace(/^xmodule_js\/common_static\//, '')}`);
pat = path.join(appRoot, '/common/static/'
+ pat.replace(/^xmodule_js\/common_static\//, ''));
}
return pat;
}

View File

@@ -29,7 +29,7 @@ define([
generateItems = function(numItems) {
return _.map(_.range(numItems), function(i) {
return {
text: `item ${i}`
text: 'item ' + i
};
});
};
@@ -84,7 +84,7 @@ define([
function expectFooter(options) {
var footerEl = testView.$('.test-paging-footer');
expect(footerEl.text())
.toMatch(new RegExp(`${options.currentPage}\\s+out of\\s+\/\\s+${options.totalPages}`));
.toMatch(new RegExp(options.currentPage + '\\s+out of\\s+\/\\s+' + options.totalPages));
expect(footerEl.hasClass('hidden')).toBe(options.isHidden);
}

View File

@@ -226,7 +226,7 @@
describe('should filter correctly', function() {
return _.each(['all', 'unread', 'unanswered', 'flagged'], function(filterVal) {
it(`for ${filterVal}`, function() {
it('for ' + filterVal, function() {
expectFilter(filterVal);
this.view.$('.forum-nav-filter-main-control').val(filterVal).change();
return expect($.ajax).toHaveBeenCalled();
@@ -734,7 +734,7 @@
.first()
.text()
.trim()
).toEqual(`${newCommentsOnUnreadThread} new`);
).toEqual(newCommentsOnUnreadThread + ' new');
});
it('should display every thread as read if hideReadState: true is passed to the constructor', function() {

View File

@@ -47,7 +47,7 @@
expectedText = '';
if (truncatedText) {
testText = new Array(100).join('test ');
expectedText = `${testText.substring(0, 139)}`;
expectedText = testText.substring(0, 139) + '…';
} else {
testText = 'Test body';
expectedText = 'Test body';
@@ -57,20 +57,20 @@
_ref >= 0 ? _i <= _ref : _i >= _ref;
i = _ref >= 0 ? ++_i : --_i
) {
threadData.body += imageTag;
threadData.body = threadData.body + imageTag;
if (i === 0) {
expectedHtml += imageTag;
expectedHtml = expectedHtml + imageTag;
} else {
expectedHtml = `${expectedHtml}<em>image omitted</em>`;
expectedHtml = expectedHtml + '<em>image omitted</em>';
}
}
}
threadData.body = `${threadData.body}<em>${testText}</em></p>`;
threadData.body = threadData.body + '<em>' + testText + '</em></p>';
if (numberOfImages > 1) {
expectedHtml = `${expectedHtml}<em>${expectedText
}</em></p><p><em>Some images in this post have been omitted</em></p>`;
expectedHtml = expectedHtml + '<em>' + expectedText
+ '</em></p><p><em>Some images in this post have been omitted</em></p>';
} else {
expectedHtml = `${expectedHtml}<em>${expectedText}</em></p>`;
expectedHtml = expectedHtml + '<em>' + expectedText + '</em></p>';
}
view = makeView(makeThread(threadData));
view.render();
@@ -89,7 +89,7 @@
outputHtmlStripped = outputHtmlStripped.replace('Some images in this post have been omitted', '');
outputHtmlStripped = outputHtmlStripped.replace('image omitted', '');
inputHtmlStripped = threadData.body.replace(/(<([^>]+)>)/ig, '');
expectedOutput = `${inputHtmlStripped.substring(0, 139)}`;
expectedOutput = inputHtmlStripped.substring(0, 139) + '…';
expect(outputHtmlStripped).toEqual(expectedOutput);
return expect(view.$el.find('.post-body').html().indexOf('…')).toBeGreaterThan(0);
}
@@ -110,14 +110,14 @@
});
it('untruncated text with markdown body', function() {
var view;
this.threadData.body = `<p>${this.imageTag}<em>Google top search engine</em></p>`;
this.threadData.body = '<p>' + this.imageTag + '<em>Google top search engine</em></p>';
view = makeView(makeThread(this.threadData));
return checkBody(false, view, this.threadData);
});
it('truncated text with markdown body', function() {
var testText, view;
testText = new Array(100).join('test ');
this.threadData.body = `<p>${this.imageTag}${this.imageTag}<em>${testText}</em></p>`;
this.threadData.body = '<p>' + this.imageTag + this.imageTag + '<em>' + testText + '</em></p>';
view = makeView(makeThread(this.threadData));
return checkBody(true, view, this.threadData);
});
@@ -128,8 +128,8 @@
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
truncatedText = _ref1[_j];
it(
`body with ${numImages} images and ${truncatedText ? 'truncated' : 'untruncated'
} text`,
'body with ' + numImages + ' images and ' + (truncatedText ? 'truncated' : 'untruncated')
+ ' text',
// eslint-disable no-loop-func
function() {
return checkPostWithImages(numImages, truncatedText, this.threadData, this.imageTag);

View File

@@ -57,8 +57,8 @@
createTestResponseJson = function(index) {
return {
user_id: window.user.id,
body: `Response ${index}`,
id: `id_${index}`,
body: 'Response ' + index,
id: 'id_' + index,
created_at: '2015-01-01T22:20:28Z'
};
};
@@ -300,8 +300,8 @@
expect(view.$('.js-marked-answer-list .discussion-response').length).toEqual(numEndorsed);
expect(view.$('.js-response-list .discussion-response').length).toEqual(numNonEndorsed);
return assertResponseCountAndPaginationCorrect(
view, `${numNonEndorsed} ${numEndorsed ? 'other ' : ''
}${numNonEndorsed === 1 ? 'response' : 'responses'}`,
view, '' + numNonEndorsed + ' ' + (numEndorsed ? 'other ' : '')
+ (numNonEndorsed === 1 ? 'response' : 'responses'),
numNonEndorsed ? 'Showing all responses' : null, null
);
};
@@ -316,8 +316,8 @@
many: 5
}, function(numNonEndorsed, nonEndorsedDesc) {
it(
`renders correctly with ${endorsedDesc} marked answer(s) and ${nonEndorsedDesc
} response(s)`,
'renders correctly with ' + endorsedDesc + ' marked answer(s) and ' + nonEndorsedDesc
+ ' response(s)',
function() { return renderTestCase(this.view, numEndorsed, numNonEndorsed); }
);
});

View File

@@ -58,9 +58,9 @@
button = view.$el.find('.action-vote');
expect(button.hasClass('is-checked')).toBe(user.voted(model));
expect(button.attr('aria-checked')).toEqual(user.voted(model).toString());
expect(button.find('.vote-count').text()).toMatch(`^${model.get('votes').up_count} Votes?$`);
expect(button.find('.vote-count').text()).toMatch('^' + (model.get('votes').up_count) + ' Votes?$');
return expect(button.find('.sr.js-sr-vote-count').text())
.toMatch(`^there are currently ${model.get('votes').up_count} votes?$`);
.toMatch('^there are currently ' + (model.get('votes').up_count) + ' votes?$');
};
DiscussionViewSpecHelper.checkRenderVote = function(view, model) {
@@ -91,7 +91,7 @@
var initialVoteCount, _ref, _ref1;
expect((_ref = model.id, __indexOf.call(user.get('upvoted_ids'), _ref) >= 0)).toBe(false);
initialVoteCount = model.get('votes').up_count;
triggerVoteEvent(view, event, `${DiscussionUtil.urlFor(`upvote_${model.get('type')}`, model.id)}?ajax=1`);
triggerVoteEvent(view, event, DiscussionUtil.urlFor('upvote_' + (model.get('type')), model.id) + '?ajax=1');
expect((_ref1 = model.id, __indexOf.call(user.get('upvoted_ids'), _ref1) >= 0)).toBe(true);
return expect(model.get('votes').up_count).toEqual(initialVoteCount + 1);
};
@@ -102,7 +102,7 @@
expect((_ref = model.id, __indexOf.call(user.get('upvoted_ids'), _ref) >= 0)).toBe(true);
initialVoteCount = model.get('votes').up_count;
triggerVoteEvent(
view, event, `${DiscussionUtil.urlFor(`undo_vote_for_${model.get('type')}`, model.id)}?ajax=1`
view, event, DiscussionUtil.urlFor('undo_vote_for_' + (model.get('type')), model.id) + '?ajax=1'
);
expect(user.get('upvoted_ids')).toEqual([]);
return expect(model.get('votes').up_count).toEqual(initialVoteCount - 1);

View File

@@ -9,7 +9,7 @@
DiscussionSpecHelper.setUnderscoreFixtures();
window.$$course_id = 'edX/999/test';
spyOn(DiscussionUtil, 'makeWmdEditor').and.callFake(function($content, $local, cls_identifier) {
return $local(`.${cls_identifier}`).html('<textarea></textarea>');
return $local('.' + cls_identifier).html('<textarea></textarea>');
});
this.discussion = new Discussion([], {
pages: 1
@@ -254,7 +254,7 @@
}
};
return _.each(['tab', 'inline'], function(mode) {
it(`resets the form in ${mode} mode`, function() {
it('resets the form in ' + mode + ' mode', function() {
return checkPostCancelReset(mode, this.discussion, this.course_settings);
});
});

View File

@@ -105,7 +105,7 @@
expect(this.view._delete).toHaveBeenCalled();
this.view.showView.trigger('comment:edit', DiscussionSpecHelper.makeEventSpy());
expect(this.view.edit).toHaveBeenCalled();
return expect(this.view.$(`.edit-post-form#comment_${this.comment.id}`))
return expect(this.view.$('.edit-post-form#comment_' + this.comment.id))
.not.toHaveClass('edit-post-form');
});
});
@@ -118,7 +118,7 @@
expect(this.view.update).toHaveBeenCalled();
this.view.editView.trigger('comment:cancel_edit', DiscussionSpecHelper.makeEventSpy());
expect(this.view.cancelEdit).toHaveBeenCalled();
return expect(this.view.$(`.edit-post-form#comment_${this.comment.id}`)).toHaveClass('edit-post-form');
return expect(this.view.$('.edit-post-form#comment_' + this.comment.id)).toHaveClass('edit-post-form');
});
});
describe('edit', function() {

View File

@@ -71,7 +71,7 @@
});
this.view.render();
expect(this.view.$('.posted-details').text().replace(/\s+/g, ' '))
.toMatch(`marked as answer less than a minute ago by ${endorsement.username}`);
.toMatch('marked as answer less than a minute ago by ' + endorsement.username);
return expect(this.view.$('.posted-details > a').attr('href'))
.toEqual('/courses/edX/999/test/discussion/forum/users/test_id');
});
@@ -104,7 +104,7 @@
});
this.view.render();
expect(this.view.$('.posted-details').text().replace(/\s+/g, ' '))
.toMatch(`endorsed less than a minute ago by ${endorsement.username}`);
.toMatch('endorsed less than a minute ago by ' + endorsement.username);
return expect(this.view.$('.posted-details > a').attr('href'))
.toEqual('/courses/edX/999/test/discussion/forum/users/test_id');
});

View File

@@ -171,7 +171,7 @@
];
for (i = 0; i < testFiles.length; i++) {
testFiles[i] = `/base/${testFiles[i]}`;
testFiles[i] = '/base/' + testFiles[i];
}
specHelpers = [

View File

@@ -19,7 +19,7 @@
CUSTOM_MESSAGE = 'custom message';
var createFixture = function(type, name, required, minlength, maxlength, value) {
setFixtures(`<input id="field" type=${type}>`);
setFixtures('<input id="field" type=' + type + '>');
field = $('#field');
field.prop('required', required);

View File

@@ -45,11 +45,11 @@
}
spies = {
constructor: jasmine.createSpy(`${classToFake}'s constructor`)
constructor: jasmine.createSpy('' + classToFake + '\'s constructor')
};
_.each(methodsToSpy, function(methodName) {
spies[methodName] = jasmine.createSpy(`${classToFake}#${methodName}`);
spies[methodName] = jasmine.createSpy('' + classToFake + '#' + methodName);
return fakeClass.prototype[methodName] = function() {
return spies[methodName].apply(this, arguments);
};

View File

@@ -6,14 +6,14 @@ define(['jquery', 'underscore'],
var installTemplate, installTemplates;
installTemplate = function(templateFile, isFirst, templateId) {
var template = readFixtures(`${templateFile}.underscore`),
var template = readFixtures(templateFile + '.underscore'),
templateName = templateFile,
slashIndex = _.lastIndexOf(templateName, '/');
if (slashIndex >= 0) {
templateName = templateFile.substring(slashIndex + 1);
}
if (!templateId) {
templateId = `${templateName}-tpl`;
templateId = templateName + '-tpl';
}
if (isFirst) {

View File

@@ -125,7 +125,7 @@
getLabel: function(id) {
// Extract the field label, remove the asterisk (if it appears) and any extra whitespace
return $(`label[for=${id}] > span.label-text`).text().split('*')[0].trim();
return $('label[for=' + id + '] > span.label-text').text().split('*')[0].trim();
},
getMessage: function($el, tests) {
@@ -140,8 +140,8 @@
_.each(tests, function(value, key) {
if (!value) {
label = _fn.validate.getLabel($el.attr('id'));
customMsg = $el.data(`errormsg-${key}`) || false;
liveValidationMsg = $(`#${$el.attr('id')}-validation-error-msg`).text() || false;
customMsg = $el.data('errormsg-' + key) || false;
liveValidationMsg = $('#' + $el.attr('id') + '-validation-error-msg').text() || false;
// If the field has a custom error msg attached, use it
if (customMsg) {

View File

@@ -7,9 +7,9 @@
var selector;
requestToken = requestToken || $(element).data('request-token');
if (requestToken) {
selector = `.${blockClass}[data-request-token="${requestToken}"]`;
selector = '.' + blockClass + '[data-request-token="' + requestToken + '"]';
} else {
selector = `.${blockClass}`;
selector = '.' + blockClass;
}
// After an element is initialized, a class is added to it. To avoid repeat initialization, no
// elements with that class should be selected.
@@ -26,11 +26,11 @@
initFnName = $element.data('init');
if (runtime && version && initFnName) {
return new window[runtime][`v${version}`]();
return new window[runtime]['v' + version]();
} else {
if (runtime || version || initFnName) {
console.log(
`Block ${$element.outerHTML} is missing data-runtime, data-runtime-version or data-init, `
'Block ' + $element.outerHTML + ' is missing data-runtime, data-runtime-version or data-init, '
+ 'and can\'t be initialized'
);
} // else this XBlock doesn't have a JS init function.
@@ -114,7 +114,7 @@
*/
initializeAside: function(element) {
var blockUsageId = $(element).data('block-id');
var blockElement = $(element).siblings(`[data-usage-id="${blockUsageId}"]`)[0];
var blockElement = $(element).siblings('[data-usage-id="' + blockUsageId + '"]')[0];
return constructBlock(element, [blockElement, initArgs(element)]);
},

View File

@@ -17,7 +17,7 @@
});
}
prev_id = `#${this.id}_preview`;
prev_id = '#' + this.id + '_preview';
preview_div = $(prev_id);
// find the closest parent problems-wrapper and use that url

View File

@@ -36,7 +36,7 @@
HtmlUtils.HTML('ERROR: Image "'), state.config.baseImage, HtmlUtils.HTML('" was not found!'),
HtmlUtils.HTML('</span>')
);
console.log(`ERROR: Image "${state.config.baseImage}" was not found!`);
console.log('ERROR: Image "' + state.config.baseImage + '" was not found!');
HtmlUtils.setHtml($baseImageElContainer, errorMsg);
$baseImageElContainer.appendTo(state.containerEl);
});

View File

@@ -206,11 +206,11 @@
function attrIsString(obj, attr) {
if (obj.hasOwnProperty(attr) === false) {
console.log(`ERROR: Attribute "obj.${attr}" is not present.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not present.');
return false;
} else if (typeof obj[attr] !== 'string') {
console.log(`ERROR: Attribute "obj.${attr}" is not a string.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not a string.');
return false;
}
@@ -222,7 +222,7 @@
var tempInt;
if (obj.hasOwnProperty(attr) === false) {
console.log(`ERROR: Attribute "obj.${attr}" is not present.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not present.');
return false;
}
@@ -230,7 +230,7 @@
tempInt = parseInt(obj[attr], 10);
if (isFinite(tempInt) === false) {
console.log(`ERROR: Attribute "obj.${attr}" is not an integer.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not an integer.');
return false;
}
@@ -243,7 +243,7 @@
function attrIsBoolean(obj, attr, defaultVal) {
if (obj.hasOwnProperty(attr) === false) {
if (defaultVal === undefined) {
console.log(`ERROR: Attribute "obj.${attr}" is not present.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not present.');
return false;
} else {
@@ -260,7 +260,7 @@
} else if ((obj[attr] === 'true') || (obj[attr] === true)) {
obj[attr] = true;
} else {
console.log(`ERROR: Attribute "obj.${attr}" is not a boolean.`);
console.log('ERROR: Attribute "obj.' + attr + '" is not a boolean.');
return false;
}

View File

@@ -7,7 +7,7 @@
'<div style=" clear: both; width: 665px; margin-left: auto; margin-right: auto; " ></div>'
);
$(`#inputtype_${state.problemId}`).before(HtmlUtils.HTML(state.containerEl).toString());
$('#inputtype_' + state.problemId).before(HtmlUtils.HTML(state.containerEl).toString());
}
}); // End-of: define([], function () {
}(RequireJS.requirejs, RequireJS.require, RequireJS.define)); // End-of: (function (requirejs, require, define) {

View File

@@ -62,10 +62,10 @@
}
try {
config = JSON.parse($(`#drag_and_drop_json_${problemId}`).html());
config = JSON.parse($('#drag_and_drop_json_' + problemId).html());
} catch (err) {
console.log('ERROR: Could not parse the JSON configuration options.');
console.log(`Error message: "${err.message}".`);
console.log('Error message: "' + err.message + '".');
return;
}

View File

@@ -52,7 +52,7 @@
// We scroll by changing the 'margin-left' CSS property smoothly.
state.sliderEl.animate({
'margin-left': `${showElLeftMargin}px`
'margin-left': showElLeftMargin + 'px'
}, 100, function() {
updateArrowOpacity();
});
@@ -123,7 +123,7 @@
// We scroll by changing the 'margin-left' CSS property smoothly.
state.sliderEl.animate({
'margin-left': `${showElLeftMargin}px`
'margin-left': showElLeftMargin + 'px'
}, 100, function() {
updateArrowOpacity();
});

View File

@@ -41,7 +41,7 @@
function getUniqueId() {
this.uniqueId += 1;
return `${this.salt}_${this.uniqueId.toFixed(0)}`;
return this.salt + '_' + this.uniqueId.toFixed(0);
}
function makeSalt() {

View File

@@ -50,7 +50,7 @@
}(0));
}
$(`#input_${state.problemId}`).val(JSON.stringify(draggables));
$('#input_' + state.problemId).val(JSON.stringify(draggables));
}
function addTargetRecursively(tempObj, draggable, target) {
@@ -69,7 +69,7 @@
function check(state) {
var inputElVal;
inputElVal = $(`#input_${state.problemId}`).val();
inputElVal = $('#input_' + state.problemId).val();
if (inputElVal.length === 0) {
return false;
@@ -189,7 +189,7 @@
if (reportError !== false) {
console.log(
'ERROR: In answer there exists a '
+ `draggable ID "${draggableId}". No `
+ 'draggable ID "' + draggableId + '". No '
+ 'draggable with this ID could be found.'
);
}
@@ -201,7 +201,7 @@
if (reportError !== false) {
console.log(
'ERROR: In answer there exists a target '
+ `ID "${targetId}". No target with this `
+ 'ID "' + targetId + '". No target with this '
+ 'ID could be found.'
);
}
@@ -227,7 +227,7 @@
if ((draggable = getById(state, 'draggables', draggableId)) === null) {
console.log(
'ERROR: In answer there exists a '
+ `draggable ID "${draggableId}". No `
+ 'draggable ID "' + draggableId + '". No '
+ 'draggable with this ID could be found.'
);

View File

@@ -32,7 +32,7 @@
}
select.appendChild(option);
}
feedback.innerText = `The currently selected answer is '${state.selectedChoice}'.`;
feedback.innerText = "The currently selected answer is '" + state.selectedChoice + "'.";
}
function getGrade() {
@@ -74,8 +74,8 @@
select.addEventListener('change', function() {
state.selectedChoice = select.options[select.selectedIndex].text;
feedback.innerText = `You have selected '${state.selectedChoice
}'. Click Submit to grade your answer.`;
feedback.innerText = "You have selected '" + state.selectedChoice
+ "'. Click Submit to grade your answer.";
});
return {

View File

@@ -64,7 +64,7 @@ describe('Formula Equation Preview', function() {
this.oldDGEBI = document.getElementById;
document.getElementById = function(id) {
return $(`*#${id}`)[0] || null;
return $('*#' + id)[0] || null;
};
// Catch the AJAX requests
@@ -195,7 +195,7 @@ describe('Formula Equation Preview', function() {
var $input = $('#input_THE_ID');
var value;
function inputAnother(iter) {
value = `math input ${iter}`;
value = 'math input ' + iter;
$input.val(value).trigger('input');
}

View File

@@ -20,17 +20,17 @@ function escapeSelector(id) {
return '\uFFFD';
}
// Control characters and (dependent upon position) numbers get escaped as code points
return `${ch.slice(0, -1)}\\${ch.charCodeAt(ch.length - 1).toString(16)} `;
return ch.slice(0, -1) + '\\' + ch.charCodeAt(ch.length - 1).toString(16) + ' ';
}
// Other potentially-special ASCII characters get backslash-escaped
return `\\${ch}`;
return '\\' + ch;
}
if (window.CSS && window.CSS.escape) {
return window.CSS.escape(id);
} else {
// ensure string and then run the replacements
return (`${id}`).replace(rcssescape, fcssescape);
return (id + '').replace(rcssescape, fcssescape);
}
}
@@ -49,7 +49,7 @@ formulaEquationPreview.enable = function() {
function setupInput() {
var $this = $(this); // cache the jQuery object
var $preview = $(`#${escapeSelector(this.id)}_preview`);
var $preview = $('#' + escapeSelector(this.id) + '_preview');
var inputData = {
// These are the mutable values
@@ -187,7 +187,7 @@ formulaEquationPreview.enable = function() {
console.log('[FormulaEquationInput] Oops no mathjax for ', latex);
// Fall back to modifying the actual element.
var textNode = previewElement.childNodes[0];
textNode.data = `\\(${latex}\\)`;
textNode.data = '\\(' + latex + '\\)';
MathJax.Hub.Queue(['Typeset', MathJax.Hub, previewElement]);
}
});
@@ -198,7 +198,7 @@ formulaEquationPreview.enable = function() {
if (response.error) {
inputData.$img.css('visibility', 'visible');
inputData.errorWaitTimeout = window.setTimeout(function() {
display(`\\text{${response.error}}`);
display('\\text{' + response.error + '}');
inputData.$img.css('visibility', 'hidden');
}, formulaEquationPreview.errorDelay);
} else {

View File

@@ -249,7 +249,7 @@ var Channel = (function() {
exists = hasWin(s_boundChans[origin][scope]);
}
}
if (exists) { throw `A channel is already bound to the same window which overlaps with origin '${origin}' and has scope '${scope}'`; }
if (exists) { throw "A channel is already bound to the same window which overlaps with origin '" + origin + "' and has scope '" + scope + "'"; }
if (typeof s_boundChans[origin] !== 'object') { s_boundChans[origin] = { }; }
if (typeof s_boundChans[origin][scope] !== 'object') { s_boundChans[origin][scope] = []; }
@@ -388,7 +388,7 @@ var Channel = (function() {
if (cfg.debugOutput && window.console && window.console.log) {
// try to stringify, if it doesn't work we'll let javascript's built in toString do its magic
try { if (typeof m !== 'string') { m = JSON.stringify(m); } } catch (e) { }
console.log(`[${chanId}] ${m}`);
console.log('[' + chanId + '] ' + m);
}
};
@@ -455,11 +455,11 @@ var Channel = (function() {
origin: origin,
invoke: function(cbName, v) {
// verify in table
if (!inTbl[id]) { throw `attempting to invoke a callback of a nonexistent transaction: ${id}`; }
if (!inTbl[id]) { throw 'attempting to invoke a callback of a nonexistent transaction: ' + id; }
// verify that the callback name is valid
var valid = false;
for (var i = 0; i < callbacks.length; i++) { if (cbName === callbacks[i]) { valid = true; break; } }
if (!valid) { throw `request supports no such callback '${cbName}'`; }
if (!valid) { throw "request supports no such callback '" + cbName + "'"; }
// send callback invocation
postMessage({id: id, callback: cbName, params: v});
@@ -467,7 +467,7 @@ var Channel = (function() {
error: function(error, message) {
completed = true;
// verify in table
if (!inTbl[id]) { throw `error called for nonexistent message: ${id}`; }
if (!inTbl[id]) { throw 'error called for nonexistent message: ' + id; }
// remove transaction from table
delete inTbl[id];
@@ -478,7 +478,7 @@ var Channel = (function() {
complete: function(v) {
completed = true;
// verify in table
if (!inTbl[id]) { throw `complete called for nonexistent message: ${id}`; }
if (!inTbl[id]) { throw 'complete called for nonexistent message: ' + id; }
// remove transaction from table
delete inTbl[id];
// send complete
@@ -500,7 +500,7 @@ var Channel = (function() {
return window.setTimeout(function() {
if (outTbl[transId]) {
// XXX: what if client code raises an exception here?
var msg = `timeout (${timeout}ms) exceeded on method '${method}'`;
var msg = 'timeout (' + timeout + "ms) exceeded on method '" + method + "'";
(1, outTbl[transId].error)('timeout_error', msg);
delete outTbl[transId];
delete s_transIds[transId];
@@ -518,7 +518,7 @@ var Channel = (function() {
try {
cfg.gotMessageObserver(origin, m);
} catch (e) {
debug(`gotMessageObserver() raised an exception: ${e.toString()}`);
debug('gotMessageObserver() raised an exception: ' + e.toString());
}
}
@@ -590,14 +590,14 @@ var Channel = (function() {
}
} else if (m.id && m.callback) {
if (!outTbl[m.id] || !outTbl[m.id].callbacks || !outTbl[m.id].callbacks[m.callback]) {
debug(`ignoring invalid callback, id:${m.id} (${m.callback})`);
debug('ignoring invalid callback, id:' + m.id + ' (' + m.callback + ')');
} else {
// XXX: what if client code raises an exception here?
outTbl[m.id].callbacks[m.callback](m.params);
}
} else if (m.id) {
if (!outTbl[m.id]) {
debug(`ignoring invalid response: ${m.id}`);
debug('ignoring invalid response: ' + m.id);
} else {
// XXX: what if client code raises an exception here?
if (m.error) {
@@ -636,7 +636,7 @@ var Channel = (function() {
// delay posting if we're not ready yet.
var verb = (ready ? 'post ' : 'queue ');
debug(`${verb} message: ${JSON.stringify(msg)}`);
debug(verb + ' message: ' + JSON.stringify(msg));
if (!force && !ready) {
pendingQueue.push(msg);
} else {
@@ -644,7 +644,7 @@ var Channel = (function() {
try {
cfg.postMessageObserver(cfg.origin, msg);
} catch (e) {
debug(`postMessageObserver() raised an exception: ${e.toString()}`);
debug('postMessageObserver() raised an exception: ' + e.toString());
}
}
@@ -683,7 +683,7 @@ var Channel = (function() {
// tries to unbind a bound message handler. returns false if not possible
unbind: function(method) {
if (regTbl[method]) {
if (!(delete regTbl[method])) { throw (`can't delete method: ${method}`); }
if (!(delete regTbl[method])) { throw ("can't delete method: " + method); }
return true;
}
return false;
@@ -692,7 +692,7 @@ var Channel = (function() {
if (!method || typeof method !== 'string') { throw "'method' argument to bind must be string"; }
if (!cb || typeof cb !== 'function') { throw 'callback missing from bind params'; }
if (regTbl[method]) { throw `method '${method}' is already bound!`; }
if (regTbl[method]) { throw "method '" + method + "' is already bound!"; }
regTbl[method] = cb;
return this;
},

View File

@@ -24,7 +24,7 @@ window.SymbolicMathjaxPreprocessor = function() {
// a zero width space--this is an invisible character that no one would
// use, that gets passed through MathJax and to the server
var c = '\u200b';
eqn = eqn.replace(/__(?:([^\{])|\{([^\}]+)\})/g, `^{${c}$1$2}`);
eqn = eqn.replace(/__(?:([^\{])|\{([^\}]+)\})/g, '^{' + c + '$1$2}');
// NOTE: MathJax supports '\class{name}{mathcode}' but not for asciimath
// input, which is too bad. This would be preferable to this char tag

View File

@@ -184,7 +184,7 @@
spyOn(jQuery, 'ajax');
window.onunload();
expect(jQuery.ajax).toHaveBeenCalledWith({
url: `${this.prefix}/event`,
url: this.prefix + '/event',
type: 'GET',
data: {
event_type: 'page_close',

View File

@@ -1,15 +1,15 @@
describe('interpolate_ntext', function() {
it('replaces placeholder values', function() {
expect(interpolate_ntext('contains {count} student', 'contains {count} students', 1, {count: 1}))
.toBe('contains 1 student');
expect(interpolate_ntext('contains {count} student', 'contains {count} students', 5, {count: 2}))
.toBe('contains 2 students');
expect(interpolate_ntext('contains {count} student', 'contains {count} students', 1, {count: 1})).
toBe('contains 1 student');
expect(interpolate_ntext('contains {count} student', 'contains {count} students', 5, {count: 2})).
toBe('contains 2 students');
});
});
describe('interpolate_text', function() {
it('replaces placeholder values', function() {
expect(interpolate_text('contains {adjective} students', {adjective: 'awesome'}))
.toBe('contains awesome students');
expect(interpolate_text('contains {adjective} students', {adjective: 'awesome'})).
toBe('contains awesome students');
});
});

View File

@@ -99,7 +99,7 @@ var trapShiftTabFocus = function($last, closeButtonId) {
var bindReturnFocusListener = function($previouslyFocusedElement, closeButtonId, modalId, mainPageId) {
// Ensures that on modal close, focus is returned to the element
// that had focus before the modal was opened.
$(`#lean_overlay, ${closeButtonId}`).click(function() {
$('#lean_overlay, ' + closeButtonId).click(function() {
$(mainPageId).attr('aria-hidden', 'false');
$(modalId).attr('aria-hidden', 'true');
$previouslyFocusedElement.focus();
@@ -151,7 +151,7 @@ var accessible_modal = function(trigger, closeButtonId, modalId, mainPageId) {
// see http://accessibility.oit.ncsu.edu/blog/2013/09/13/the-incredible-accessible-modal-dialog/
// for more information on managing modals
//
var initialFocus;
var initialFocus
$(trigger).click(function() {
$focusedElementBeforeModal = $(trigger);
@@ -206,7 +206,7 @@ $(function() {
function SRAlert() {
// This initialization sometimes gets done twice, so take to only create a single reader-feedback div.
var readerFeedbackID = 'reader-feedback',
$readerFeedbackSelector = $(`#${readerFeedbackID}`);
$readerFeedbackSelector = $('#' + readerFeedbackID);
if ($readerFeedbackSelector.length === 0) {
edx.HtmlUtils.append(
@@ -217,7 +217,7 @@ $(function() {
)
);
}
this.el = $(`#${readerFeedbackID}`);
this.el = $('#' + readerFeedbackID);
}
SRAlert.prototype.clear = function() {

View File

@@ -11,6 +11,6 @@
// Internet Explorer does not have built-in property 'window.location.origin',
// we need to create one here as some vendor code such as TinyMCE uses this.
if (!window.location.origin) {
window.location.origin = `${window.location.protocol}//${window.location.hostname
}${window.location.port ? `:${window.location.port}` : ''}`;
window.location.origin = window.location.protocol + '//' + window.location.hostname
+ (window.location.port ? ':' + window.location.port : '');
}

View File

@@ -4,7 +4,7 @@
var TooltipManager = function(element) {
this.element = $(element);
// If tooltip container already exist, use it.
this.tooltip = $(`div.${this.className.split(/\s+/).join('.')}`);
this.tooltip = $('div.' + this.className.split(/\s+/).join('.'));
// Otherwise, create new one.
if (!this.tooltip.length) {
this.tooltip = $('<div />', {

View File

@@ -13,7 +13,7 @@ window.isExternal = function(url) {
if (typeof match[2] === 'string'
&& match[2].length > 0
// this regex removes the port number if it patches the current location's protocol
&& match[2].replace(new RegExp(`:(${{'http:': 80, 'https:': 443}[location.protocol]})?$`), '') !== location.host) { return true; }
&& match[2].replace(new RegExp(':(' + {'http:': 80, 'https:': 443}[location.protocol] + ')?$'), '') !== location.host) { return true; }
return false;
};
@@ -34,6 +34,6 @@ window.rewriteStaticLinks = function(content, from, to) {
// handle http and https
// escape all regex interpretable chars
fromRe = from.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var regex = new RegExp(`(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}([-a-zA-Z0-9@:%_\+.~#?&//=]*))?${fromRe}`, 'g');
var regex = new RegExp('(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}([-a-zA-Z0-9@:%_\+.~#?&//=]*))?' + fromRe, 'g');
return content.replace(regex, replacer);
};

View File

@@ -6,7 +6,6 @@
'use strict';
var path = require('path');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var options = {
@@ -14,7 +13,7 @@ var options = {
useRequireJs: false,
normalizePathsForCoverageFunc: function(appRoot, pattern) {
return path.join(appRoot, `/common/static/${pattern}`);
return path.join(appRoot, '/common/static/' + pattern);
},
// Avoid adding files to this list. Use RequireJS.

View File

@@ -6,7 +6,6 @@
'use strict';
var path = require('path');
var configModule = require(path.join(__dirname, '../../common/static/common/js/karma.common.conf.js'));
var options = {
@@ -14,7 +13,7 @@ var options = {
includeCommonFiles: true,
normalizePathsForCoverageFunc: function(appRoot, pattern) {
return path.join(appRoot, `/common/static/${pattern}`);
return path.join(appRoot, '/common/static/' + pattern);
},
libraryFiles: [