Newer
Older
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
Daniel Vincent Grippi
a validé
danielvincent
a validé
var aspectIds = "#{aspect_ids}".split(',');
var uploader = new qq.FileUploaderBasic({
element: document.getElementById('file-upload'),
danielvincent
a validé
params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"},
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tiff'],
action: "#{photos_path}",
debug: true,
button: document.getElementById('file-upload'),
onProgress: function(id, fileName, loaded, total){
},
danielvincent
a validé
messages: {
typeError: "#{t('.invalid_ext')}",
sizeError: "#{t('.size_error')}",
emptyError: "#{t('.empty')}"
},
$('#file-upload').addClass("loading");
$('#publisher').find("input[type='submit']").attr('disabled','disabled');
$('#photodropzone').append(
"<li class='publisher_photo loading' style='position:relative;'>" +
"<img src='/images/ajax-loader2.gif' />" +
"</li>"
);
danielvincent
a validé
onComplete: function(id, fileName, responseJSON) {
$('#fileInfo').text(fileName + ' completed');
url = responseJSON.data.photo.unprocessed_image.url,
currentPlaceholder = $('li.loading').first();
danielvincent
a validé
$('#new_status_message').append("<input type='hidden' value='" + id + "' name='photos[]' />");
// replace image placeholders
var img = currentPlaceholder.find('img');
img.attr('src', url);
img.attr('data-id', id);
currentPlaceholder.removeClass('loading');
currentPlaceholder.append("<div class='x'>X</div>" +
"<div class='circle'></div>");
////
var publisher = $('#publisher'),
textarea = publisher.find('textarea');
publisher.find("input[type='submit']").removeAttr('disabled');
$('.x').bind('click', function(){
var photo = $(this).closest('.publisher_photo');
$.ajax({url: "photos/" + photo.children('img').attr('data-id'),
type: 'DELETE',
success: function() {
photo.fadeOut(400, function(){
if ( $('.publisher_photo').length == 0){
},
onAllComplete: function(completed_files){
danielvincent
a validé
danielvincent
a validé