kopia lustrzana https://github.com/wagtail/wagtail
Progress Controller - add backwards compatible cancelSpinner
- support legacy cancelSpinner global for any other code that may still rely on this - see #10498pull/10425/head
rodzic
a86dddaddf
commit
35de8a98b7
|
@ -168,7 +168,6 @@ module.exports = {
|
|||
files: ['wagtail/**/**'],
|
||||
globals: {
|
||||
buildExpandingFormset: 'readonly',
|
||||
cancelSpinner: 'readonly',
|
||||
escapeHtml: 'readonly',
|
||||
jsonData: 'readonly',
|
||||
ModalWorkflow: 'readonly',
|
||||
|
|
|
@ -3,6 +3,13 @@ import type { Application } from '@hotwired/stimulus';
|
|||
|
||||
const DEFAULT_CLASS = 'button-longrunning';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
/** support legacy cancelSpinner until RemovedInWagtail60 */
|
||||
cancelSpinner: () => void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ability for a button to be clicked and then not allow any further clicks
|
||||
* until the duration has elapsed. Will also update the button's label while in progress.
|
||||
|
@ -45,7 +52,9 @@ export class ProgressController extends Controller<HTMLButtonElement> {
|
|||
|
||||
/**
|
||||
* Ensure we have backwards compatibility with buttons that have
|
||||
* not yet adopted the new data attribute syntax.
|
||||
* not yet adopted the new data attribute syntax. Along with the
|
||||
* global cancelSpinner function to stop all spinners globally.
|
||||
*
|
||||
* Will be removed in a future release.
|
||||
*
|
||||
* @deprecated RemovedInWagtail60
|
||||
|
@ -57,6 +66,14 @@ export class ProgressController extends Controller<HTMLButtonElement> {
|
|||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
window.cancelSpinner = () => {
|
||||
const attr = `data-${identifier}-loading-value`;
|
||||
|
||||
document.querySelectorAll(`[${attr}="true"]`).forEach((element) => {
|
||||
element.removeAttribute(attr);
|
||||
});
|
||||
};
|
||||
|
||||
document
|
||||
.querySelectorAll(
|
||||
`.${DEFAULT_CLASS}:not([${controllerAttribute}~='${identifier}'])`,
|
||||
|
|
Ładowanie…
Reference in New Issue