Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Conform to ESLint code styles (#4435)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephaniehobson authored and Schalk Neethling committed Oct 20, 2017
1 parent b326c37 commit 46e328b
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 73 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -59,6 +59,7 @@ module.exports = {
"interpolate": true,
"mdn": true,
"Mozilla": true,
"waffle": true
"waffle": true,
"Prism": true
}
};
7 changes: 3 additions & 4 deletions kuma/static/js/analytics.js
Expand Up @@ -119,9 +119,9 @@

trackLink: function(event, url, data) {
// ctrl or cmd click or context menu
var newTab = (event.metaKey || event.ctrlKey || event.type == 'contextmenu');
var newTab = (event.metaKey || event.ctrlKey || event.type === 'contextmenu');
// is a same page anchor
var isAnchor = (url.indexOf("#") == 0);
var isAnchor = (url.indexOf('#') === 0);
// isBlank
var isBlank = $(event.target).attr('target') === '_blank';

Expand Down Expand Up @@ -164,8 +164,7 @@
status: request.status,
statusText: request.statusText,
crossDomain: settings.crossDomain,
dataType: settings.dataType
})
dataType: settings.dataType })
);
});
},
Expand Down
116 changes: 59 additions & 57 deletions kuma/static/js/auth.js
Expand Up @@ -54,71 +54,73 @@
Show notifications about account association status as part of the
registration process.
*/
if(win.mdn.features.localStorage) (function() {
try {
var $browserRegister = $('#browser_register');
var matchKey = 'account-match-for';
var matchCurrent = $browserRegister.data(matchKey);
var matchStored = localStorage.getItem(matchKey);

// The user is on the registration page and has been notified that
// there is an MDN profile with a matching email address.
if(matchCurrent && !matchStored) {
localStorage.setItem(matchKey, matchCurrent);
if(win.mdn.features.localStorage) {
(function() {
try {
var $browserRegister = $('#browser_register');
var matchKey = 'account-match-for';
var matchCurrent = $browserRegister.data(matchKey);
var matchStored = localStorage.getItem(matchKey);

// The user is on the registration page and has been notified that
// there is an MDN profile with a matching email address.
if(matchCurrent && !matchStored) {
localStorage.setItem(matchKey, matchCurrent);
}

// After seeing the notice, the user tried to sign in with a second
// social account, but was again directed to the registration page.
// This will happen if the second social account was also not
// tied to an MDN profile.
else if(!matchCurrent && matchStored && $browserRegister.length) {
localStorage.removeItem(matchKey);
}

// After seeing the notice, the user took an action that resulted in
// them landing on another page. Either the user abandoned the
// registration process or the user tried to sign in with a second
// social account and was successful. In either case, the
// localStorage item should be immediately removed.
else if(!matchCurrent && matchStored) {
$doc.on('mdn:login', function() {
mdn.Notifier.growl('You can now use ' + matchStored + ' to sign in to this MDN profile.', { duration: 0, closable: true }).success();
});
localStorage.removeItem(matchKey);
}
}

// After seeing the notice, the user tried to sign in with a second
// social account, but was again directed to the registration page.
// This will happen if the second social account was also not
// tied to an MDN profile.
else if(!matchCurrent && matchStored && $browserRegister.length) {
localStorage.removeItem(matchKey);
}

// After seeing the notice, the user took an action that resulted in
// them landing on another page. Either the user abandoned the
// registration process or the user tried to sign in with a second
// social account and was successful. In either case, the
// localStorage item should be immediately removed.
else if(!matchCurrent && matchStored) {
$doc.on('mdn:login', function(service) {
mdn.Notifier.growl('You can now use ' + matchStored + ' to sign in to this MDN profile.', { duration: 0, closable: true }).success();
});
localStorage.removeItem(matchKey);
catch (e) {
// Browser probably doesn't support localStorage
}

}
catch (e) {
// Browser probably doesn't support localStorage
}
})();
})();
}

/*
Fire off events when the user logs in and logs out.
*/
if(win.mdn.features.localStorage) (function() {
var serviceKey = 'login-service';
var serviceStored = localStorage.getItem(serviceKey);
var serviceCurrent = $(doc.body).data(serviceKey);
if(win.mdn.features.localStorage) {
(function() {
var serviceKey = 'login-service';
var serviceStored = localStorage.getItem(serviceKey);
var serviceCurrent = $(doc.body).data(serviceKey);

try {
// User just logged in
if(serviceCurrent && !serviceStored) {
localStorage.setItem(serviceKey, serviceCurrent);
$doc.trigger('mdn:login', [ serviceCurrent ]);
}

// User just logged out
else if(!serviceCurrent && serviceStored) {
localStorage.removeItem(serviceKey);
$doc.trigger('mdn:logout', [ serviceStored ]);
}

try {

// User just logged in
if(serviceCurrent && !serviceStored) {
localStorage.setItem(serviceKey, serviceCurrent);
$doc.trigger('mdn:login', [ serviceCurrent ]);
}

// User just logged out
else if(!serviceCurrent && serviceStored) {
localStorage.removeItem(serviceKey);
$doc.trigger('mdn:logout', [ serviceStored ]);
catch (e) {
// Browser probably doesn't support localStorage
}

}
catch (e) {
// Browser probably doesn't support localStorage
}
})();
})();
}

})(window, document, jQuery);
2 changes: 1 addition & 1 deletion kuma/static/js/framebuster.js
@@ -1,4 +1,4 @@
// Quick and dirty way to bust out of a frame / iframe.
if (top.location != self.location) {
if (top.location !== self.location) {
top.location = self.location.href;
}
2 changes: 1 addition & 1 deletion kuma/static/js/newsletter.js
@@ -1,4 +1,4 @@
;(function(doc) {
(function(doc) {
'use strict';

// !! this file assumes only one signup form per page !!
Expand Down
6 changes: 3 additions & 3 deletions kuma/static/js/search.js
Expand Up @@ -5,9 +5,9 @@
Auto-submit the filters form on the search page when a checkbox is changed.
*/
$('.search-results-filters').on('change', 'input', function() {
if (this.value != "none") {
// De-select the All Topics checkbox when another filter is selected
$("#no_filter").attr('checked', false);
if (this.value !== 'none') {
// De-select the All Topics checkbox when another filter is selected
$('#no_filter').attr('checked', false);
}
$('#search-form').submit();
$(this).parents('fieldset').attr('disabled', 'disabled');
Expand Down
4 changes: 3 additions & 1 deletion kuma/static/js/syntax-prism.js
Expand Up @@ -20,7 +20,9 @@

// If the PRE has a child <code> tag, it's likely a copy/pasted, already-prism'd code samples.
// Bail to avoid an error
if($pre.find('code').length) return;
if($pre.find('code').length) {
return;
}

// Parse classname to look for brush
var brushSearch = klass.match(/brush: ?(.*)/);
Expand Down
4 changes: 2 additions & 2 deletions kuma/static/js/wiki-admin.js
@@ -1,6 +1,6 @@
// See also: http://stackoverflow.com/questions/6086651/minimize-the-list-filter-in-django-admin
(function($){
"use strict";
'use strict';

var ListFilterCollapsePrototype = {
bindToggle: function(){
Expand All @@ -25,7 +25,7 @@

$(document).ready(function(){
$('#changelist-filter').each(function(){
var collapser = new ListFilterCollapse(this);
new ListFilterCollapse(this);
});
});
})(window.django.jQuery);
8 changes: 5 additions & 3 deletions kuma/static/js/wiki-tags-edit.js
@@ -1,5 +1,5 @@
(function($) {
"use strict";
'use strict';

var $form = $('#wiki-page-edit');
var $idTagsField = $('#tagit_tags');
Expand All @@ -15,10 +15,12 @@
var itemTexts = [];

// Don't add list items we're going to remove
if(!isRemove) listItems.push(li);
if(!isRemove) {
listItems.push(li);
}

// Cycling through each list item,
listItems.each(function(i, e, a) {
listItems.each(function() {
if(!(isRemove && this === li[0])) {
itemTexts.push('"' + $(this).find('.tagit-label').text() + '"');
}
Expand Down

0 comments on commit 46e328b

Please sign in to comment.