-# Copyright (c) 2010-2011, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. :javascript function createUploader(){ var aspectIds = "#{aspect_ids}".split(','); var uploader = new qq.FileUploaderBasic({ element: document.getElementById('file-upload'), params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"}, allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], action: "#{photos_path}", debug: true, button: document.getElementById('file-upload'), sizeLimit: 4194304, onProgress: function(id, fileName, loaded, total){ }, messages: { typeError: "#{t('.invalid_ext')}", sizeError: "#{t('.size_error')}", emptyError: "#{t('.empty')}" }, onSubmit: function(id, fileName){ $('#file-upload').addClass("loading"); $('#publisher').find("input[type='submit']").attr('disabled','disabled'); $("#publisher textarea").addClass("with_attachments"); $('#photodropzone').append( "
  • " + "" + "
  • " ); }, onComplete: function(id, fileName, responseJSON) { $('#fileInfo').text(fileName + ' completed'); var id = responseJSON.data.photo.id, url = responseJSON.data.photo.unprocessed_image.url, currentPlaceholder = $('li.loading').first(); $("#publisher textarea").addClass("with_attachments"); $('#new_status_message').append(""); // replace image placeholders var img = currentPlaceholder.find('img'); img.attr('src', url); img.attr('data-id', id); currentPlaceholder.removeClass('loading'); currentPlaceholder.append("
    X
    " + "
    "); //// var publisher = $('#publisher'), textarea = publisher.find('textarea'); publisher.find("input[type='submit']").removeAttr('disabled'); $('.x').bind('click', function(){ var photo = $(this).closest('.publisher_photo'); photo.addClass("dim"); $.ajax({url: "photos/" + photo.children('img').attr('data-id'), type: 'DELETE', success: function() { photo.fadeOut(400, function(){ photo.remove(); textarea.css('paddingBottom', $("#photodropzone").height() + 10); if ( $('.publisher_photo').length == 0){ textarea.removeClass("with_attachments"); textarea.css('paddingBottom', ''); if( $('#status_message_text').attr("value") == ""){ Publisher.close() } } }); } }); }); }, onAllComplete: function(completed_files){ } }); } createUploader();