|
Lines 1-5
Link Here
|
| 1 |
(() => { |
1 |
(() => { |
| 2 |
const DEFAULT_TIMEOUT = 3000; |
2 |
const DEFAULT_TIMEOUT = 3000; |
|
|
3 |
const pendingTimeouts = new WeakMap(); |
| 3 |
|
4 |
|
| 4 |
const toggleButton = element => { |
5 |
const toggleButton = element => { |
| 5 |
const isDisabled = element.hasAttribute("disabled"); |
6 |
const isDisabled = element.hasAttribute("disabled"); |
|
Lines 53-59
Link Here
|
| 53 |
|
54 |
|
| 54 |
requestAnimationFrame(() => { |
55 |
requestAnimationFrame(() => { |
| 55 |
toggleButton(submitter); |
56 |
toggleButton(submitter); |
| 56 |
setTimeout(() => toggleButton(submitter), timeout); |
57 |
const timeoutId = setTimeout( |
|
|
58 |
() => toggleButton(submitter), |
| 59 |
timeout |
| 60 |
); |
| 61 |
pendingTimeouts.set(submitter, timeoutId); |
| 57 |
}); |
62 |
}); |
| 58 |
} |
63 |
} |
| 59 |
}); |
64 |
}); |
|
Lines 64-69
Link Here
|
| 64 |
document |
69 |
document |
| 65 |
.querySelectorAll("[data-throttled-button][disabled]") |
70 |
.querySelectorAll("[data-throttled-button][disabled]") |
| 66 |
.forEach(button => { |
71 |
.forEach(button => { |
|
|
72 |
const timeoutId = pendingTimeouts.get(button); |
| 73 |
if (timeoutId) { |
| 74 |
clearTimeout(timeoutId); |
| 75 |
pendingTimeouts.delete(button); |
| 76 |
} |
| 67 |
toggleButton(button); |
77 |
toggleButton(button); |
| 68 |
}); |
78 |
}); |
| 69 |
} |
79 |
} |
| 70 |
- |
|
|