Commit a05a47fb authored by Kevin Gutierrez's avatar Kevin Gutierrez
Browse files

Format JS files

parent cd475b8e
$(function() {
$(function () {
// Redirect users that don't support filereader
if (!$('html').hasClass('filereader')) {
document.location.href = window.fileupload_opts.simple_upload_url;
......@@ -6,7 +6,7 @@ $(function() {
}
// prevents browser default drag/drop
$(document).bind('drop dragover', function(e) {
$(document).bind('drop dragover', function (e) {
e.preventDefault();
});
......@@ -20,7 +20,7 @@ $(function() {
acceptFileTypes: window.fileupload_opts.errormessages.accepted_file_types,
maxFileSize: window.fileupload_opts.errormessages.max_file_size
},
add: function(e, data) {
add: function (e, data) {
$('.messages').empty();
var $this = $(this);
var that = $this.data('blueimp-fileupload') || $this.data('fileupload')
......@@ -30,23 +30,23 @@ $(function() {
$('#upload-list').append(li);
data.context = li;
data.process(function() {
data.process(function () {
return $this.fileupload('process', data);
}).always(function() {
}).always(function () {
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));
});
}).done(function() {
}).done(function () {
data.context.find('.start').prop('disabled', false);
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false) {
data.submit()
}
}).fail(function() {
}).fail(function () {
if (data.files.error) {
data.context.each(function(index) {
data.context.each(function (index) {
var error = data.files[index].error;
if (error) {
$(this).find('.error_messages').text(error);
......@@ -56,18 +56,18 @@ $(function() {
});
},
processfail: function(e, data) {
processfail: function (e, data) {
var itemElement = $(data.context);
itemElement.removeClass('upload-uploading').addClass('upload-failure');
},
progress: function(e, data) {
progress: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var progress = Math.floor(data.loaded / data.total * 100);
data.context.each(function() {
data.context.each(function () {
$(this).find('.progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css(
'width',
progress + '%'
......@@ -75,7 +75,7 @@ $(function() {
});
},
progressall: function(e, data) {
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#overall-progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css(
'width',
......@@ -87,7 +87,7 @@ $(function() {
}
},
done: function(e, data) {
done: function (e, data) {
var itemElement = $(data.context);
var response = $.parseJSON(data.result);
......@@ -102,29 +102,29 @@ $(function() {
},
fail: function(e, data) {
fail: function (e, data) {
var itemElement = $(data.context);
itemElement.addClass('upload-failure');
},
always: function(e, data) {
always: function (e, data) {
var itemElement = $(data.context);
itemElement.removeClass('upload-uploading').addClass('upload-complete');
}
});
// ajax-enhance forms added on done()
$('#upload-list').on('submit', 'form', function(e) {
$('#upload-list').on('submit', 'form', function (e) {
var form = $(this);
var itemElement = form.closest('#upload-list > li');
e.preventDefault();
$.post(this.action, form.serialize(), function(data) {
$.post(this.action, form.serialize(), function (data) {
if (data.success) {
var statusText = $('.status-msg.update-success').text();
addMessage('success', statusText);
itemElement.slideUp(function() {$(this).remove()});
itemElement.slideUp(function () { $(this).remove() });
} else {
form.replaceWith(data.form);
......@@ -134,7 +134,7 @@ $(function() {
});
});
$('#upload-list').on('click', '.delete', function(e) {
$('#upload-list').on('click', '.delete', function (e) {
var form = $(this).closest('form');
var itemElement = form.closest('#upload-list > li');
......@@ -142,9 +142,9 @@ $(function() {
var CSRFToken = $('input[name="csrfmiddlewaretoken"]', form).val();
$.post(this.href, {csrfmiddlewaretoken: CSRFToken}, function(data) {
$.post(this.href, { csrfmiddlewaretoken: CSRFToken }, function (data) {
if (data.success) {
itemElement.slideUp(function() {$(this).remove()});
itemElement.slideUp(function () { $(this).remove() });
}
});
});
......
VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
'chooser': function(modal, jsonData) {
var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
'chooser': function (modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action');
/* currentTag stores the tag currently being filtered on, so that we can
preserve this when paginating */
var currentTag;
function ajaxifyLinks (context) {
$('.listing a', context).click(function() {
function ajaxifyLinks(context) {
$('.listing a', context).click(function () {
modal.loadUrl(this.href);
return false;
});
$('.pagination a', context).click(function() {
$('.pagination a', context).click(function () {
var page = this.getAttribute("data-page");
setPage(page);
return false;
......@@ -23,7 +23,7 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
$.ajax({
url: searchUrl,
data: requestData,
success: function(data, status) {
success: function (data, status) {
$('#image-results').html(data);
ajaxifyLinks($('#image-results'));
}
......@@ -42,8 +42,8 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
}
function setPage(page) {
params = {p: page};
if ($('#id_q').val().length){
var params = { p: page };
if ($('#id_q').val().length) {
params['q'] = $('#id_q').val();
}
if (currentTag) {
......@@ -56,7 +56,7 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
ajaxifyLinks(modal.body);
$('form.video-upload', modal.body).submit(function() {
$('form.video-upload', modal.body).submit(function () {
var formdata = new FormData(this);
$.ajax({
url: this.action,
......@@ -65,11 +65,11 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
contentType: false,
type: 'POST',
dataType: 'text',
success: function(response){
success: function (response) {
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
error: function (response, textStatus, errorThrown) {
var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' +
'<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>');
......@@ -81,13 +81,13 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
$('form.video-search', modal.body).submit(search);
$('#id_q').on('input', function() {
$('#id_q').on('input', function () {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200);
$(this).data('timer', wait);
});
$('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function() {
$('a.suggested-tag').click(function () {
currentTag = $(this).text();
$('#id_q').val('');
fetchResults({
......@@ -101,7 +101,7 @@ VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// });
},
'video_chosen': function(modal, jsonData) {
'video_chosen': function (modal, jsonData) {
modal.respond('videoChosen', jsonData['result']);
modal.close();
},
......
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