Browse files

Fix eslint problems.

  • Loading branch information...
1 parent be6fa7e commit 46f886e0684398531968d89a72ac0ad94b6414c1 @mythmon mythmon committed Dec 15, 2015
View
5 .eslintrc
@@ -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
View
22 kitsune/sumo/static/sumo/js/customercare.js
@@ -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',
View
11 kitsune/sumo/static/sumo/js/dashboards.js
@@ -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) {
View
2 kitsune/sumo/static/sumo/js/editable.js
@@ -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');
View
30 kitsune/sumo/static/sumo/js/forums.js
@@ -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() {
View
48 kitsune/sumo/static/sumo/js/gallery.js
@@ -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');
View
4 kitsune/sumo/static/sumo/js/kbox.js
@@ -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;
}
View
3 kitsune/sumo/static/sumo/js/nunjucks.js
@@ -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]];
View
22 kitsune/sumo/static/sumo/js/rickshaw_utils.js
@@ -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;
View
22 kitsune/sumo/static/sumo/js/screencast.js
@@ -6,13 +6,13 @@
(function () {
var VIDEO_ID_PREFIX = 'video-flash-', id_counter = 0,
- FLASH_VERSION = '9.0.0',
- params = {allowfullscreen: 'true'},
- flashvars = {
- autoload: 1,
- showtime: 1,
- showvolume: 1
- };
+ FLASH_VERSION = '9.0.0',
+ params = {allowfullscreen: 'true'},
+ flashvars = {
+ autoload: 1,
+ showtime: 1,
+ showvolume: 1
+ };
/*
* Initializes flash fallback for a video object.
*/
@@ -22,11 +22,11 @@
}
var formats = {ogg: false, webm: false}, i,
- width = Number($video.data('width')),
- height = Number($video.data('height')),
+ width = Number($video.data('width')),
+ height = Number($video.data('height')),
// Build a unique ID for the object container
- unique_id = VIDEO_ID_PREFIX + id_counter,
- flash_file;
+ unique_id = VIDEO_ID_PREFIX + id_counter,
+ flash_file;
id_counter++;
$video.attr('id', unique_id);
View
2 kitsune/sumo/static/sumo/js/search.js
@@ -2,7 +2,7 @@
$(document).ready(function() {
// initiate tabs
var tabs = $('#search-tabs').tabs(),
- cache_search_date = $('.showhide-input');
+ cache_search_date = $('.showhide-input');
$('#tab-wrapper form').submit(function() {
$('input.auto-fill').each(function() {
View
19 kitsune/sumo/static/sumo/js/tags.filter.js
@@ -7,11 +7,10 @@
function init($container) {
var $form = $container ? $container.find('form') : $('#tag-filter form'),
- $tags = $form.find('input[type="text"]'),
- $btn = $form.find('input[type="submit"], button'),
- $hidden = $('<input type="hidden"/>'),
- vocab = $tags.data('vocabulary'),
- lowerVocab = {};
+ $tags = $form.find('input[type="text"]'), $btn = $form.find('input[type="submit"], button'),
+ $hidden = $('<input type="hidden"/>'),
+ vocab = $tags.data('vocabulary'),
+ lowerVocab = {};
if (!$form.length) {
return;
@@ -50,15 +49,15 @@
// When form is submitted, get the slugs to send over in request.
$form.submit(function() {
var tagNames = $tags.val(),
- slugNames = [],
- currentSlugs = $form.find('input.current-tagged').val(),
- slugs,
- invalid = false;
+ slugNames = [],
+ currentSlugs = $form.find('input.current-tagged').val(),
+ slugs,
+ invalid = false;
// For each tag name, find the slug.
_.each(tagNames.split(','), function(tag) {
var trimmed = $.trim(tag),
- slug = lowerVocab[trimmed.toLowerCase()];
+ slug = lowerVocab[trimmed.toLowerCase()];
if (slug) {
slugNames.push(slug);
} else if (trimmed) {
View
42 kitsune/sumo/static/sumo/js/tags.js
@@ -33,11 +33,11 @@
// Return a function() that sets the enabledness of the Add button appropriately.
function makeButtonTender($addForm) {
var $adder = $addForm.find('input.adder'),
- $input = $addForm.find('input.autocomplete-tags'),
- $tagsDiv = $input.closest('div.tags'),
- canCreateTags = $tagsDiv.data('can-create-tags') !== undefined,
- vocab = $tagsDiv.data('tagVocab'),
- $tagList = inputToTagList($input);
+ $input = $addForm.find('input.autocomplete-tags'),
+ $tagsDiv = $input.closest('div.tags'),
+ canCreateTags = $tagsDiv.data('can-create-tags') !== undefined,
+ vocab = $tagsDiv.data('tagVocab'),
+ $tagList = inputToTagList($input);
// Enable Add button if the entered tag is in the vocabulary. Else,
// disable it. If the user has the can_add_tag permission, let him
@@ -47,8 +47,8 @@
// TODO: Optimization: use the calculation already done for the
// autocomplete menu to limit the search space.
var tagName = $.trim($input.val()),
- inVocab = inArrayCaseInsensitive(tagName, vocab) !== -1,
- isOnscreen = tagIsOnscreen(tagName, $tagList);
+ inVocab = inArrayCaseInsensitive(tagName, vocab) !== -1,
+ isOnscreen = tagIsOnscreen(tagName, $tagList);
$adder.attr('disabled', !tagName.length || isOnscreen ||
(!canCreateTags && !inVocab));
}
@@ -62,11 +62,11 @@
// $tags -- a .tags element containing a vocab in its tagVocab attr
function makeVocabCallback($tags) {
var vocab = $tags.data('tagVocab'),
- $tagList = $tags.find('ul.tag-list');
+ $tagList = $tags.find('ul.tag-list');
function vocabCallback(request, response) {
var appliedTags = getAppliedTags($tagList),
- vocabMinusApplied = $.grep(vocab,
+ vocabMinusApplied = $.grep(vocab,
function(e, i) {
return $.inArray(e, appliedTags) === -1;
}
@@ -80,7 +80,7 @@
$('input.autocomplete-tags').each(
function() {
var $input = $(this),
- tender = makeButtonTender($input.closest('form'));
+ tender = makeButtonTender($input.closest('form'));
$input.autocomplete({
source: makeVocabCallback($input.closest('div.tags')),
@@ -103,7 +103,7 @@
$('div.tags').each(
function() {
var $div = $(this),
- async = !$div.hasClass('deferred');
+ async = !$div.hasClass('deferred');
$div.find('.tag').each(
function() {
attachRemoverHandlerTo($(this), async);
@@ -122,9 +122,9 @@
$container.find('.remover').click(
function() {
var $remover = $(this),
- $tag = $remover.closest('.tag'),
- tagName = $tag.find('.tag-name').text(),
- csrf = $remover.closest('form')
+ $tag = $remover.closest('.tag'),
+ tagName = $tag.find('.tag-name').text(),
+ csrf = $remover.closest('form')
.find('input[name=csrfmiddlewaretoken]').val();
function makeTagDisappear() {
@@ -155,11 +155,11 @@
// $container is either a form or a div.tags.
function addTag($container, async) {
var $input = $container.find('input.autocomplete-tags'),
- tagName = $input.val(),
- vocab = $input.closest('div.tags').data('tagVocab'),
- tagIndex = inArrayCaseInsensitive(tagName, vocab),
- csrf = $container.find('input[name=csrfmiddlewaretoken]').val(),
- $tag;
+ tagName = $input.val(),
+ vocab = $input.closest('div.tags').data('tagVocab'),
+ tagIndex = inArrayCaseInsensitive(tagName, vocab),
+ csrf = $container.find('input[name=csrfmiddlewaretoken]').val(),
+ $tag;
// Add a (ghostly, if async) tag to the onscreen
// list and return the tag element. If the tag was
@@ -206,7 +206,7 @@
// activate its remover button, and
// add it to the local vocab.
var url = data.tagUrl,
- tagNameSpan = $tag.find('.tag-name');
+ tagNameSpan = $tag.find('.tag-name');
tagNameSpan.replaceWith($("<a class='tag-name' />")
.attr('href', url)
.text(tagNameSpan.text()));
@@ -231,7 +231,7 @@
$('.tag-adder').each(function() {
var $this = $(this),
- async = !$this.hasClass('deferred');
+ async = !$this.hasClass('deferred');
function handler() {
return addTag($this, async);
}
View
30 kitsune/sumo/static/sumo/js/upload.js
@@ -38,12 +38,12 @@ $(document).ready(function () {
url: $(this).closest('.attachments-upload').data('post-url'),
beforeSubmit: function($input) {
var $divUpload = $input.closest('.attachments-upload'),
- $options = {
- progress: $divUpload.find('.upload-progress'),
- add: $divUpload.find('.add-attachment'),
- adding: $divUpload.find('.adding-attachment'),
- loading: $divUpload.find('.uploaded')
- };
+ $options = {
+ progress: $divUpload.find('.upload-progress'),
+ add: $divUpload.find('.add-attachment'),
+ adding: $divUpload.find('.adding-attachment'),
+ loading: $divUpload.find('.uploaded')
+ };
// truncate filename
$options.filename = $input.val().split(/[\/\\]/).pop();
@@ -73,7 +73,7 @@ $(document).ready(function () {
try {
iframeJSON = $.parseJSON(iframeContent);
- } catch(err) {
+ } catch (err) {
if (err.substr(0, 12) === 'Invalid JSON') {
dialogSet(UPLOAD.error_login, UPLOAD.error_title_up);
}
@@ -126,14 +126,14 @@ $(document).ready(function () {
$('article').on('click', '.attachments-list a.image', function(ev) {
ev.preventDefault();
var imgUrl = $(this).attr('href'),
- image = new Image(),
- html = '<div><img class="loading" /></div>',
- kbox = new KBox(html, {
- modal: true,
- title: gettext('Image Attachment'),
- id: 'image-attachment-kbox',
- destroy: true
- });
+ image = new Image(),
+ html = '<div><img class="loading" /></div>',
+ kbox = new KBox(html, {
+ modal: true,
+ title: gettext('Image Attachment'),
+ id: 'image-attachment-kbox',
+ destroy: true
+ });
kbox.open();
function setWidth() {
View
98 kitsune/sumo/static/sumo/js/wiki.js
@@ -123,12 +123,12 @@
$('details').each(function() {
// Store a reference to the current `details` element in a variable
var $details = $(this),
- // Store a reference to the `summary` element of the current `details` element (if any) in a variable
- $detailsSummary = $('summary', $details),
- // Do the same for the info within the `details` element
- $detailsNotSummary = $details.children(':not(summary)'),
- // This will be used later to look for direct child text nodes
- $detailsNotSummaryContents = $details.contents(':not(summary)');
+ // Store a reference to the `summary` element of the current `details` element (if any) in a variable
+ $detailsSummary = $('summary', $details),
+ // Do the same for the info within the `details` element
+ $detailsNotSummary = $details.children(':not(summary)'),
+ // This will be used later to look for direct child text nodes
+ $detailsNotSummaryContents = $details.contents(':not(summary)');
// If there is no `summary` in the current `details` element...
if (!$detailsSummary.length) {
@@ -169,15 +169,15 @@
$detailsNotSummary.slideToggle();
$details.toggleClass('open');
}).keyup(function(event) {
- if (event.keyCode === 13 || event.keyCode === 32) {
+ if (event.keyCode === 13 || event.keyCode === 32) {
// Enter or Space is pressed -- trigger the `click` event on the `summary` element
// Opera already seems to trigger the `click` event when Enter is pressed
- if (!($.browser.opera && event.keyCode === 13)) {
- event.preventDefault();
- $detailsSummary.click();
- }
- }
- });
+ if (!($.browser.opera && event.keyCode === 13)) {
+ event.preventDefault();
+ $detailsSummary.click();
+ }
+ }
+ });
});
}
}
@@ -220,23 +220,23 @@
function initSummaryCount() {
var $summaryCount = $('#remaining-characters'),
- $summaryBox = $('#id_summary'),
- // 160 characters is the maximum summary
- // length of a Google result
- warningCount = 160,
- maxCount = $summaryCount.text(),
- updateCount = function() {
- var currentCount = $summaryBox.val().length;
- $summaryCount.text(warningCount - currentCount);
- if (warningCount - currentCount >= 0) {
- $summaryCount.css('color', 'black');
- } else {
- $summaryCount.css('color', 'red');
- if (currentCount >= maxCount) {
- $summaryBox.val($summaryBox.val().substr(0, maxCount));
- }
+ $summaryBox = $('#id_summary'),
+ // 160 characters is the maximum summary
+ // length of a Google result
+ warningCount = 160,
+ maxCount = $summaryCount.text(),
+ updateCount = function() {
+ var currentCount = $summaryBox.val().length;
+ $summaryCount.text(warningCount - currentCount);
+ if (warningCount - currentCount >= 0) {
+ $summaryCount.css('color', 'black');
+ } else {
+ $summaryCount.css('color', 'red');
+ if (currentCount >= maxCount) {
+ $summaryBox.val($summaryBox.val().substr(0, maxCount));
}
- };
+ }
+ };
updateCount();
$summaryBox.bind('input', updateCount);
@@ -247,11 +247,11 @@
*/
function initArticlePreview() {
var $preview = $('#preview'),
- $previewBottom = $('#preview-bottom'),
- preview = new k.AjaxPreview($('.btn-preview'), {
- contentElement: $('#id_content'),
- previewElement: $preview
- });
+ $previewBottom = $('#preview-bottom'),
+ preview = new k.AjaxPreview($('.btn-preview'), {
+ contentElement: $('#id_content'),
+ previewElement: $preview
+ });
$(preview).bind('done', function(e, success) {
if (success) {
$previewBottom.show();
@@ -267,8 +267,8 @@
// Diff Preview of edits
function initPreviewDiff() {
var $diff = $('#preview-diff'),
- $previewBottom = $('#preview-bottom'),
- $diffButton = $('.btn-diff');
+ $previewBottom = $('#preview-bottom'),
+ $diffButton = $('.btn-diff');
$diff.addClass('diff-this');
$diffButton.click(function() {
$diff.find('.to').text($('#id_content').val());
@@ -281,18 +281,18 @@
function initTitleAndSlugCheck() {
$('#id_title').change(function() {
var $this = $(this),
- $form = $this.closest('form'),
- title = $this.val(),
- slug = $('#id_slug').val();
+ $form = $this.closest('form'),
+ title = $this.val(),
+ slug = $('#id_slug').val();
verifyTitleUnique(title, $form);
// Check slug too, since it auto-updates and doesn't seem to fire
// off change event.
verifySlugUnique(slug, $form);
});
$('#id_slug').change(function() {
var $this = $(this),
- $form = $this.closest('form'),
- slug = $('#id_slug').val();
+ $form = $this.closest('form'),
+ slug = $('#id_slug').val();
verifySlugUnique(slug, $form);
});
@@ -343,8 +343,8 @@
// If the Customer Care banner is present, animate it and handle closing.
function initAOABanner() {
var $banner = $('#banner'),
- cssFrom = { top: -100 },
- cssTo = { top: -10 };
+ cssFrom = { top: -100 },
+ cssTo = { top: -10 };
if ($banner.length > 0) {
setTimeout(function() {
$banner
@@ -365,7 +365,7 @@
// submit modal.
function initPreValidation() {
var $modal = $('#submit-modal'),
- kbox = $modal.data('kbox');
+ kbox = $modal.data('kbox');
kbox.updateOptions({
preOpen: function() {
var form = $('.btn-submit').closest('form')[0];
@@ -442,7 +442,7 @@
function initReadyForL10n() {
var $watchDiv = $('#revision-list div.l10n'),
- post_url, checkbox_id;
+ post_url, checkbox_id;
$watchDiv.find('a.markasready').click(function() {
var $check = $(this);
@@ -453,7 +453,7 @@
$('#ready-for-l10n-modal input[type=submit], #ready-for-l10n-modal button[type=submit]').click(function() {
var csrf = $('#ready-for-l10n-modal input[name=csrfmiddlewaretoken]').val(),
- kbox = $('#ready-for-l10n-modal').data('kbox');
+ kbox = $('#ready-for-l10n-modal').data('kbox');
if (post_url !== undefined && checkbox_id !== undefined) {
$.ajax({
type: 'POST',
@@ -475,8 +475,8 @@
function addReferrerAndQueryToVoteForm() {
// Add the source/referrer and query terms to the helpful vote form
var urlParams = k.getQueryParamsAsDict(),
- referrer = k.getReferrer(urlParams),
- query = k.getSearchQuery(urlParams, referrer);
+ referrer = k.getReferrer(urlParams),
+ query = k.getSearchQuery(urlParams, referrer);
$('.document-vote form')
.append($('<input type="hidden" name="referrer"/>')
.attr('value', referrer))
@@ -489,7 +489,7 @@
// "Needs change" checkbox. Also, make the textarea required
// when checked.
var $checkbox = $('#id_needs_change'),
- $comment = $('#document-form li.comment,#approve-modal div.comment');
+ $comment = $('#document-form li.comment,#approve-modal div.comment');
if ($checkbox.length > 0) {
updateComment();

0 comments on commit 46f886e

Please sign in to comment.