Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to follow the brace-style ESLint rule #1312

Closed
wants to merge 13 commits into from
90 changes: 30 additions & 60 deletions root/static/scripts/common/MB/Control/Autocomplete.js
Expand Up @@ -618,23 +618,19 @@ MB.Control.autocomplete_formatters = {

var comment = [];

if (item.primaryAlias && item.primaryAlias != item.name)
{
if (item.primaryAlias && item.primaryAlias != item.name) {
comment.push(item.primaryAlias);
}

if (item.sort_name && !isLatin(item.name) && item.sort_name != item.name && !item.primaryAlias)
{
if (item.sort_name && !isLatin(item.name) && item.sort_name != item.name && !item.primaryAlias) {
comment.push(item.sort_name);
}

if (item.comment)
{
if (item.comment) {
comment.push(item.comment);
}

if (comment.length)
{
if (comment.length) {
a.append(' <span class="autocomplete-comment">' +
_.escape(bracketed(commaOnlyList(comment))) + '</span>');
}
Expand All @@ -645,48 +641,41 @@ MB.Control.autocomplete_formatters = {
"recording": function (ul, item) {
var a = $("<a>").text(item.name);

if (item.length)
{
if (item.length) {
a.prepend('<span class="autocomplete-length">' +
formatTrackLength(item.length) + '</span>');
}

if (item.comment)
{
if (item.comment) {
a.append('<span class="autocomplete-comment">' +
_.escape(bracketed(item.comment)) + '</span>');
}

if (item.video)
{
if (item.video) {
const title = _.escape(l('This recording is a video'));
a.prepend($(`<span class="video" title="${title}"></span>`));
}

a.append('<br /><span class="autocomplete-comment">by ' +
_.escape(item.artist) + '</span>');

if (item.appearsOn && item.appearsOn.hits > 0)
{
if (item.appearsOn && item.appearsOn.hits > 0) {
var rgs = [];
$.each(item.appearsOn.results, function (idx, item) {
rgs.push(item.name);
});

if (item.appearsOn.hits > item.appearsOn.results.length)
{
if (item.appearsOn.hits > item.appearsOn.results.length) {
rgs.push('...');
}

a.append('<br /><span class="autocomplete-appears">' + _.escape(addColon(l('appears on'))) + ' ' +
_.escape(commaOnlyList(rgs)) + '</span>');
}
else if (item.appearsOn && item.appearsOn.hits === 0) {
} else if (item.appearsOn && item.appearsOn.hits === 0) {
a.append('<br /><span class="autocomplete-appears">' + _.escape(l('standalone recording')) + '</span>');
}

if (item.isrcs && item.isrcs.length)
{
if (item.isrcs && item.isrcs.length) {
a.append('<br /><span class="autocomplete-isrcs">' + _.escape(addColon(l('ISRCs'))) + ' ' +
_.escape(commaOnlyList(item.isrcs.map(isrc => isrc.isrc))) + '</span>');
}
Expand Down Expand Up @@ -749,14 +738,12 @@ MB.Control.autocomplete_formatters = {
"release-group": function (ul, item) {
var a = $("<a>").text(item.name);

if (item.firstReleaseDate)
{
if (item.firstReleaseDate) {
a.append('<span class="autocomplete-comment">' +
bracketed(item.firstReleaseDate) + '</span>');
}

if (item.comment)
{
if (item.comment) {
a.append('<span class="autocomplete-comment">' +
_.escape(bracketed(item.comment)) + '</span>');
}
Expand Down Expand Up @@ -796,33 +783,27 @@ MB.Control.autocomplete_formatters = {
'</span>');
}

if (item.primaryAlias && item.primaryAlias != item.name)
{
if (item.primaryAlias && item.primaryAlias != item.name) {
comment.push(item.primaryAlias);
}

if (item.comment)
{
if (item.comment) {
comment.push(item.comment);
}

if (comment.length)
{
if (comment.length) {
a.append(' <span class="autocomplete-comment">' +
_.escape(bracketed(commaOnlyList(comment))) + '</span>');
}

if (item.typeName)
{
if (item.typeName) {
a.append('<br /><span class="autocomplete-comment">' + _.escape(addColon(l('Type')) + ' ' + lp_attributes(item.typeName, 'work_type')) + '</span>');
}

var artistRenderer = function (prefix, artists) {
if (artists && artists.hits > 0)
{
if (artists && artists.hits > 0) {
var toRender = artists.results;
if (artists.hits > toRender.length)
{
if (artists.hits > toRender.length) {
toRender.push('...');
}

Expand All @@ -842,8 +823,7 @@ MB.Control.autocomplete_formatters = {
"area": function (ul, item) {
var a = $("<a>").text(item.name);

if (item.comment)
{
if (item.comment) {
a.append('<span class="autocomplete-comment">' +
_.escape(bracketed(item.comment)) + '</span>');
}
Expand All @@ -868,18 +848,15 @@ MB.Control.autocomplete_formatters = {

var comment = [];

if (item.primaryAlias && item.primaryAlias != item.name)
{
if (item.primaryAlias && item.primaryAlias != item.name) {
comment.push(item.primaryAlias);
}

if (item.comment)
{
if (item.comment) {
comment.push(item.comment);
}

if (comment.length)
{
if (comment.length) {
a.append(' <span class="autocomplete-comment">' +
_.escape(bracketed(commaOnlyList(comment))) + '</span>');
}
Expand Down Expand Up @@ -920,8 +897,7 @@ MB.Control.autocomplete_formatters = {
comment.push(lp_attributes(item.typeName, 'instrument_type'));
}

if (comment.length)
{
if (comment.length) {
a.append(' <span class="autocomplete-comment">' +
_.escape(bracketed(commaOnlyList(comment))) + '</span>');
}
Expand All @@ -942,18 +918,15 @@ MB.Control.autocomplete_formatters = {
var a = $("<a>").text(item.name);
var comment = [];

if (item.primaryAlias && item.primaryAlias != item.name)
{
if (item.primaryAlias && item.primaryAlias != item.name) {
comment.push(item.primaryAlias);
}

if (item.comment)
{
if (item.comment) {
comment.push(item.comment);
}

if (comment.length)
{
if (comment.length) {
a.append(' <span class="autocomplete-comment">' +
_.escape(bracketed(commaOnlyList(comment))) + '</span>');
}
Expand All @@ -962,17 +935,14 @@ MB.Control.autocomplete_formatters = {
a.append(' <span class="autocomplete-comment">' + _.escape(bracketed(lp_attributes(item.typeName, 'event_type'))) + '</span>');
}

if (item.begin_date || item.time)
{
if (item.begin_date || item.time) {
a.append('<br /><span class="autocomplete-comment">' + (item.begin_date ? (formatDatePeriod(item) + ' ') : '') + (item.time ? item.time : '') + '</span>');
}

var entityRenderer = function (prefix, related_entities) {
if (related_entities && related_entities.hits > 0)
{
if (related_entities && related_entities.hits > 0) {
var toRender = related_entities.results;
if (related_entities.hits > toRender.length)
{
if (related_entities.hits > toRender.length) {
toRender.push('...');
}

Expand Down
9 changes: 3 additions & 6 deletions root/static/scripts/common/ratings.js
Expand Up @@ -27,8 +27,7 @@ $(document).on("click", "span.star-rating a", function () {
currentRatingSpan.removeClass('current-rating');
currentRatingSpan.addClass('current-user-rating');
rating = data.rating;
}
else {
} else {
// Removed user rating, use the average rating instead
currentRatingSpan.removeClass('current-user-rating');
currentRatingSpan.addClass('current-rating');
Expand All @@ -38,8 +37,7 @@ $(document).on("click", "span.star-rating a", function () {
// Update the width if we have some ratings
currentRatingSpan.css('width', rating + '%');
currentRatingSpan.text(5 * rating / 100);
}
else {
} else {
// No ratings, remove it
currentRatingSpan.remove();
}
Expand All @@ -53,8 +51,7 @@ $(document).on("click", "span.star-rating a", function () {
? 0
: originalRating;
var oldRatingMatch = this.href.match(/rating=(\d+)/);
if (oldRatingMatch[1] != newRating)
{
if (oldRatingMatch[1] != newRating) {
this.href = this.href.replace(
oldRatingMatch[0],
'rating=' + newRating,
Expand Down
3 changes: 1 addition & 2 deletions root/static/scripts/common/tagger.js
Expand Up @@ -8,8 +8,7 @@ $(function () {
iframe.src = this.href;
iframe.style.display = "none";
$('body').append(iframe);
}
else {
} else {
var tagger = new Image();
tagger.src = this.href;
}
Expand Down
25 changes: 15 additions & 10 deletions root/static/scripts/edit/MB/Control/Bubble.js
Expand Up @@ -19,7 +19,9 @@ class BubbleBase {
* The default observable equality comparer returns false if the values
* aren't primitive, even if the values are equal.
*/
targetEqualityComparer(a, b) { return a === b }
targetEqualityComparer(a, b) {
return a === b;
}

constructor(group) {
this.group = group || 0;
Expand Down Expand Up @@ -72,7 +74,9 @@ class BubbleBase {
}

// Action upon pressing enter in an input. Defaults to hide.
submit() { this.hide() }
submit() {
this.hide();
}

toggle(control) {
if (this.visible.peek()) {
Expand All @@ -96,8 +100,7 @@ class BubbleBase {

if ($(this.control).parents("html").length === 0) {
this.hide(false);
}
else {
} else {
this.show(this.control, !!stealFocus, true /* isRedraw */);
}
}
Expand Down Expand Up @@ -198,14 +201,15 @@ ko.bindingHandlers.controlsBubble = {
}

ko.computed({
read: function () { return !!bubble.canBeShown(viewModel) },
read: function () {
return !!bubble.canBeShown(viewModel);
},
disposeWhenNodeIsRemoved: element
})
.subscribe(function (show) {
if (show !== bubble.visible()) {
bubble.toggle(element);
}
else if (show && !bubble.targetIs(viewModel)) {
} else if (show && !bubble.targetIs(viewModel)) {
bubble.show(element);
}
});
Expand All @@ -229,7 +233,9 @@ ko.bindingHandlers.affectsBubble = {
}

var observer = new MutationObserver(_.throttle(function () {
_.delay(function () { valueAccessor().redraw() }, 100);
_.delay(function () {
valueAccessor().redraw();
}, 100);
}, 100));

observer.observe(element, { childList: true, subtree: true });
Expand Down Expand Up @@ -333,8 +339,7 @@ function bubbleKeydownHandler(event) {

if (pressedEsc) {
bubbleDoc.hide();
}
else if (pressedEnter) {
} else if (pressedEnter) {
bubbleDoc.submit();
}
}
Expand Down