Fix: PDFs + Dokumente direkt zum Download (kein problematischer iframe) [deploy]
All checks were successful
Deploy baustelle-pwa / deploy (push) Successful in 4s
All checks were successful
Deploy baustelle-pwa / deploy (push) Successful in 4s
This commit is contained in:
parent
a538dbb744
commit
a192cbfa27
1 changed files with 4 additions and 7 deletions
11
app.js
11
app.js
|
|
@ -1793,11 +1793,10 @@ function formatShortDate(ts) {
|
|||
}
|
||||
|
||||
function openFileViewer({ url, blob, mime }, filename) {
|
||||
const isPdf = (mime || '').includes('pdf') || /\.pdf$/i.test(filename);
|
||||
const isImage = (mime || '').startsWith('image/');
|
||||
|
||||
if (!isPdf && !isImage) {
|
||||
// Nicht inline anzeigbar → Download anstoßen
|
||||
if (!isImage) {
|
||||
// Alles außer Bildern: direkt Download
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename || 'download';
|
||||
|
|
@ -1805,6 +1804,7 @@ function openFileViewer({ url, blob, mime }, filename) {
|
|||
a.click();
|
||||
a.remove();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 10000);
|
||||
showToast('⬇ ' + escapeHtml(filename || 'Datei') + ' wird heruntergeladen');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1814,12 +1814,9 @@ function openFileViewer({ url, blob, mime }, filename) {
|
|||
<div class="fs-header">
|
||||
<button class="icon-btn" id="dv-close">✕</button>
|
||||
<div class="fs-title">${escapeHtml(filename || '')}</div>
|
||||
<a class="icon-btn" id="dv-download" title="Herunterladen" download="${escapeHtml(filename || 'download')}" href="${url}">⬇</a>
|
||||
</div>
|
||||
<div class="dv-body">
|
||||
${isPdf
|
||||
? `<iframe src="${url}" style="width:100%;height:100%;border:0;background:#fff;"></iframe>`
|
||||
: `<img src="${url}" style="max-width:100%;max-height:100%;object-fit:contain;">`}
|
||||
<img src="${url}" style="max-width:100%;max-height:100%;object-fit:contain;">
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(modal);
|
||||
|
|
|
|||
Loading…
Reference in a new issue