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:
Pontoporeia
2026-05-07 22:48:18 +02:00
parent ac0008df6c
commit bdd95341b0
13 changed files with 833 additions and 778 deletions

View 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();
}
});
})();