mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #5217 from overleaf/jpa-web-templates-de-ng
[web] de-ng templates module (server-pro) GitOrigin-RevId: 8d2ffd6a109d61b11d6d7c1acb781b429da3891c
This commit is contained in:
parent
01588adec7
commit
471bc70463
2 changed files with 18 additions and 0 deletions
16
services/web/frontend/js/features/fallback-image/index.js
Normal file
16
services/web/frontend/js/features/fallback-image/index.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
function loadingFailed(imgEl) {
|
||||
return imgEl.complete && imgEl.naturalWidth === 0
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-ol-fallback-image]').forEach(imgEl => {
|
||||
function showFallback() {
|
||||
imgEl.src = imgEl.getAttribute('data-ol-fallback-image')
|
||||
}
|
||||
if (loadingFailed(imgEl)) {
|
||||
// The image loading failed before the sprinkle ran.
|
||||
showFallback()
|
||||
} else {
|
||||
// The image loading might fail in the future.
|
||||
imgEl.addEventListener('error', showFallback)
|
||||
}
|
||||
})
|
|
@ -5,6 +5,8 @@ import './features/form-helpers/hydrate-form'
|
|||
import './features/link-helpers/slow-link'
|
||||
import './features/contact-form'
|
||||
import './features/event-tracking'
|
||||
import './features/fallback-image'
|
||||
import './features/multi-submit'
|
||||
|
||||
$('[data-ol-lang-selector-tooltip]').tooltip({ trigger: 'hover' })
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
|
|
Loading…
Reference in a new issue