2021-09-21 13:47:09 +00:00
|
|
|
import { inflightHelper } from '../form-helpers/hydrate-form'
|
2021-09-27 10:45:04 +00:00
|
|
|
import { disableElement } from '../utils/disableElement'
|
2021-09-21 13:47:09 +00:00
|
|
|
|
|
|
|
function setup(el) {
|
2021-09-27 10:45:04 +00:00
|
|
|
// Make the element discoverable for multi-submit.
|
|
|
|
el.setAttribute('data-ol-disabled-inflight', '')
|
|
|
|
|
2021-09-21 13:47:09 +00:00
|
|
|
inflightHelper(el)
|
|
|
|
el.addEventListener('click', function () {
|
2021-09-27 10:45:04 +00:00
|
|
|
disableElement(el)
|
2021-09-21 13:47:09 +00:00
|
|
|
el.dispatchEvent(new Event('pending'))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
document.querySelectorAll('[data-ol-slow-link]').forEach(setup)
|