chore(release): static site deploy (sitio-estatico)

This commit is contained in:
Andres Santana
2026-09-25 13:13:22 -04:00
commit 132e3f4731
9 changed files with 1414 additions and 0 deletions
+151
View File
@@ -0,0 +1,151 @@
/* ===== VALEA Inversiones — Scripts estáticos ===== */
(function () {
'use strict';
/* ---------- Mobile navigation ---------- */
var toggle = document.querySelector('.nav-toggle');
var mobile = document.querySelector('.nav-mobile');
if (toggle && mobile) {
toggle.addEventListener('click', function () {
mobile.classList.toggle('open');
var icon = toggle.querySelector('svg');
if (mobile.classList.contains('open')) {
icon.innerHTML = '<line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>';
} else {
icon.innerHTML = '<line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line>';
}
});
mobile.querySelectorAll('a').forEach(function (a) {
a.addEventListener('click', function () { mobile.classList.remove('open'); });
});
}
/* ---------- Active nav link ---------- */
var path = window.location.pathname.split('/').pop() || 'index.html';
document.querySelectorAll('[data-nav]').forEach(function (link) {
if (link.getAttribute('data-nav') === path) link.classList.add('active');
});
/* ---------- Scroll reveal ---------- */
var reveals = document.querySelectorAll('.reveal');
if ('IntersectionObserver' in window && reveals.length) {
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
io.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
reveals.forEach(function (el) { io.observe(el); });
} else {
reveals.forEach(function (el) { el.classList.add('visible'); });
}
/* ---------- Toast ---------- */
function showToast(title, desc, type) {
var vp = document.querySelector('.toast-viewport');
if (!vp) {
vp = document.createElement('div');
vp.className = 'toast-viewport';
document.body.appendChild(vp);
}
var t = document.createElement('div');
t.className = 'toast ' + (type || 'success');
t.innerHTML =
'<div><div class="toast-title"></div><div class="toast-desc"></div></div>' +
'<button class="toast-close" aria-label="Cerrar"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>';
t.querySelector('.toast-title').textContent = title;
t.querySelector('.toast-desc').textContent = desc || '';
vp.appendChild(t);
var close = function () {
t.style.transition = 'opacity .3s, transform .3s';
t.style.opacity = '0';
t.style.transform = 'translateX(100%)';
setTimeout(function () { if (t.parentNode) t.parentNode.removeChild(t); }, 300);
};
t.querySelector('.toast-close').addEventListener('click', close);
setTimeout(close, 5000);
}
window.valeaToast = showToast;
/* ---------- Contact form ---------- */
var form = document.getElementById('contact-form');
if (form) {
var fields = ['nombre', 'email', 'telefono', 'empresa', 'asunto', 'mensaje'];
var data = {};
fields.forEach(function (f) { data[f] = ''; });
function setError(name, msg) {
var input = form.querySelector('[name="' + name + '"]');
var errEl = form.querySelector('[data-error="' + name + '"]');
if (input) input.classList.toggle('error', !!msg);
if (errEl) errEl.textContent = msg || '';
}
function validate() {
var ok = true;
if (!data.nombre.trim()) { setError('nombre', 'El nombre es requerido'); ok = false; } else setError('nombre', '');
if (!data.email.trim()) { setError('email', 'El email es requerido'); ok = false; }
else if (!/^\S+@\S+\.\S+$/.test(data.email)) { setError('email', 'Email inválido'); ok = false; } else setError('email', '');
if (!data.telefono.trim()) { setError('telefono', 'El teléfono es requerido'); ok = false; } else setError('telefono', '');
if (!data.asunto.trim()) { setError('asunto', 'El asunto es requerido'); ok = false; } else setError('asunto', '');
if (!data.mensaje.trim()) { setError('mensaje', 'El mensaje es requerido'); ok = false; } else setError('mensaje', '');
return ok;
}
fields.forEach(function (name) {
var input = form.querySelector('[name="' + name + '"]');
if (input) {
input.addEventListener('input', function () {
data[name] = input.value;
if (input.classList.contains('error')) setError(name, '');
});
}
});
form.addEventListener('submit', function (e) {
e.preventDefault();
fields.forEach(function (name) {
var input = form.querySelector('[name="' + name + '"]');
if (input) data[name] = input.value;
});
if (!validate()) {
showToast('Error de validación', 'Por favor complete todos los campos requeridos.', 'error');
return;
}
var btn = form.querySelector('button[type="submit"]');
var original = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:.5rem;animation:spin 1s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"></path></svg> Enviando...';
// Alternativa funcional sin backend: abrir el cliente de correo del usuario
// con todos los datos del formulario ya rellenados.
setTimeout(function () {
var subject = encodeURIComponent(data.asunto || 'Consulta desde la web VALEA Inversiones');
var body = encodeURIComponent(
'Nombre: ' + data.nombre + '\n' +
'Email: ' + data.email + '\n' +
'Teléfono: ' + data.telefono + '\n' +
(data.empresa ? 'Empresa: ' + data.empresa + '\n' : '') +
'\nMensaje:\n' + data.mensaje
);
var mailto = 'mailto:valeainversiones@gmail.com?subject=' + subject + '&body=' + body;
showToast('¡Mensaje listo para enviar!', 'Se abrirá su cliente de correo. Si no se abre, escríbanos a valeainversiones@gmail.com', 'success');
btn.disabled = false;
btn.innerHTML = original;
form.reset();
fields.forEach(function (f) { data[f] = ''; });
// Intentar abrir el cliente de correo
try { window.location.href = mailto; } catch (err) {}
}, 1200);
});
}
})();
/* spinner keyframe injected */
var style = document.createElement('style');
style.textContent = '@keyframes spin{to{transform:rotate(360deg)}}';
document.head.appendChild(style);