Permalink
Browse files

Merge pull request #943 from darkwing/code-cleanup

Quote cleanup for JS
  • Loading branch information...
2 parents 56197d2 + 3fc4e2e commit 158902829cd288e278c6799daafc0a836679b0bc @groovecoder groovecoder committed Mar 21, 2013
Showing with 66 additions and 66 deletions.
  1. +5 −5 media/js/wiki-tags-edit.js
  2. +51 −51 media/js/wiki.js
  3. +5 −5 media/js/wiki_ckeditor.js
  4. +5 −5 media/js/wiki_ckeditor_translate.js
@@ -1,16 +1,16 @@
(function($) {
$(document).ready(function() {
- var idTagsField = $("#tagit_tags");
+ var idTagsField = $('#tagit_tags');
// Create a hidden input type for the purposes of saving
- var hiddenTags = $('<input type="hidden" name="tags" id="hiddenTags" value="' + (idTagsField.val() || "") + '" />').appendTo("#page-tags");
+ var hiddenTags = $('<input type="hidden" name="tags" id="hiddenTags" value="' + (idTagsField.val() || '') + '" />').appendTo('#page-tags');
// Grabs text from the list items, updates hidden input so tags are properly saved
// Requires node reading because the tag-it widget incorrectly overrides the "singleNodeField"
function consolidateTags(isRemove) {
return function(event, li) {
- var listItems = $("#page-tags .tagit-choice"),
+ var listItems = $('#page-tags .tagit-choice'),
itemTexts = [];
// Don't add list items we're going to remove
@@ -24,10 +24,10 @@
// do nothing -- this is the item being removed
}
else {
- itemTexts.push('"' + $(this).find(".tagit-label").text() + '"');
+ itemTexts.push('"' + $(this).find('.tagit-label').text() + '"');
}
});
- hiddenTags.val(itemTexts.join(","));
+ hiddenTags.val(itemTexts.join(','));
};
};
View
@@ -28,7 +28,7 @@
var $body = $('body');
- if($body.hasClass("is-template")) {
+ if($body.hasClass('is-template')) {
isTemplate = 1;
}
@@ -749,12 +749,12 @@
* Initialize the article preview functionality.
*/
function initArticlePreview() {
- $("#btn-preview").click(function(e) {
+ $('#btn-preview').click(function(e) {
e.preventDefault();
// Ensure that content is available and exists
- var title = " ",
- $titleNode = $("#id_title"),
+ var title = ' ',
+ $titleNode = $('#id_title'),
data;
if(CKEDITOR.instances['id_content']) {
@@ -778,7 +778,7 @@
$("<input type='hidden' name='title' />").val(title).appendTo($form);
// Add the CSRF ?
- $("#csrfmiddlewaretoken").clone().appendTo($form);
+ $('#csrfmiddlewaretoken').clone().appendTo($form);
// Submit the form, and then get rid of it
$form.get(0).submit();
@@ -950,7 +950,7 @@
//
function initMetadataParentTranslation() {
var $parentLi = $('#article-head .metadata .metadata-choose-parent'),
- $parentInput = $("#parent_id");
+ $parentInput = $('#parent_id');
if($parentLi.length) {
$parentLi.css('display', 'block');
$('#parent_text').mozillaAutocomplete({
@@ -966,7 +966,7 @@
$parentInput.val(item.id);
},
onDeselect: function(item) {
- $parentInput.val("");
+ $parentInput.val('');
}
});
}
@@ -986,7 +986,7 @@
finalKey = 'draft/translate' + noEdit + '/' + location.search.replace('?tolocale=', '');
finalKey = finalKey.replace('$translate', '');
}
- else if($("#id_current_rev").val()) { // Edit
+ else if($('#id_current_rev').val()) { // Edit
finalKey = 'draft/edit' + noEdit;
}
else { // New
@@ -1013,7 +1013,7 @@
$draftDiv = $('<div class="notice"><p>' + text + '</p></div>').insertBefore($contentNode);
// Hook up the "restore" link
- $draftDiv.find(".restoreLink").click(function(e) {
+ $draftDiv.find('.restoreLink').click(function(e) {
e.preventDefault();
$contentNode.val(content);
@@ -1032,7 +1032,7 @@
});
// Hook up the "dispose" link
- $draftDiv.find(".discardLink").click(function(e) {
+ $draftDiv.find('.discardLink').click(function(e) {
e.preventDefault();
hideDraftBox();
clearDraft(getStorageKey());
@@ -1220,48 +1220,48 @@
}
function initAttachmentsActions() {
- var $attachmentsTable = $("#page-attachments-table"),
- $attachmentsCount = $("#page-attachments-count"),
- $attachmentsButton = $("#page-attachments-button"),
- $attachmentsNoMessage = $("#page-attachments-no-message"),
- $attachmentsNewTable = $("#page-attachments-new-table"),
- $attachmentsForm = $("#page-attachments-form"),
- $attachmentsFormCloneRow = $attachmentsNewTable.find("tbody tr").first(),
- $attachmentsNewTableActions = $attachmentsNewTable.find("tbody tr").last(),
- $pageAttachmentsSpinner = $("#page-attachments-spinner"),
- $iframe = $("#page-attachments-upload-target"),
- uploadFormTarget = $attachmentsForm.length && $attachmentsForm.attr("action"),
+ var $attachmentsTable = $('#page-attachments-table'),
+ $attachmentsCount = $('#page-attachments-count'),
+ $attachmentsButton = $('#page-attachments-button'),
+ $attachmentsNoMessage = $('#page-attachments-no-message'),
+ $attachmentsNewTable = $('#page-attachments-new-table'),
+ $attachmentsForm = $('#page-attachments-form'),
+ $attachmentsFormCloneRow = $attachmentsNewTable.find('tbody tr').first(),
+ $attachmentsNewTableActions = $attachmentsNewTable.find('tbody tr').last(),
+ $pageAttachmentsSpinner = $('#page-attachments-spinner'),
+ $iframe = $('#page-attachments-upload-target'),
+ uploadFormTarget = $attachmentsForm.length && $attachmentsForm.attr('action'),
running = false;
// If no attachments table, get out -- no permissions
if(!$attachmentsTable.length) {
return;
}
- // Upon click of the "Attach Files" button, toggle display of upload table
- $attachmentsButton.bind("click", function(e) {
+ // Upon click of the 'Attach Files' button, toggle display of upload table
+ $attachmentsButton.bind('click', function(e) {
e.preventDefault();
- $attachmentsNewTable.toggleClass("hidden");
- if(!$attachmentsNewTable.hasClass("hidden")) {
- $attachmentsNewTable.find("input[type=text]").first()[0].focus();
+ $attachmentsNewTable.toggleClass('hidden');
+ if(!$attachmentsNewTable.hasClass('hidden')) {
+ $attachmentsNewTable.find('input[type=text]').first()[0].focus();
}
});
- // Clicking the "AMF" button adds more rows
- $("#page-attachments-more").bind("click", function() {
+ // Clicking the 'AMF' button adds more rows
+ $('#page-attachments-more').bind('click', function() {
// Don't add boxes during submission
if(running) return;
function clone() {
// Create and insert clone
$clone = $attachmentsFormCloneRow.clone();
- $clone.find("input, textarea").val("");
- $clone.find(".attachment-error").remove();
+ $clone.find('input, textarea').val('');
+ $clone.find('.attachment-error').remove();
$clone.insertBefore($attachmentsNewTableActions);
$clone.addClass('dynamic-row');
// Show the cell actions now!
- $attachmentsNewTable.find(".page-attachment-actions-cell").removeClass("hidden");
- $clone.find(".delete-attachment").removeClass("hidden");
+ $attachmentsNewTable.find('.page-attachment-actions-cell').removeClass('hidden');
+ $clone.find('.delete-attachment').removeClass('hidden');
return $clone;
}
@@ -1273,13 +1273,13 @@
$("<input type='hidden' name='is_ajax' value='1' />").appendTo($attachmentsForm);
// Submitting the form posts to mystical iframe
- $iframe.bind("load", function(e) {
+ $iframe.bind('load', function(e) {
running = false;
$attachmentsForm.data('disabled', false);
// Handle results
try {
- var $textarea = $iframe.contents().find("textarea").first(),
+ var $textarea = $iframe.contents().find('textarea').first(),
validIndexes = [],
invalidIndexes = [],
dynamicRows,
@@ -1288,15 +1288,15 @@
// Get JSON
result = JSON.parse($.trim($textarea.val()));
// Add error messages where needed, or hide all new rows
- $dynamicRows = $attachmentsNewTable.find(".dynamic-row");
+ $dynamicRows = $attachmentsNewTable.find('.dynamic-row');
// Add the row to the table
$.each(result, function(i) {
// If valid....
if(this.id) {
// Add to uploads table
var $newTr = $(this.html);
$newTr.appendTo($attachmentsTable);
- $newTr.addClass("new-row");
+ $newTr.addClass('new-row');
// Update attachment count
$attachmentsCount.text(parseInt($attachmentsCount.text(), 10) + 1);
// Add item to list
@@ -1306,11 +1306,11 @@
validIndexes.push(i);
// Remove the form row
if(!i) { // First row
- $attachmentsFormCloneRow.find("input, textarea").val("");
+ $attachmentsFormCloneRow.find('input, textarea').val('');
}
else {
var node = $dynamicRows.eq(i)[0];
- $dynamicRows[i] = "";
+ $dynamicRows[i] = '';
node.parentNode.removeChild(node);
}
}
@@ -1320,9 +1320,9 @@
});
- // Hide the "no rows" paragraph, show table
- $attachmentsNoMessage.addClass("hidden");
- $attachmentsTable.removeClass("hidden");
+ // Hide the 'no rows' paragraph, show table
+ $attachmentsNoMessage.addClass('hidden');
+ $attachmentsTable.removeClass('hidden');
// If all good, we can reset the form
if(validIndexes.length == result.length) {
@@ -1335,42 +1335,42 @@
if(this == 0) {
// Add message to the clone row
$('<div class="attachment-error"></div>')
- .appendTo($attachmentsFormCloneRow.find(".page-attachment-actions-file-cell"))
+ .appendTo($attachmentsFormCloneRow.find('.page-attachment-actions-file-cell'))
.text(result[this]['error'])
}
});
}
}
else {
// Show error message?
- console.warn("No textarea")
+ console.warn('No textarea')
}
}
catch(e) {
// Show error message?
- console.warn("Exception! ", e);
+ console.warn('Exception! ', e);
}
- $pageAttachmentsSpinner.css("opacity", 0);
+ $pageAttachmentsSpinner.css('opacity', 0);
});
// Form submission, upload, and response handling
- $attachmentsForm.attr("target", "page-attachments-upload-target").bind("submit", function(e) {
+ $attachmentsForm.attr('target', 'page-attachments-upload-target').bind('submit', function(e) {
// Stop concurrent submissions
if(running) return;
// Hide all error messages
- $attachmentsNewTable.find(".attachment-error").remove();
+ $attachmentsNewTable.find('.attachment-error').remove();
// IE....
var valid = true;
- $attachmentsNewTable.find("input[required], textarea[required]").each(function() {
+ $attachmentsNewTable.find('input[required], textarea[required]').each(function() {
var $this = $(this);
- if($this.val() == "") {
+ if($this.val() == '') {
e.preventDefault();
e.stopPropagation();
- $this.addClass("attachment-required");
+ $this.addClass('attachment-required');
valid = false;
}
else {
- $this.removeClass("attachment-required");
+ $this.removeClass('attachment-required');
}
});
if(!valid) {
@@ -18,12 +18,12 @@
if (!fixed) {
fixed = true;
$head.css({
- position: 'fixed',
+ position: "fixed",
top: 19,
width: "95%"
});
$tools.css({
- position: 'fixed',
+ position: "fixed",
top: headHeight + 28,
width: $("#cke_id_content").width() - 11
});
@@ -38,12 +38,12 @@
if (fixed) {
fixed = false;
$head.css({
- position: 'relative',
+ position: "relative",
top: "auto",
width: "auto"
});
$tools.css({
- position: 'relative',
+ position: "relative",
top: "auto",
width: "auto"
});
@@ -66,7 +66,7 @@
});
// remove the id_content required attribute
- $('#id_content').removeAttr("required");
+ $("#id_content").removeAttr("required");
};
@@ -26,12 +26,12 @@
if (!fixed) {
fixed = true;
$head.css({
- position: 'fixed',
+ position: "fixed",
top: 19,
width: "95%"
});
$tools.css({
- position: 'fixed',
+ position: "fixed",
top: headHeight + 28,
width: $("#cke_id_content").width() - 11
});
@@ -48,12 +48,12 @@
if (fixed) {
fixed = false;
$head.css({
- position: 'relative',
+ position: "relative",
top: "auto",
width: "auto"
});
$tools.css({
- position: 'relative',
+ position: "relative",
top: "auto",
width: "auto"
});
@@ -69,7 +69,7 @@
}
// remove the id_content required attribute
- $('#id_content').removeAttr("required");
+ $("#id_content").removeAttr("required");
});

0 comments on commit 1589028

Please sign in to comment.