document.addEventListener('DOMContentLoaded', function() {
const header = document.getElementById('site-header');
const isProductPage = header.classList.contains('scrolled');
if (header) {
window.addEventListener('scroll', function() {
if (window.scrollY > 20) {
header.setAttribute('data-scrolled', 'true');
} else if (isProductPage === false) {
header.setAttribute('data-scrolled', 'false');
}
});
}
});
document.addEventListener('DOMContentLoaded', function() {
const btn = document.getElementById('language-dropdown-btn');
const menu = document.getElementById('language-dropdown-menu');
const wrapper = document.getElementById('language-dropdown-wrapper');
// Função para alternar o dropdown
btn.addEventListener('click', function() {
// Alterna a visibilidade do menu
menu.classList.toggle('opacity-0');
menu.classList.toggle('invisible');
menu.classList.toggle('-translate-y-2');
});
// Função para fechar o dropdown se o usuário clicar fora dele
document.addEventListener('click', function(event) {
if (!wrapper.contains(event.target)) {
menu.classList.add('opacity-0', 'invisible', '-translate-y-2');
}
});
});
const showNavBar = (action) => {
const header = document.getElementById('site-header');
if (action) {
// BLOQUEIA O SCROLL DA PÁGINA
document.body.classList.add('overflow-hidden');
document.getElementById('navbar').classList.remove('hidden');
document.getElementById('navbar-bg-opacity').classList.remove('hidden');
setTimeout(() => {
document.getElementById('navbar-bg-opacity').classList.remove('opacity-0');
document.getElementById('navbar-bg-opacity').classList.add('opacity-100');
document.getElementById("navbar").classList.remove('-translate-x-full');
document.getElementById("navbar").classList.add('translate-x-0');
document.getElementById("toogleNavbar").onclick = () => showNavBar(false);
document.getElementById("toogleNavbar").setAttribute('data-open', 'true');
header.setAttribute('data-scrolled', 'true');
}, 100);
} else {
// RESTAURA O SCROLL DA PÁGINA
document.body.classList.remove('overflow-hidden');
document.getElementById('navbar-bg-opacity').classList.remove('opacity-100');
document.getElementById('navbar-bg-opacity').classList.add('opacity-0');
document.getElementById("navbar").classList.add('-translate-x-full');
document.getElementById("navbar").classList.remove('translate-x-0');
document.getElementById("toogleNavbar").onclick = () => showNavBar(true);
document.getElementById("toogleNavbar").setAttribute('data-open', 'false');
console.log("window.scrollY", window.scrollY)
if (window.scrollY > 20) {
header.setAttribute('data-scrolled', 'true');
} else {
header.setAttribute('data-scrolled', 'false');
}
setTimeout(() => {
document.getElementById('navbar').classList.add('hidden');
document.getElementById('navbar-bg-opacity').classList.add('hidden');
}, 200);
}
}
window.addEventListener('resize', () => {
if (window.innerWidth >= 1024) {
document.body.classList.remove('overflow-hidden');
}
});
window.addEventListener("DOMContentLoaded", () => {
document.getElementById('woo-search-form').addEventListener('submit', function() {
var catSelect = document.getElementById('woo-category-select');
if (!catSelect.value || catSelect.value === '0') {
catSelect.removeAttribute('name');
}
});
});
document.addEventListener('DOMContentLoaded', () => {
const btn = document.getElementById('btn-ver-mais');
const content = document.getElementById('content-seo');
const MAX_HEIGHT = 144;
function initVerMais() {
if (!content || !btn) return;
// Remove limites temporariamente para medir a altura real do conteúdo
content.style.maxHeight = 'none';
const realHeight = content.scrollHeight;
if (realHeight > MAX_HEIGHT) {
// Se passar de 144px, aplica o limite e mostra o botão
content.style.maxHeight = `${MAX_HEIGHT}px`;
btn.style.display = 'inline-block'; // ou 'block', dependendo do seu layout
btn.textContent = 'Ver mais';
// Usamos um data-attribute para guardar o estado atual
btn.dataset.expanded = 'false';
} else {
// Se não passar de 144px, deixa livre e esconde o botão
content.style.maxHeight = 'none';
btn.style.display = 'none';
}
}
initVerMais();
// Evento de clique no botão
btn.addEventListener('click', () => {
const isExpanded = btn.dataset.expanded === 'true';
if (isExpanded) {
// Ação de VER MENOS (Recolher)
content.style.maxHeight = `${MAX_HEIGHT}px`;
btn.textContent = 'Ver mais';
btn.dataset.expanded = 'false';
} else {
// Ação de VER MAIS (Expandir)
// Usamos o scrollHeight de novo para a animação do CSS saber até onde ir
content.style.maxHeight = `${content.scrollHeight}px`;
btn.textContent = 'Ver menos';
btn.dataset.expanded = 'true';
}
});
// Bônus: Recalcular se a tela mudar de tamanho (responsividade)
window.addEventListener('resize', () => {
// Só recalcula se o texto estiver fechado.
// Se já estiver aberto, não atrapalhamos a leitura do usuário.
if (btn.dataset.expanded !== 'true') {
initVerMais();
}
});
});
document.addEventListener('DOMContentLoaded', () => {
const parentSubmenus = document.querySelectorAll('.menu-header-tex > .menu-item-has-children > .sub-menu');
parentSubmenus.forEach(parentMenu => {
// 1. Armazena a altura original assim que o menu de produtos abre
parentMenu.addEventListener('mouseenter', () => {
if(window.innerWidth >= 1024) {
// Remove qualquer min-height anterior para medir o tamanho natural do pai
parentMenu.style.minHeight = 'auto';
parentMenu.dataset.originalHeight = parentMenu.offsetHeight;
}
});
// Selecionamos TODOS os itens (li) diretos do submenu (Automóvel, Caminhão, etc.)
const allItems = parentMenu.querySelectorAll(':scope > li');
allItems.forEach(item => {
item.addEventListener('mouseenter', () => {
if(window.innerWidth >= 1024) {
// RESET: Antes de qualquer coisa, volta o pai para a altura original
const originalH = parentMenu.dataset.originalHeight;
parentMenu.style.minHeight = originalH + 'px';
// Agora, se ESTE item específico tiver um submenu, checamos se precisa expandir
const childMenu = item.querySelector('.sub-menu');
if (childMenu) {
// Pequeno delay para o CSS aplicar o display: grid/flex
setTimeout(() => {
const childHeight = childMenu.scrollHeight;
const currentParentHeight = parseInt(originalH);
if (childHeight > currentParentHeight) {
parentMenu.style.minHeight = `${childHeight}px`;
}
}, 10);
}
}
});
});
// Limpa tudo ao fechar o menu de produtos
parentMenu.addEventListener('mouseleave', () => {
if(window.innerWidth >= 1024) {
parentMenu.style.minHeight = 'auto';
}
});
});
});
document.addEventListener('DOMContentLoaded', () => {
// Seleciona todos os itens de menu que possuem um submenu
const dropdownItems = document.querySelectorAll('.menu-header-mobile-tex .menu-item-has-children');
dropdownItems.forEach(item => {
const link = item.querySelector('a');
const subMenu = item.querySelector('.sub-menu');
// 1. Prepara o submenu (esconde por padrão e adiciona classes do Tailwind)
// Ajuste o padding (pl-4) conforme o design do seu Figma
subMenu.classList.add('hidden', 'flex-col', 'gap-y-2', 'pl-2', 'mt-4');
// 2. Prepara o link principal (transforma em flex para alinhar a seta)
link.classList.add('flex', 'items-center', 'justify-between', 'w-full');
// 3. Cria o ícone da seta (SVG)
const arrowBtn = document.createElement('button');
arrowBtn.className = 'p-1 transition-transform duration-300 rotate-180 transform';
arrowBtn.innerHTML = `
`;
// Insere a seta dentro do link principal
link.appendChild(arrowBtn);
// 4. Lógica de clique para abrir/fechar
link.addEventListener('click', (e) => {
// Previne que a página recarregue se o link principal for apenas um título vazio (ex: href="#")
if (link.getAttribute('href') === '#' || link.getAttribute('href') === '') {
e.preventDefault();
}
subMenu.classList.toggle('hidden');
subMenu.classList.toggle('flex');
arrowBtn.classList.toggle('rotate-180');
});
});
});
function clearSearch() {
const searchInput = document.getElementById('search-input');
if (searchInput) {
searchInput.value = '';
searchInput.focus();
}
}
new Swiper('.swiper-brands-carousel', {
slidesPerView: 2,
spaceBetween: 20,
navigation: {
nextEl: '.swiper-button-next-brands-carousel',
prevEl: '.swiper-button-prev-brands-carousel',
},
pagination: {
el: '.swiper-pagination-brands-carousel',
clickable: true,
},
breakpoints: {
768: {
slidesPerView: 3,
},
1024: {
slidesPerView: 5,
}
}
});
https://texaco.wicomm.com.br/wp-sitemap-posts-post-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-posts-page-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-posts-product-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-posts-distribuidor-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-posts-catalogos-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-taxonomies-category-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-taxonomies-product_cat-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-taxonomies-pais-1.xmlhttps://texaco.wicomm.com.br/wp-sitemap-users-1.xml