Upload form now shows an image button and submits automatically.

This commit is contained in:
Christoph Haas 2015-04-19 01:11:20 +02:00
parent c691f60ef1
commit 94de7fc9ca

View file

@ -26,15 +26,9 @@
// Upload image
li
/ = form_tag(upload_image_path, multipart: true)
/ = file_field_tag('image')
/ = submit_tag
= form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f|
= f.label :image, 'Upload new screenshot'
= f.file_field :image, id: 'fileupload', multiple: true
= f.submit "Upload"
//- raise
= image_tag("/images/dummy/upload.svg", style: "width: 100%", id: 'upload-image')
= f.file_field :image, id: 'fileupload', multiple: true, style: 'display: none'
// TODO: Enable comments in a later version
// = partial '/package/comments'
@ -73,3 +67,19 @@
// //$('#comment-content,#comment-author').fadeIn();
// $('form.comment > *').fadeIn();
// });
javascript:
$(function () {
// If the image button is clicked then imitate a click on the file
// select button that is hidden.
$("#upload-image").click( function () {
$("#fileupload").click();
});
// Files have been selected. Tell the user what's going on and
// submit the upload form.
$('#fileupload').change( function () {
$('#upload-image').attr('src', '/images/dummy/please-wait.svg');
$('form').submit();
});
});