Aggiunge menu lingua dropdown e base i18n IT/EN/TH.
Introduce routing multilingua con locale tailandese, selettore lingua a tendina con icone bandiera SVG e gestione chiusura click-outside/Esc, oltre a integrazione Turnstile lato form contatti. Made-with: Cursor
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
interface ContactFormCfg {
|
||||
actionUrl: string;
|
||||
mailto: string;
|
||||
turnstileSiteKey: string;
|
||||
notifySubject: string;
|
||||
successRedirect: string;
|
||||
fieldName: string;
|
||||
@ -18,6 +19,7 @@ function readCfg(): ContactFormCfg {
|
||||
return {
|
||||
actionUrl: '',
|
||||
mailto: '',
|
||||
turnstileSiteKey: '',
|
||||
notifySubject: '',
|
||||
successRedirect: '',
|
||||
fieldName: 'name',
|
||||
@ -39,6 +41,23 @@ function bind(): void {
|
||||
const err = document.getElementById('nx-contact-form-error');
|
||||
if (err) err.classList.add('hidden');
|
||||
|
||||
const hasTurnstile =
|
||||
typeof cfg.turnstileSiteKey === 'string' && cfg.turnstileSiteKey.length > 0;
|
||||
if (cfg.actionUrl && hasTurnstile) {
|
||||
const token = form.querySelector<HTMLInputElement>(
|
||||
'input[name="cf-turnstile-response"]',
|
||||
)?.value;
|
||||
if (!token) {
|
||||
e.preventDefault();
|
||||
if (err) {
|
||||
err.textContent =
|
||||
'Completa il controllo anti-spam prima di inviare il messaggio.';
|
||||
err.classList.remove('hidden');
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.actionUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user