diff --git a/app/views/packages/details.slim b/app/views/packages/details.slim index 4208cb4..7aa9afe 100644 --- a/app/views/packages/details.slim +++ b/app/views/packages/details.slim @@ -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(); + }); + });