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) {
|
function openFileViewer({ url, blob, mime }, filename) {
|
||||||
const isPdf = (mime || '').includes('pdf') || /\.pdf$/i.test(filename);
|
|
||||||
const isImage = (mime || '').startsWith('image/');
|
const isImage = (mime || '').startsWith('image/');
|
||||||
|
|
||||||
if (!isPdf && !isImage) {
|
if (!isImage) {
|
||||||
// Nicht inline anzeigbar → Download anstoßen
|
// Alles außer Bildern: direkt Download
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = filename || 'download';
|
a.download = filename || 'download';
|
||||||
|
|
@ -1805,6 +1804,7 @@ function openFileViewer({ url, blob, mime }, filename) {
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 10000);
|
setTimeout(() => URL.revokeObjectURL(url), 10000);
|
||||||
|
showToast('⬇ ' + escapeHtml(filename || 'Datei') + ' wird heruntergeladen');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1814,12 +1814,9 @@ function openFileViewer({ url, blob, mime }, filename) {
|
||||||
<div class="fs-header">
|
<div class="fs-header">
|
||||||
<button class="icon-btn" id="dv-close">✕</button>
|
<button class="icon-btn" id="dv-close">✕</button>
|
||||||
<div class="fs-title">${escapeHtml(filename || '')}</div>
|
<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>
|
||||||
<div class="dv-body">
|
<div class="dv-body">
|
||||||
${isPdf
|
<img src="${url}" style="max-width:100%;max-height:100%;object-fit:contain;">
|
||||||
? `<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;">`}
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue