Skip to content

Commit 3d010d5

Browse files
committed
- Aviso de processando envio de msg
- Ajuste de ícone de whatsapp piscando notificação - ícone whatsapp desaparece quando clica no formulário
1 parent 5410be1 commit 3d010d5

File tree

6 files changed

+177
-72
lines changed

6 files changed

+177
-72
lines changed

app/static/css/main/aniversarios.css

+30-1
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,40 @@
122122
}
123123

124124
/* hidden by default */
125-
.btn--form .sucesso-span {
125+
#sucesso {
126126
display: none;
127127
color: green;
128+
background-color: rgb(205, 251, 216);
129+
font-weight: bold;
130+
padding: 12px 24px;
131+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
132+
margin: 0 20px;
133+
border-radius: 10px;
134+
height: auto;
135+
font-size: 20px;
136+
justify-content: center;
137+
align-items: center;
138+
}
139+
140+
.processando--span {
141+
color: #ff9100;
142+
font-weight: bold;
143+
padding: 12px 24px;
144+
background-color: white;
145+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
146+
margin: 0 20px;
147+
font-size: 20px;
148+
border-radius: 10px;
149+
justify-content: center;
150+
align-items: center;
128151
}
129152

153+
.btn--form span {
154+
justify-content: center;
155+
align-items: center;
156+
}
157+
158+
130159
@media (max-width:855px) {
131160
.grid--aniversarios {
132161
grid-template-columns: 1fr;

app/static/css/main/contacto.css

+33
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,39 @@
5353
font-size: 16px;
5454
}
5555

56+
#sucesso_contacto {
57+
display: none;
58+
color: green;
59+
background-color: rgb(205, 251, 216);
60+
font-weight: bold;
61+
padding: 12px 24px;
62+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
63+
margin: 0 20px;
64+
border-radius: 10px;
65+
height: auto;
66+
font-size: 20px;
67+
justify-content: center;
68+
align-items: center;
69+
}
70+
71+
.processando--span {
72+
color: #ff9100;
73+
font-weight: bold;
74+
padding: 12px 24px;
75+
background-color: white;
76+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
77+
margin: 0 20px;
78+
font-size: 20px;
79+
border-radius: 10px;
80+
justify-content: center;
81+
align-items: center;
82+
}
83+
84+
.btn--form span {
85+
justify-content: center;
86+
align-items: center;
87+
}
88+
5689
@media (max-width:800px) {
5790
#contacto p {
5891
font-size: 16px;

app/static/css/utilidades/utilidades.css

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* Utilidades */
2-
31
@font-face {
42
font-family: "autumn";
53
src: local("Autumn in November"),
@@ -77,7 +75,6 @@ a {
7775
font-display: swap;
7876
}
7977

80-
8178
.junge {
8279
font-family: "Junge", cursive;
8380
font-weight: 400;
@@ -153,7 +150,8 @@ a {
153150
justify-content: center;
154151
width: 60px;
155152
height: 60px;
156-
153+
opacity: 1;
154+
transition: opacity 0.3s;
157155
}
158156

159157
.whatsapp-fixo img {
@@ -165,11 +163,12 @@ a {
165163
border-radius: 100% 100% 100% 8px;
166164
}
167165

168-
.whatsapp-fixo::after {
166+
/* Exibir o ::after apenas quando tiver a classe 'with-notification' */
167+
.whatsapp-fixo.with-notification::after {
169168
content: "1";
170169
position: absolute;
171-
top: 2px;
172-
right: 8px;
170+
top: -5px; /* Ajusta a posição da notificação */
171+
right: -5px;
173172
width: 20px;
174173
height: 20px;
175174
background-color: red;
@@ -181,6 +180,12 @@ a {
181180
justify-content: center;
182181
align-items: center;
183182
animation: blink 0.8s infinite;
183+
z-index: 1000; /* Garante que a notificação fique acima do ícone */
184+
}
185+
186+
/* Esconder o ::after permanentemente após o clique */
187+
.whatsapp-fixo.clicked::after {
188+
display: none;
184189
}
185190

186191
@keyframes blink {
@@ -192,12 +197,11 @@ a {
192197
}
193198
}
194199

195-
196-
.whatsapp-fixo.clicked::after {
197-
display: none;
200+
/* Esconder o ícone ao clicar em inputs */
201+
.whatsapp-fixo.hidden {
202+
opacity: 0; /* O ícone fica invisível */
198203
}
199204

200-
201205
@media (max-width: 1300px) {
202206
.container-1200 {
203207
margin: 0 20px;
@@ -244,4 +248,4 @@ a {
244248
.header-bg {
245249
padding-bottom: 12px;
246250
}
247-
}
251+
}

app/static/js/script.js

+44-14
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,62 @@ document.addEventListener("DOMContentLoaded", function () {
77
});
88
});
99

10-
//form
10+
// Whatsapp Icon
11+
const whatsappIcon = document.querySelector('.whatsapp-fixo');
12+
const inputs = document.querySelectorAll('input, textarea'); // Seleciona inputs e textareas
13+
14+
// Adicionar classe 'with-notification' para exibir a notificação
15+
whatsappIcon.classList.add('with-notification');
16+
17+
// Esconde o ícone quando o usuário clica em qualquer input ou textarea
18+
inputs.forEach(input => {
19+
input.addEventListener('focus', () => {
20+
whatsappIcon.classList.add('hidden'); // Esconde o ícone
21+
});
22+
23+
input.addEventListener('blur', () => {
24+
whatsappIcon.classList.remove('hidden'); // Mostra o ícone novamente
25+
});
26+
});
27+
28+
// Adiciona evento de clique no ícone do WhatsApp
29+
whatsappIcon.addEventListener('click', () => {
30+
whatsappIcon.classList.remove('with-notification'); // Remove a notificação
31+
whatsappIcon.classList.add('clicked'); // Adiciona a classe 'clicked' para remover o ::after permanentemente
32+
});
1133

34+
//form
1235

1336
async function enviarFormulario(suffix = "") {
1437
console.log("Iniciando envio do formulário");
38+
39+
// Seleção dos elementos
1540
const nome = document.getElementById(`nome${suffix}`).value;
1641
const email = document.getElementById(`email${suffix}`).value;
1742
const telemovel = document.getElementById(`telemovel${suffix}`).value;
1843
const mensagem = document.getElementById(`mensagem${suffix}`).value;
44+
const submitBtn = document.querySelector(`.btn`); // Seleciona o botão de envio
45+
const processando = document.getElementById(`processando${suffix}`); // Indicador de "Enviando..."
46+
const sucesso = document.getElementById(`sucesso${suffix}`); // Mensagem de sucesso
1947

48+
// Verificação de campos obrigatórios
2049
if (!nome || !email || !telemovel || !mensagem) {
2150
alert("Todos os campos são obrigatórios!");
2251
throw new Error("Required fields are missing");
2352
}
2453

54+
// Desativar o botão "Enviar" e mostrar "Enviando..."
55+
submitBtn.disabled = true;
56+
processando.style.display = 'inline';
57+
sucesso.style.display = 'none'; // Esconde mensagem de sucesso anterior
58+
59+
// FormData para envio
2560
const formData = new FormData();
2661
formData.append("nome", nome);
2762
formData.append("email", email);
2863
formData.append("telemovel", telemovel);
2964
formData.append("mensagem", mensagem);
3065

31-
const data = document.getElementById(`data${suffix}`);
32-
if (data) {
33-
formData.append("data", data.value);
34-
}
35-
36-
formData.forEach((value, key) => {
37-
console.log(`${key}: ${value}`);
38-
});
39-
4066
try {
4167
const response = await fetch("/enviar-email/", {
4268
method: "POST",
@@ -52,19 +78,23 @@ async function enviarFormulario(suffix = "") {
5278
const result = await response.json();
5379
console.log("Resultado da API:", result);
5480

55-
// clean all inputs on success
81+
// Limpar todos os campos após o envio com sucesso
5682
const inputs = document.querySelectorAll(`.emailform${suffix} input, .emailform${suffix} textarea`);
5783
inputs.forEach(input => {
5884
input.value = '';
5985
});
6086

61-
const sucesso = document.getElementById(`sucesso${suffix}`);
62-
sucesso.style.display = "inline";
63-
sucesso.innerText = result.message;
87+
// Exibir a mensagem de sucesso
88+
sucesso.innerText = result.message || 'Mensagem enviada com sucesso!';
89+
sucesso.style.display = 'inline';
6490

6591
} catch (error) {
6692
console.error("Erro ao enviar o formulário:", error);
6793
alert(`Erro ao enviar o formulário: ${error.message}`);
94+
} finally {
95+
// Reativar o botão "Enviar" e esconder "Enviando..." após o processo
96+
submitBtn.disabled = false;
97+
processando.style.display = 'none';
6898
}
6999
}
70100

app/templates/base.html

+45-40
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
<head>
55
<!-- Google tag (gtag.js) -->
6-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZHRZWGQCF"></script>
7-
<script>
8-
window.dataLayer = window.dataLayer || [];
9-
function gtag(){dataLayer.push(arguments);}
10-
gtag('js', new Date());
11-
12-
gtag('config', 'G-PZHRZWGQCF');
13-
</script>
6+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZHRZWGQCF"></script>
7+
<script>
8+
window.dataLayer = window.dataLayer || [];
9+
function gtag() { dataLayer.push(arguments); }
10+
gtag('js', new Date());
11+
12+
gtag('config', 'G-PZHRZWGQCF');
13+
</script>
1414
<meta charset="UTF-8">
1515
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1616
<meta name="description" content="Conheça o Park Encantado, parque infantil para crianças de 2 a 12 anos com piscina de bolinhas, trampolim, escorregadores e muito mais. O local perfeito para diversão em Viana do Castelo!">
@@ -19,8 +19,8 @@
1919
<link rel="preconnect" href="https://fonts.googleapis.com">
2020
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2121
<link rel="apple-touch-icon" sizes="180x180" href="static/img/apple-touch-icon.png">
22-
<link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png">
23-
<link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon-16x16.png">
22+
<link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png">
23+
<link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon-16x16.png">
2424
<link href="https://fonts.googleapis.com/css2?family=Fredericka+the+Great&display=swap" rel="stylesheet">
2525
<style>
2626
@import url('https://fonts.googleapis.com/css2?family=Beth+Ellen&family=Junge&display=swap');
@@ -32,21 +32,21 @@
3232
<header>
3333
<div class="header-bg">
3434
<div class="header">
35-
{% block header %}
36-
<a href="./" id="logo-img"><img src="static/img/logo.svg" alt="Park Encantado"></a>
37-
<nav aria-label="primaria">
38-
<ul class="header-menu">
39-
<li><a href="{{url_for('index')}}#espaco">O espaço</a></li>
40-
<li><a href="{{url_for('index')}}#aniversarios">Aniversários</a></li>
41-
<li><a href="{{url_for('index')}}#endereco">Localização</a></li>
42-
<li><a href="{{url_for('index')}}#contacto">Contacto</a></li>
43-
</ul>
44-
<a href="{{url_for('index')}}#aniversarios" aria-label="Botão de envio para solicitação de Informações sobre Aniversários" class="btn">Reserve</a>
45-
<div class="hamburger" id="hamburger-menu">
46-
&#9776;
47-
</div>
48-
</nav>
49-
{% endblock %}
35+
{% block header %}
36+
<a href="./" id="logo-img"><img src="static/img/logo.svg" alt="Park Encantado"></a>
37+
<nav aria-label="primaria">
38+
<ul class="header-menu">
39+
<li><a href="{{url_for('index')}}#espaco">O espaço</a></li>
40+
<li><a href="{{url_for('index')}}#aniversarios">Aniversários</a></li>
41+
<li><a href="{{url_for('index')}}#endereco">Localização</a></li>
42+
<li><a href="{{url_for('index')}}#contacto">Contacto</a></li>
43+
</ul>
44+
<a href="{{url_for('index')}}#aniversarios" aria-label="Botão de envio para solicitação de Informações sobre Aniversários" class="btn">Reserve</a>
45+
<div class="hamburger" id="hamburger-menu">
46+
&#9776;
47+
</div>
48+
</nav>
49+
{% endblock %}
5050
</div>
5151
</div>
5252
</header>
@@ -55,7 +55,7 @@
5555
{% block main %}{% endblock %}
5656

5757
{% block contacto %}
58-
58+
5959
{% endblock %}
6060

6161
<!--<section id="regulamento" class="container-1200">
@@ -121,20 +121,25 @@ <h1 class="titulo">regulamento</h1>
121121
%}
122122

123123
<script>
124-
document.addEventListener('DOMContentLoaded', () => {
125-
const inputs = document.querySelectorAll('input, textarea');
126-
const whatsappIcon = document.getElementById('whatsapp-icon');
127-
128-
inputs.forEach(input => {
129-
input.addEventListener('focus', () => {
130-
whatsappIcon.style.display = 'none';
131-
});
132-
input.addEventListener('blur', () => {
133-
whatsappIcon.style.display = 'block';
134-
});
135-
});
136-
});
124+
const whatsappIcon = document.querySelector('.whatsapp-fixo');
125+
const inputs = document.querySelectorAll('input');
126+
127+
// Adiciona evento de foco nos inputs
128+
inputs.forEach(input => {
129+
input.addEventListener('focus', () => {
130+
whatsappIcon.classList.add('hidden'); // Esconde o ícone
131+
});
132+
133+
input.addEventListener('blur', () => {
134+
whatsappIcon.classList.remove('hidden'); // Mostra o ícone novamente
135+
});
136+
});
137+
138+
// Adiciona evento de clique no ícone do WhatsApp
139+
whatsappIcon.addEventListener('click', () => {
140+
whatsappIcon.classList.toggle('clicked'); // Alterna a classe 'clicked'
141+
});
137142
</script>
138143
</body>
139144

140-
</html>
145+
</html>

0 commit comments

Comments
 (0)