Upload starts automatically when Javascript is enabled

This commit is contained in:
Christoph Haas 2016-08-31 18:08:16 +02:00
parent 52590d866e
commit 4ee670e438
2 changed files with 10 additions and 6 deletions

View file

@ -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
}
};

View file

@ -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"