Commit 8b236d91 authored by lauriii's avatar lauriii

Issue #2662932 by Darren Oh, imre.horjan, droplet, nod_, mohit1604, Peter...

Issue #2662932 by Darren Oh, imre.horjan, droplet, nod_, mohit1604, Peter Swietoslawski, swentel: Fix file upload progress bar
parent 19b69fe8
......@@ -65,7 +65,7 @@
attach(context) {
$(context).find('input[type="file"]').once('auto-file-upload').on('change.autoFileUpload', Drupal.file.triggerUploadButton);
},
detach(context, setting, trigger) {
detach(context, settings, trigger) {
if (trigger === 'unload') {
$(context).find('input[type="file"]').removeOnce('auto-file-upload').off('.autoFileUpload');
}
......@@ -88,10 +88,12 @@
$context.find('.js-form-submit').on('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').on('mousedown', Drupal.file.progressBar);
},
detach(context) {
const $context = $(context);
$context.find('.js-form-submit').off('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').off('mousedown', Drupal.file.progressBar);
detach(context, settings, trigger) {
if (trigger === 'unload') {
const $context = $(context);
$context.find('.js-form-submit').off('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').off('mousedown', Drupal.file.progressBar);
}
},
};
......@@ -234,6 +236,7 @@
setTimeout(() => {
$clickedButton.closest('div.js-form-managed-file').find('div.ajax-progress-bar').slideDown();
}, 500);
$clickedButton.trigger('fileUpload');
},
/**
......
......@@ -39,7 +39,7 @@
attach: function attach(context) {
$(context).find('input[type="file"]').once('auto-file-upload').on('change.autoFileUpload', Drupal.file.triggerUploadButton);
},
detach: function detach(context, setting, trigger) {
detach: function detach(context, settings, trigger) {
if (trigger === 'unload') {
$(context).find('input[type="file"]').removeOnce('auto-file-upload').off('.autoFileUpload');
}
......@@ -52,10 +52,12 @@
$context.find('.js-form-submit').on('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').on('mousedown', Drupal.file.progressBar);
},
detach: function detach(context) {
var $context = $(context);
$context.find('.js-form-submit').off('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').off('mousedown', Drupal.file.progressBar);
detach: function detach(context, settings, trigger) {
if (trigger === 'unload') {
var $context = $(context);
$context.find('.js-form-submit').off('mousedown', Drupal.file.disableFields);
$context.find('.js-form-managed-file .js-form-submit').off('mousedown', Drupal.file.progressBar);
}
}
};
......@@ -126,6 +128,7 @@
setTimeout(function () {
$clickedButton.closest('div.js-form-managed-file').find('div.ajax-progress-bar').slideDown();
}, 500);
$clickedButton.trigger('fileUpload');
},
openInNewWindow: function openInNewWindow(event) {
event.preventDefault();
......
......@@ -295,6 +295,10 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
// Add the upload progress callback.
$element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress', ['key' => $upload_progress_key]);
// Set a custom submit event so we can modify the upload progress
// identifier element before the form gets submitted.
$element['upload_button']['#ajax']['event'] = 'fileUpload';
}
// The file upload field itself.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment