diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js index c933cd1fb73b76a6044a76a6b7c4f88e600995b9..dfbe420353bb36bf81696de6c51aab718aa18191 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js @@ -33,12 +33,13 @@ var setFormValueOpenBrowser, // @deprecated define(['jquery', 'TYPO3/CMS/Backend/FormEngineValidation', 'TYPO3/CMS/Backend/DocumentSaveActions', + 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Utility/MessageUtility', 'TYPO3/CMS/Backend/Severity', 'TYPO3/CMS/Backend/BackendException', 'TYPO3/CMS/Backend/Event/InteractionRequestMap' -], function($, FormEngineValidation, DocumentSaveActions, Modal, MessageUtility, Severity, BackendException, InteractionRequestMap) { +], function($, FormEngineValidation, DocumentSaveActions, Icons, Modal, MessageUtility, Severity, BackendException, InteractionRequestMap) { /** * @param {InteractionRequest} interactionRequest @@ -598,6 +599,25 @@ define(['jquery', FormEngine.openPopupWindow(mode, params); }); + document.editform.addEventListener('submit', function () { + const elements = [ + 'button[form]', + 'button[name^="_save"]', + 'a[data-name^="_save"]', + 'button[name="CMD"][value^="save"]', + 'a[data-name="CMD"][data-value^="save"]', + ].join(','); + + const button = document.querySelector(elements); + if (button !== null) { + button.disabled = true; + + Icons.getIcon('spinner-circle-dark', Icons.sizes.small).then(function (markup) { + button.querySelector('.t3js-icon').outerHTML = markup; + }); + } + }); + window.addEventListener('message', FormEngine.handlePostMessage); }; @@ -1291,14 +1311,27 @@ define(['jquery', */ FormEngine.closeDocument = function() { document.editform.closeDoc.value = 1; + + FormEngine.dispatchSubmitEvent(); document.editform.submit(); }; FormEngine.saveDocument = function() { document.editform.doSave.value = 1; + + FormEngine.dispatchSubmitEvent(); document.editform.submit(); }; + /** + * Dispatches the "submit" event to the form. This is necessary if .submit() is called directly. + */ + FormEngine.dispatchSubmitEvent = function() { + const submitEvent = document.createEvent('Event'); + submitEvent.initEvent('submit', false, true); + document.editform.dispatchEvent(submitEvent); + }; + /** * Main init function called from outside *