mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Extract shared TFE form partial — single source of truth for add/edit/partage
Created templates/partials/form/form.php as the unified form template driven by
$mode ('add'|'edit'|'partage') and boolean flags for optional sections.
The three calling templates (templates/admin/add.php, templates/admin/edit.php,
partage/index.php renderShareLinkForm) now only set variables then include the
shared partial. ~200 lines of duplicated fieldset HTML eliminated.
This commit is contained in:
@@ -75,18 +75,6 @@
|
||||
/* ── Buttons ────────────────────────────────────────────────────────────── */
|
||||
.admin-form-footer {
|
||||
margin-top: var(--space-l);
|
||||
padding-top: var(--space-m);
|
||||
}
|
||||
|
||||
/* Sticky variant — pinned below admin header, top-right */
|
||||
.admin-form-footer--sticky {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
margin: 0 0 var(--space-m);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--space-s);
|
||||
}
|
||||
|
||||
/* ── Admin button aliases — see common.css .btn base class ────────────── */
|
||||
|
||||
@@ -427,6 +427,7 @@ main {
|
||||
.btn--primary {
|
||||
background: var(--accent-primary);
|
||||
color: var(--accent-foreground);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.btn--primary:hover {
|
||||
|
||||
@@ -302,6 +302,10 @@
|
||||
/* ── Submit / form footer ───────────────────────────────────────────────── */
|
||||
.form-footer {
|
||||
margin-top: var(--space-l);
|
||||
margin-bottom: var(--space-l);
|
||||
display: flex;
|
||||
gap: var(--space-s);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-footer button {
|
||||
|
||||
25
app/public/assets/js/beforeunload-guard.js
Normal file
25
app/public/assets/js/beforeunload-guard.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Beforeunload guard — prompts the user before navigating away from unsaved changes.
|
||||
*
|
||||
* Attach to any form with a data-beforeunload-guard attribute.
|
||||
* No effect when JavaScript is unavailable (form posts normally).
|
||||
*/
|
||||
(function () {
|
||||
var forms = document.querySelectorAll('form[data-beforeunload-guard]');
|
||||
if (!forms.length) return;
|
||||
|
||||
var dirty = false;
|
||||
|
||||
for (var i = 0; i < forms.length; i++) {
|
||||
var form = forms[i];
|
||||
form.addEventListener('input', function () { dirty = true; });
|
||||
form.addEventListener('change', function () { dirty = true; });
|
||||
form.addEventListener('submit', function () { dirty = false; });
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', function (e) {
|
||||
if (dirty) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user