mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
25 lines
609 B
JavaScript
25 lines
609 B
JavaScript
|
|
||
|
const domContentLoadedCallbacks = [];
|
||
|
// from admin LTE
|
||
|
const onDOMContentLoaded = (callback) => {
|
||
|
if (document.readyState === 'loading') {
|
||
|
// add listener on the first call when the document is in loading state
|
||
|
if (!domContentLoadedCallbacks.length) {
|
||
|
document.addEventListener('DOMContentLoaded', () => {
|
||
|
for (const callback of domContentLoadedCallbacks) {
|
||
|
callback()
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
domContentLoadedCallbacks.push(callback)
|
||
|
} else {
|
||
|
callback()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
export {
|
||
|
onDOMContentLoaded,
|
||
|
}
|