2011-04-25 07:54:08 +02:00
|
|
|
<%= content_for :javascript do %>
|
2012-07-20 22:50:30 +02:00
|
|
|
<style type="text/css">@import url(/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css);</style>
|
|
|
|
<%= javascript_include_tag "plupload/js/plupload.full.js" -%>
|
|
|
|
<%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%>
|
2009-06-02 00:08:57 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function () {
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
$("#uploader").pluploadQueue({
|
|
|
|
// General settings
|
|
|
|
runtimes:'flash,html5,browserplus,silverlight,gears',
|
|
|
|
url:'<%= photos_path %>',
|
|
|
|
max_file_size:'10mb',
|
|
|
|
multipart:true,
|
|
|
|
multipart_params:{
|
|
|
|
'<%= get_session_key %>':encodeURIComponent('<%= cookies[get_session_key] %>'),
|
|
|
|
'authenticity_token':'<%= form_authenticity_token %>',
|
|
|
|
'photo[album_id]':"<%= @album.id %>"
|
|
|
|
},
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Resize images on clientside if we can
|
|
|
|
//resize : {width : 320, height : 240, quality : 90},
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Specify what files to browse for
|
|
|
|
filters:[
|
|
|
|
{title:"Image files", extensions:"jpg,gif,png,bmp,jpeg,tif,tiff,JPG,GIF,PNG,BMP,JPEG,TIF,TIFF"}
|
|
|
|
],
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Flash settings
|
|
|
|
flash_swf_url:'/javascripts/plupload/js/plupload.flash.swf',
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Silverlight settings
|
|
|
|
silverlight_xap_url:'/javascripts/plupload/js/plupload.silverlight.xap',
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Post init events, bound after the internal events
|
|
|
|
init:{
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
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')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// Client side form validation
|
|
|
|
$('form').submit(function (e) {
|
|
|
|
var uploader = $('#uploader').pluploadQueue();
|
2011-04-11 07:30:43 +02:00
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
</script>
|
2009-06-02 00:08:57 +02:00
|
|
|
<% end %>
|
2011-04-11 06:38:53 +02:00
|
|
|
|
2009-06-02 00:08:57 +02:00
|
|
|
<form>
|
2012-07-20 22:50:30 +02:00
|
|
|
<div id="uploader">
|
|
|
|
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div id="thumbs"></div>
|
2009-06-02 00:08:57 +02:00
|
|
|
</form>
|
|
|
|
|
2012-07-20 22:50:30 +02:00
|
|
|
<br><%= link_to "Edit uploaded photos", untouched_album_photos_path(@album) %>
|
2010-09-17 17:57:33 +02:00
|
|
|
<br><%= link_to "Back to #{@album.title}", @album %>
|