Upload form now shows an image button and submits automatically.
This commit is contained in:
parent
c691f60ef1
commit
94de7fc9ca
1 changed files with 18 additions and 8 deletions
|
|
@ -26,15 +26,9 @@
|
||||||
|
|
||||||
// Upload image
|
// Upload image
|
||||||
li
|
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|
|
= form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f|
|
||||||
= f.label :image, 'Upload new screenshot'
|
= image_tag("/images/dummy/upload.svg", style: "width: 100%", id: 'upload-image')
|
||||||
= f.file_field :image, id: 'fileupload', multiple: true
|
= f.file_field :image, id: 'fileupload', multiple: true, style: 'display: none'
|
||||||
= f.submit "Upload"
|
|
||||||
//- raise
|
|
||||||
|
|
||||||
// TODO: Enable comments in a later version
|
// TODO: Enable comments in a later version
|
||||||
// = partial '/package/comments'
|
// = partial '/package/comments'
|
||||||
|
|
@ -73,3 +67,19 @@
|
||||||
// //$('#comment-content,#comment-author').fadeIn();
|
// //$('#comment-content,#comment-author').fadeIn();
|
||||||
// $('form.comment > *').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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue