diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c60af6a..51ec189 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -40,7 +40,8 @@ load_reviews = function() { // Initialize the upload form. upload_form_init = function() { - // Disable the submit button until files are selected. + // Disable the submit button if Javascript is supported. + // Upload will start right after selecting images. $('#file-submit').hide(); // Install event handler to notice when files were selected. @@ -50,8 +51,8 @@ upload_form_init = function() { upload_form_files_selected = function() { no_files = this.files.length; if (no_files > 0) { - $('#file-label').html(no_files+" files selected"); - $('#file-select-button').addClass('success'); - $('#file-submit').fadeIn('slow'); + $('#file-label').html(no_files+" files selected - uploading…"); // change label + $('#file-select-button').attr('disabled','disabled'); // disable select button + $('#file-form').submit(); // start upload } }; diff --git a/app/views/packages/upload.slim b/app/views/packages/upload.slim index 03042b5..047ad7b 100644 --- a/app/views/packages/upload.slim +++ b/app/views/packages/upload.slim @@ -21,11 +21,14 @@ - else ' There are no screenshots yet for #{@package.name}. - = form_tag(upload_image_path, multipart: true) + = form_for :screenshot, url: upload_image_path, html: { multipart: true, id: 'file-form' } do |f| + + / = form_tag(upload_image_path, multipart: true, id: 'file-form') .row .small-6.columns - input.hidden-inputfile type="file" name="file" id="file" multiple=true + / input.hidden-inputfile type="file" name="image" id="file" multiple=true + = f.file_field :image, id: 'file', multiple: true, class: 'hidden-inputfile' label for="file" a.button id="file-select-button" = fa_stacked_icon "image", base: "circle-thin"