feat: Add print functionality and improve layout for various templates
This commit is contained in:
@@ -682,6 +682,29 @@
|
||||
}
|
||||
</style>
|
||||
</footer>
|
||||
<style>
|
||||
/* Print button shared style */
|
||||
.print-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
background: #ffffff;
|
||||
border: 1px solid #ccd5cc;
|
||||
border-radius: 8px;
|
||||
color: #184f57;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
.print-btn.primary {
|
||||
background: linear-gradient(120deg, #286f78 0%, #194f56 100%);
|
||||
color: white;
|
||||
border-color: #184f57;
|
||||
}
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
}
|
||||
</style>
|
||||
<div class="cookie-banner hidden" id="cookieBanner" role="dialog" aria-live="polite" aria-label="Cookie Hinweis">
|
||||
<p>Wir verwenden Cookies, um die Website sicher und benutzerfreundlich zu betreiben. Du kannst auswählen, welche Cookies du erlaubst. Details in <a href="{{ url_for('datenschutz') }}">Datenschutz</a>.</p>
|
||||
<div class="cookie-actions">
|
||||
@@ -899,6 +922,38 @@
|
||||
|
||||
// Run once on load in case user already saved consent
|
||||
applyConsent();
|
||||
// Global print helpers
|
||||
window.printDocument = function () {
|
||||
try { window.print(); } catch (e) { console.error('print error', e); }
|
||||
};
|
||||
|
||||
window.printPdf = function (url) {
|
||||
try {
|
||||
var w = window.open(url, '_blank');
|
||||
if (!w) return;
|
||||
// Attempt to print after load; poll for readyState
|
||||
var attempts = 0;
|
||||
var t = setInterval(function () {
|
||||
attempts++;
|
||||
try {
|
||||
if (w.document && (w.document.readyState === 'complete' || w.document.readyState === 'interactive')) {
|
||||
w.focus();
|
||||
w.print();
|
||||
clearInterval(t);
|
||||
}
|
||||
} catch (err) {
|
||||
// cross-domain or plugin viewer may block access; fallback: focus window and leave to user
|
||||
if (attempts > 8) {
|
||||
clearInterval(t);
|
||||
try { w.focus(); } catch (e) {}
|
||||
}
|
||||
}
|
||||
if (attempts > 30) clearInterval(t);
|
||||
}, 300);
|
||||
} catch (e) {
|
||||
console.error('printPdf error', e);
|
||||
}
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user