2009-06-02 00:08:57 +02:00
|
|
|
<% content_for :javascript do %>
|
2011-04-11 07:30:43 +02:00
|
|
|
<style type="text/css">@import url(/javascripts/plupload/examples/css/plupload.queue.css);</style>
|
|
|
|
<%= javascript_include_tag "plupload/js/plupload.full.min.js" -%>
|
|
|
|
<%= javascript_include_tag "plupload/js/jquery.plupload.queue.min.js" -%>
|
2009-06-02 00:08:57 +02:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
2011-04-11 07:30:43 +02:00
|
|
|
|
|
|
|
$("#uploader").pluploadQueue({
|
|
|
|
// General settings
|
|
|
|
runtimes : 'html5,browserplus,flash,silverlight,gears',
|
|
|
|
url : '<%= photos_path %>',
|
|
|
|
max_file_size : '10mb',
|
|
|
|
chunk_size : '1mb',
|
|
|
|
unique_names : true,
|
|
|
|
multipart: true,
|
|
|
|
multipart_params: {
|
|
|
|
'authenticity_token' : '<%= form_authenticity_token %>',
|
2009-06-02 00:08:57 +02:00
|
|
|
'photo[album_id]' : "<%= @album.id %>"
|
2011-04-11 07:30:43 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Resize images on clientside if we can
|
|
|
|
//resize : {width : 320, height : 240, quality : 90},
|
|
|
|
|
|
|
|
// Specify what files to browse for
|
|
|
|
filters : [
|
|
|
|
{title : "Image files", extensions : "jpg,gif,png,bmp,jpeg,tif,tiff"}
|
|
|
|
],
|
|
|
|
|
|
|
|
// Flash settings
|
|
|
|
flash_swf_url : '/javascripts/plupload/js/plupload.flash.swf',
|
|
|
|
|
|
|
|
// Silverlight settings
|
|
|
|
silverlight_xap_url : '/javascripts/plupload/js/plupload.silverlight.xap',
|
|
|
|
|
|
|
|
// Post init events, bound after the internal events
|
|
|
|
init : {
|
|
|
|
|
|
|
|
FileUploaded: function(up, file, info) {
|
|
|
|
// Called when a file has finished uploading
|
|
|
|
res = info.response;
|
|
|
|
if (res.substring(0, 7) === "FILEID:") {
|
|
|
|
var image = $('<img>').appendTo('#thumbs')
|
|
|
|
image.css('display','none')
|
|
|
|
image.attr('src', res.substring(7) )
|
|
|
|
image.fadeIn('slow')
|
|
|
|
}
|
|
|
|
}
|
2009-06-02 00:08:57 +02:00
|
|
|
}
|
2011-04-11 07:30:43 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Client side form validation
|
|
|
|
$('form').submit(function(e) {
|
|
|
|
console.log('hello test');
|
|
|
|
var uploader = $('#uploader').pluploadQueue();
|
|
|
|
|
|
|
|
// Validate number of uploaded files
|
|
|
|
if (uploader.total.uploaded == 0) {
|
|
|
|
// Files in queue upload them first
|
|
|
|
if (uploader.files.length > 0) {
|
|
|
|
// When all files are uploaded submit form
|
|
|
|
uploader.bind('UploadProgress', function() {
|
|
|
|
if (uploader.total.uploaded == uploader.files.length)
|
|
|
|
$('form').submit();
|
|
|
|
});
|
|
|
|
|
|
|
|
uploader.start();
|
|
|
|
} else
|
|
|
|
alert('You must at least upload one file.');
|
|
|
|
|
|
|
|
e.preventDefault();
|
2009-06-02 00:08:57 +02:00
|
|
|
}
|
2011-04-11 07:30:43 +02:00
|
|
|
});
|
2009-06-02 00:08:57 +02:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<% end %>
|
2011-04-11 06:38:53 +02:00
|
|
|
|
2009-06-02 00:08:57 +02:00
|
|
|
<form>
|
2011-04-11 07:30:43 +02:00
|
|
|
<div id="uploader">
|
|
|
|
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
|
|
|
</div>
|
|
|
|
|
2010-09-17 17:57:33 +02:00
|
|
|
<br>
|
2009-06-02 00:08:57 +02:00
|
|
|
<div id="thumbs"></div>
|
|
|
|
</form>
|
|
|
|
|
2010-09-17 17:57:33 +02:00
|
|
|
<br><%= link_to "Edit uploaded photos", untouched_album_photos_path( @album ) %>
|
|
|
|
<br><%= link_to "Back to #{@album.title}", @album %>
|