Skip to content
Permalink
Browse files
Fix eslint problems.
  • Loading branch information
mythmon committed Dec 15, 2015
1 parent be6fa7e commit 46f886e
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 179 deletions.
@@ -1,3 +1,5 @@
extends: eslint:recommended

rules:
# Turning on extra rules
quotes: [2, "single", "avoid-escape"]
@@ -14,7 +16,7 @@ rules:
spaced-comment: [2]
no-this-before-super: [2]
constructor-super: [2]
indent: [2, 2]
indent: [2, 2, {"SwitchCase": 1}]

# Turning off default rules. Should some of these be warnings?
no-console: [0]
@@ -27,6 +29,7 @@ rules:
no-extra-strict: [0]
no-inner-declarations: [0]
no-loop-func: [0]
no-func-assign: [0]

ecmaFeatures:
arrowFunctions: true
@@ -147,7 +147,7 @@
// the data-count attr of a parent tweet.
function update_reply_indicator($parent) {
var reply_txt = $parent.find('.reply_count').first(), // first() avoids nested tweets.
count = reply_txt.data('count') - 1;
count = reply_txt.data('count') - 1;
reply_txt.addClass('you');
if (count === 0) {
reply_txt.text(gettext('You replied'));
@@ -162,8 +162,8 @@
// Append a new tweet, given as the HTML of an <li>, to this thread.
function appendReply(html, parentId) {
var $parent = $('#tweet-' + parentId),
$count,
$replyList = $('#replies_' + parentId).children('ul');
$count,
$replyList = $('#replies_' + parentId).children('ul');
$replyList.append($(html).hide());

$count = $parent.find('.reply_count').first();
@@ -245,12 +245,12 @@
var csrf = $('#reply input[name=csrfmiddlewaretoken]').val();
this.$el.find('#submit').bind('click', {reply: this}, function(e) {
var reply = e.data.reply,
reqData = {
'csrfmiddlewaretoken': csrf,
'content': reply.content,
'reply_to': reply.tweet.id
},
$btn = $(this);
reqData = {
'csrfmiddlewaretoken': csrf,
'content': reply.content,
'reply_to': reply.tweet.id
},
$btn = $(this);
if (!$btn.is('.busy')) {
$btn.addClass('busy');
$.ajax({
@@ -407,7 +407,7 @@
/* Show/hide replies */
$('#tweets .reply-count').live('click', function(e) {
var tweet_id = $(this).closest('.tweet').attr('data-tweet-id'),
replies = $('#replies_' + tweet_id);
replies = $('#replies_' + tweet_id);

replies.toggle();

@@ -423,7 +423,7 @@
$(this).addClass('clicked');

var tweet = $(this).closest('.tweet'),
tweet_id = tweet.attr('data-tweet-id');
tweet_id = tweet.attr('data-tweet-id');
$.ajax({
url: $(this).attr('href'),
type: 'POST',
@@ -13,7 +13,7 @@
function initReadoutModes() {
$('.readout-modes').each(function attachClickHandler() {
var $modes = $(this),
slug = $modes.attr('data-slug');
slug = $modes.attr('data-slug');
$modes.find('.mode').each(function() {
var $button = $(this);
$button.click(function switchMode() {
@@ -37,7 +37,7 @@

function initWatchMenu() {
var $watchDiv = $('#doc-watch'),
$menu = $watchDiv.find('.popup-menu');
$menu = $watchDiv.find('.popup-menu');

// Initialize popup menu behavior:
$watchDiv.find('.popup-trigger').click(function toggleMenu() {
@@ -48,9 +48,8 @@
// Dim the checkbox, post the watch change, then undim.
$watchDiv.find('input[type=checkbox]').click(function post() {
var $box = $(this),
csrf = $box.closest('form')
.find('input[name=csrfmiddlewaretoken]').val(),
isChecked = $box.attr('checked');
csrf = $box.closest('form').find('input[name=csrfmiddlewaretoken]').val(),
isChecked = $box.attr('checked');
$box.attr('disabled', 'disabled');
$.ajax({
type: 'POST',
@@ -112,7 +111,7 @@
$form.removeClass('wait');
try {
data = JSON.parse(jxr.responseText);
} catch(e) {
} catch (e) {
data = {};
}
for (field in data) {
@@ -11,7 +11,7 @@
// Enable managing of member and leader lists.
$('.editable a.edit').each(function() {
var $this = $(this),
originalText = $this.text();
originalText = $this.text();
$this.click(function(ev) {
var $container = $this.closest('.editable');
$container.toggleClass('edit-on');
@@ -16,13 +16,13 @@

$('span.post-action a.reply').click(function() {
var post = $(this).data('post'),
$post = $('#post-' + post),
text = $post.find('div.content-raw').text(),
user = $post.find('a.author-name').text(),
reply = template("''{user} [[#post-{post}|said]]''\n<blockquote>\n{text}\n</blockquote>\n\n"),
reply_text,
$textarea = $('#id_content'),
oldtext = $textarea.val();
$post = $('#post-' + post),
text = $post.find('div.content-raw').text(),
user = $post.find('a.author-name').text(),
reply = template("''{user} [[#post-{post}|said]]''\n<blockquote>\n{text}\n</blockquote>\n\n"),
reply_text,
$textarea = $('#id_content'),
oldtext = $textarea.val();

reply_text = reply({'user': user, 'post': post, 'text': text});

@@ -56,14 +56,14 @@
$this.on('click', function(ev) {
ev.preventDefault();
var imgUrl = $this.attr('src'),
image = new Image(),
html = '<div><img class="loading" /></div>',
kbox = new KBox(html, {
modal: true,
title: gettext('Image Attachment'),
id: 'wiki-image-kbox',
destroy: true
});
image = new Image(),
html = '<div><img class="loading" /></div>',
kbox = new KBox(html, {
modal: true,
title: gettext('Image Attachment'),
id: 'wiki-image-kbox',
destroy: true
});
kbox.open();

function setWidth() {
@@ -35,7 +35,7 @@
$('#gallery-upload-modal .upload-media').each(function () {
var $self = $(this);
var type = $self.find('input').attr('name'),
details = $self.find('.details').html();
details = $self.find('.details').html();
CONSTANTS.messages.initial[type] = details;
});

@@ -128,7 +128,7 @@
// Deleting uploaded files sends ajax request.
jQuery.fn.makeCancelUpload = function(options) {
var $input = this,
field_name = $input.data('name');
field_name = $input.data('name');
if (!$input.is('input')) {
return $input;
}
@@ -185,7 +185,7 @@
*/
validateForm: function($input) {
var self = this,
$form = $input.closest('.upload-form');
$form = $input.closest('.upload-form');
// An image must be uploaded
if ($form[0] === self.forms.$image[0] &&
$form.find('.on input[type="file"]').length) {
@@ -209,13 +209,13 @@
*/
isValidFile: function ($input) {
var file = $input[0].files[0],
type = $input.attr('name');
type = $input.attr('name');
var file_ext = file.name.split(/\./).pop().toLowerCase();
return (in_array(file_ext, CONSTANTS.extensions[type]));
},
isTooLarge: function ($input) {
var file = $input[0].files[0],
type = $input.attr('name');
type = $input.attr('name');
return (file.size >= CONSTANTS.max_size[type]);
},
/*
@@ -228,8 +228,8 @@
*/
startUpload: function($input) {
var $form = $input.closest('.upload-form'),
filename = $input.val().split(/[\/\\]/).pop(),
$progress = $('.progress', $form)
filename = $input.val().split(/[\/\\]/).pop(),
$progress = $('.progress', $form)
.filter('.' + $input.attr('name'));
// truncate filename
if (filename.length > CONSTANTS.maxFilenameLength) {
@@ -254,7 +254,7 @@
var iframeJSON, self = this;
try {
iframeJSON = $.parseJSON(iframeContent);
} catch(err) {
} catch (err) {
self.uploadError($input, 'server');
}

@@ -276,11 +276,11 @@
*/
uploadSuccess: function($input, iframeJSON, filename) {
var type = $input.attr('name'),
$form = $input.closest('.upload-form'),
$cancel_btn = $('.upload-action input[name="cancel"]', $form),
$content, attrs = {},
$preview_area,
upFile = iframeJSON.file;
$form = $input.closest('.upload-form'),
$cancel_btn = $('.upload-action input[name="cancel"]', $form),
$content, attrs = {},
$preview_area,
upFile = iframeJSON.file;
var message = CONSTANTS.messages[type].del;

// Upload is no longer in progress.
@@ -329,7 +329,7 @@
*/
uploadError: function($input, reason) {
var self = this,
type = $input.attr('name');
type = $input.attr('name');
// Cancel existing upload.
$('.progress.' + type).find('a.' + type).click();
// Show an error message.
@@ -343,9 +343,9 @@
*/
deleteUpload: function($input) {
var self = this,
$cancelForm = $input.closest('form'),
$mediaForm = $input.closest('.upload-form'),
type = $input.data('name');
$cancelForm = $input.closest('form'),
$mediaForm = $input.closest('.upload-form'),
type = $input.data('name');
// Clean up all the preview and progress information.
$mediaForm.find('.preview.' + type).hideFade()
.filter('.row-right').html('');
@@ -370,8 +370,8 @@
*/
cancelUpload: function($a) {
var self = this,
type = $a.attr('class'),
$form = $a.closest('form');
type = $a.attr('class'),
$form = $a.closest('form');
var $input = $form.find('input[name="' + type + '"]');
var form_target = $input.closest('form').attr('target');
$('iframe[name="' + form_target + '"]')[0].src = null;
@@ -410,7 +410,7 @@
$uploads.each(function () {
var $self = $(this);
var type = $self.attr('name'),
$form = $self.closest('.upload-form');
$form = $self.closest('.upload-form');
if ($form.data(type)) {
$form.find('.upload-media.' + type).hideFade();
} else {
@@ -430,8 +430,8 @@
*/
modalClose: function() {
var self = this,
csrf = $('input[name="csrfmiddlewaretoken"]').first().val(),
$input = $('.upload-action input[name="cancel"]', self.$modal);
csrf = $('input[name="csrfmiddlewaretoken"]').first().val(),
$input = $('.upload-action input[name="cancel"]', self.$modal);
if (self.$modal.find('.draft').length) {
// If there's a draft to cancel.
$.ajax({
@@ -450,7 +450,7 @@
*/
modalReset: function() {
var self = this,
$uploads = self.$modal.find('.upload-media');
$uploads = self.$modal.find('.upload-media');
self.$modal.find('.draft').removeClass('draft');
// Hide metadata
self.$modal.find('.metadata').hide();
@@ -461,7 +461,7 @@
// Show all the file inputs with default messages.
$uploads.filter('.row-right').each(function () {
var $input = $(this).find('input[type="file"]'),
type = $input.attr('name');
type = $input.attr('name');
$input.closest('form')[0].reset();
$(this).find('.details').html(CONSTANTS.messages.initial[type]);
}).find('.error').removeClass('error');
@@ -79,7 +79,7 @@
'<div class="kbox-title"></div>' +
'<div class="kbox-wrap"><div class="kbox-placeholder"/></div>' +
'</div>',
OVERLAY =
OVERLAY =
'<div id="kbox-overlay"></div>';

// The KBox type
@@ -220,7 +220,7 @@
},
setPosition: function(position) {
var self = this,
toX, toY, $parent, parentOffset, minX, minY, scrollL, scrollT;
toX, toY, $parent, parentOffset, minX, minY, scrollL, scrollT;
if (!position) {
position = self.options.position;
}
@@ -20,6 +20,7 @@

env.addFilter('urlparams', function(url, params) {
if (url) {
var i;
var base = url.split('?')[0];
var qs = url.split('?')[1] || '';
qs = qs.split('&');
@@ -34,7 +35,7 @@

url = base;
var keys = Object.keys(params);
for (var i = 0; i < keys.length; i++) {
for (i = 0; i < keys.length; i++) {
url += (url.indexOf('?') === -1) ? '?' : '&';
url += keys[i];
var val = params[keys[i]];
@@ -105,20 +105,20 @@
// new Date(2013, 0, -60) === new Date(2012, 10, 1)
// This might be the only nice thing about JS's Date.
switch (this.data.bucketSize) {
case 'day':
case 'day':
// Get midnight of today (ie, the boundary between today and yesterday)
d.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
break;
case 'week':
d.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
break;
case 'week':
// Get the most recent Sunday.
d.date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay());
break;
case 'month':
d.date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay());
break;
case 'month':
// Get the first of this month.
d.date = new Date(date.getFullYear(), date.getMonth(), 1);
break;
default:
throw 'Unknown bucket size ' + this.data.bucketSize;
d.date = new Date(date.getFullYear(), date.getMonth(), 1);
break;
default:
throw 'Unknown bucket size ' + this.data.bucketSize;
}
d.date = d.date / 1000;

0 comments on commit 46f886e

Please sign in to comment.