Commit 4e3eb54b authored by Kevin Gutierrez's avatar Kevin Gutierrez
Browse files

Unify function spaces

parent ebe2f86d
$(function () { $(function() {
// Redirect users that don't support filereader // Redirect users that don't support filereader
if (!$('html').hasClass('filereader')) { if (!$('html').hasClass('filereader')) {
document.location.href = window.fileupload_opts.simple_upload_url; document.location.href = window.fileupload_opts.simple_upload_url;
...@@ -6,7 +6,7 @@ $(function () { ...@@ -6,7 +6,7 @@ $(function () {
} }
// prevents browser default drag/drop // prevents browser default drag/drop
$(document).bind('drop dragover', function (e) { $(document).bind('drop dragover', function(e) {
e.preventDefault(); e.preventDefault();
}); });
...@@ -20,7 +20,7 @@ $(function () { ...@@ -20,7 +20,7 @@ $(function () {
acceptFileTypes: window.fileupload_opts.errormessages.accepted_file_types, acceptFileTypes: window.fileupload_opts.errormessages.accepted_file_types,
maxFileSize: window.fileupload_opts.errormessages.max_file_size maxFileSize: window.fileupload_opts.errormessages.max_file_size
}, },
add: function (e, data) { add: function(e, data) {
$('.messages').empty(); $('.messages').empty();
var $this = $(this); var $this = $(this);
var that = $this.data('blueimp-fileupload') || $this.data('fileupload'); var that = $this.data('blueimp-fileupload') || $this.data('fileupload');
...@@ -30,21 +30,21 @@ $(function () { ...@@ -30,21 +30,21 @@ $(function () {
$('#upload-list').append(li); $('#upload-list').append(li);
data.context = li; data.context = li;
data.process(function () { data.process(function() {
return $this.fileupload('process', data); return $this.fileupload('process', data);
}).always(function () { }).always(function() {
data.context.removeClass('processing'); data.context.removeClass('processing');
data.context.find('.left').each(function (index, elm) { data.context.find('.left').each(function(index, elm) {
$(elm).append(escapeHtml(data.files[index].name)); $(elm).append(escapeHtml(data.files[index].name));
}); });
}).done(function () { }).done(function() {
data.context.find('.start').prop('disabled', false); data.context.find('.start').prop('disabled', false);
if (that._trigger('added', e, data) !== false && (options.autoUpload || data.autoUpload) && data.autoUpload !== false) { if (that._trigger('added', e, data) !== false && (options.autoUpload || data.autoUpload) && data.autoUpload !== false) {
data.submit(); data.submit();
} }
}).fail(function () { }).fail(function() {
if (data.files.error) { if (data.files.error) {
data.context.each(function (index) { data.context.each(function(index) {
var error = data.files[index].error; var error = data.files[index].error;
if (error) { if (error) {
$(this).find('.error_messages').text(error); $(this).find('.error_messages').text(error);
...@@ -54,18 +54,18 @@ $(function () { ...@@ -54,18 +54,18 @@ $(function () {
}); });
}, },
processfail: function (e, data) { processfail: function(e, data) {
var itemElement = $(data.context); var itemElement = $(data.context);
itemElement.removeClass('upload-uploading').addClass('upload-failure'); itemElement.removeClass('upload-uploading').addClass('upload-failure');
}, },
progress: function (e, data) { progress: function(e, data) {
if (e.isDefaultPrevented()) { if (e.isDefaultPrevented()) {
return false; return false;
} }
var progress = Math.floor((data.loaded / data.total) * 100); var progress = Math.floor((data.loaded / data.total) * 100);
data.context.each(function () { data.context.each(function() {
$(this) $(this)
.find('.progress') .find('.progress')
.addClass('active') .addClass('active')
...@@ -76,7 +76,7 @@ $(function () { ...@@ -76,7 +76,7 @@ $(function () {
}); });
}, },
progressall: function (e, data) { progressall: function(e, data) {
var progress = parseInt((data.loaded / data.total) * 100, 10); var progress = parseInt((data.loaded / data.total) * 100, 10);
$('#overall-progress') $('#overall-progress')
.addClass('active') .addClass('active')
...@@ -90,7 +90,7 @@ $(function () { ...@@ -90,7 +90,7 @@ $(function () {
} }
}, },
done: function (e, data) { done: function(e, data) {
var itemElement = $(data.context); var itemElement = $(data.context);
var response = $.parseJSON(data.result); var response = $.parseJSON(data.result);
...@@ -104,29 +104,29 @@ $(function () { ...@@ -104,29 +104,29 @@ $(function () {
} }
}, },
fail: function (e, data) { fail: function(e, data) {
var itemElement = $(data.context); var itemElement = $(data.context);
itemElement.addClass('upload-failure'); itemElement.addClass('upload-failure');
}, },
always: function (e, data) { always: function(e, data) {
var itemElement = $(data.context); var itemElement = $(data.context);
itemElement.removeClass('upload-uploading').addClass('upload-complete'); itemElement.removeClass('upload-uploading').addClass('upload-complete');
} }
}); });
// ajax-enhance forms added on done() // ajax-enhance forms added on done()
$('#upload-list').on('submit', 'form', function (e) { $('#upload-list').on('submit', 'form', function(e) {
var form = $(this); var form = $(this);
var itemElement = form.closest('#upload-list > li'); var itemElement = form.closest('#upload-list > li');
e.preventDefault(); e.preventDefault();
$.post(this.action, form.serialize(), function (data) { $.post(this.action, form.serialize(), function(data) {
if (data.success) { if (data.success) {
var statusText = $('.status-msg.update-success').text(); var statusText = $('.status-msg.update-success').text();
addMessage('success', statusText); addMessage('success', statusText);
itemElement.slideUp(function () { itemElement.slideUp(function() {
$(this).remove(); $(this).remove();
}); });
} else { } else {
...@@ -138,7 +138,7 @@ $(function () { ...@@ -138,7 +138,7 @@ $(function () {
}); });
}); });
$('#upload-list').on('click', '.delete', function (e) { $('#upload-list').on('click', '.delete', function(e) {
var form = $(this).closest('form'); var form = $(this).closest('form');
var itemElement = form.closest('#upload-list > li'); var itemElement = form.closest('#upload-list > li');
...@@ -146,9 +146,9 @@ $(function () { ...@@ -146,9 +146,9 @@ $(function () {
var CSRFToken = $('input[name="csrfmiddlewaretoken"]', form).val(); var CSRFToken = $('input[name="csrfmiddlewaretoken"]', form).val();
$.post(this.href, { csrfmiddlewaretoken: CSRFToken }, function (data) { $.post(this.href, { csrfmiddlewaretoken: CSRFToken }, function(data) {
if (data.success) { if (data.success) {
itemElement.slideUp(function () { itemElement.slideUp(function() {
$(this).remove(); $(this).remove();
}); });
} }
......
var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
'chooser': function (modal, jsonData) { 'chooser': function(modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action'); var searchUrl = $('form.video-search', modal.body).attr('action');
/* currentTag stores the tag currently being filtered on, so that we can /* currentTag stores the tag currently being filtered on, so that we can
...@@ -7,12 +7,12 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -7,12 +7,12 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
var currentTag; var currentTag;
function ajaxifyLinks(context) { function ajaxifyLinks(context) {
$('.listing a', context).click(function () { $('.listing a', context).click(function() {
modal.loadUrl(this.href); modal.loadUrl(this.href);
return false; return false;
}); });
$('.pagination a', context).click(function () { $('.pagination a', context).click(function() {
var page = this.getAttribute('data-page'); var page = this.getAttribute('data-page');
setPage(page); setPage(page);
return false; return false;
...@@ -23,7 +23,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -23,7 +23,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
$.ajax({ $.ajax({
url: searchUrl, url: searchUrl,
data: requestData, data: requestData,
success: function (data, status) { success: function(data, status) {
$('#image-results').html(data); $('#image-results').html(data);
ajaxifyLinks($('#image-results')); ajaxifyLinks($('#image-results'));
} }
...@@ -56,7 +56,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -56,7 +56,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
ajaxifyLinks(modal.body); ajaxifyLinks(modal.body);
$('form.video-upload', modal.body).submit(function () { $('form.video-upload', modal.body).submit(function() {
var formdata = new FormData(this); var formdata = new FormData(this);
$.ajax({ $.ajax({
url: this.action, url: this.action,
...@@ -65,10 +65,10 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -65,10 +65,10 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
contentType: false, contentType: false,
type: 'POST', type: 'POST',
dataType: 'text', dataType: 'text',
success: function (response) { success: function(response) {
modal.loadResponseText(response); modal.loadResponseText(response);
}, },
error: function (response, textStatus, errorThrown) { error: function(response, textStatus, errorThrown) {
var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status; var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append( $('#upload').append(
'<div class="help-block help-critical">' + '<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>' '<div class="help-block help-critical">' + '<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>'
...@@ -81,13 +81,13 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -81,13 +81,13 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
$('form.video-search', modal.body).submit(search); $('form.video-search', modal.body).submit(search);
$('#id_q').on('input', function () { $('#id_q').on('input', function() {
clearTimeout($.data(this, 'timer')); clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200); var wait = setTimeout(search, 200);
$(this).data('timer', wait); $(this).data('timer', wait);
}); });
$('#collection_chooser_collection_id').change(search); $('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function () { $('a.suggested-tag').click(function() {
currentTag = $(this).text(); currentTag = $(this).text();
$('#id_q').val(''); $('#id_q').val('');
fetchResults({ fetchResults({
...@@ -101,7 +101,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = { ...@@ -101,7 +101,7 @@ var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"} // autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// }); // });
}, },
'video_chosen': function (modal, jsonData) { 'video_chosen': function(modal, jsonData) {
modal.respond('videoChosen', jsonData['result']); modal.respond('videoChosen', jsonData['result']);
modal.close(); modal.close();
}, },
......
...@@ -4,12 +4,12 @@ function createVideoChooser(id) { ...@@ -4,12 +4,12 @@ function createVideoChooser(id) {
var input = $('#' + id); var input = $('#' + id);
var editLink = chooserElement.find('.edit-link'); var editLink = chooserElement.find('.edit-link');
$('.action-choose', chooserElement).click(function () { $('.action-choose', chooserElement).click(function() {
ModalWorkflow({ ModalWorkflow({
url: window.chooserUrls.videoChooser, url: window.chooserUrls.videoChooser,
onload: VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS, onload: VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS,
responses: { responses: {
videoChosen: function (videoData) { videoChosen: function(videoData) {
input.val(videoData.id); input.val(videoData.id);
previewVideo.attr({ previewVideo.attr({
src: videoData.preview.url, src: videoData.preview.url,
...@@ -22,7 +22,7 @@ function createVideoChooser(id) { ...@@ -22,7 +22,7 @@ function createVideoChooser(id) {
}); });
}); });
$('.action-clear', chooserElement).click(function () { $('.action-clear', chooserElement).click(function() {
input.val(''); input.val('');
chooserElement.addClass('blank'); chooserElement.addClass('blank');
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment