1// Função responsável por organizar a exibição das categorias no topo. 2// Esta função pega a distancia da primeira categoria até o topo da página e compara com as outras categorias. 3// TODA categoria que não possuir a mesma distancia para o topo igual à primeira, será oculta. 4function verificaQuebraCategoriasTopo(){ 5 //corrige problema .top sem existir elemento 6 if($('.elementoTopo .boxCategorias li').length > 0) { 7 $('.elementoTopo .boxCategorias').each(function(i, obj) { 8 var categoriaTopoDistance = $(this).children('li:first-child').offset().top; 9 $('.elementoTopo .boxCategorias > li').each(function(){ 10 var alturaElementoAtual = $(this).offset().top; 11 12 if ( alturaElementoAtual > categoriaTopoDistance ) 13 { 14 $(this).css('visibility','hidden'); 15 $(this).addClass('itemInvisivel'); 16 $(this).removeClass('itemVisivel'); 17 } 18 else 19 { 20 $(this).css('visibility','visible'); 21 $(this).removeClass('itemInvisivel'); 22 $(this).addClass('itemVisivel'); 23 } 24 }); 25 }); 26 } 27} 28 29//Função responsavel por localizar as duas últimas categorias visÃveis e aplicar a classe que realiza a inversão da exibição das categorias 30function aberturaTopoCategoriaInvertida() 31{ 32 $('.elementoTopo .itemInvisivel').prevAll().removeClass('subCategoriasInvertidas'); 33 34 $('.elementoTopo .itemInvisivel').prevAll().removeClass('subCategoriasInvertidas'); 35 $('.itemVisivel').last().prevAll().removeClass('subCategoriasInvertidas'); 36 $('.itemVisivel').last().addClass('subCategoriasInvertidas'); 37 $('.itemVisivel').last().prev().addClass('subCategoriasInvertidas'); 38 39 $('.itemInvisivel').removeClass('subCategoriasInvertidas'); 40} 41 42$(function(){ 43 // Chamada da função que organiza a exibição das categorias 44 verificaQuebraCategoriasTopo(); 45 aberturaTopoCategoriaInvertida(); 46 $(window).resize(function(){ 47 // Chamada da função que organiza a exibição das categorias 48 verificaQuebraCategoriasTopo(); 49 aberturaTopoCategoriaInvertida(); 50 }); 51 52 //TOPO 5 -> Insere a classe, utilizada na versao mobile, que possui a função de exibir o conteúdo dos menus do topo 53 $('.estiloTopo5').on('click', '.itemMenuTopo', function(a){ 54 $(this).toggleClass('itemMenuTopoAberto'); 55 $(this).siblings('.itemMenuTopo').removeClass('itemMenuTopoAberto'); 56 a.stopPropagation(); 57 58 //TOPO 5 -> Retira a classe de exibição de conteúdo do topo ao clicar fora 59 $('body').on('click', function(){ 60 $('.estiloTopo5 .itemMenuTopo').removeClass('itemMenuTopoAberto'); 61 }); 62 }); 63 64 $('.conteudoMenuTopo').on('click', function(z){ 65 z.stopPropagation(); 66 }); 67 /*$('.estiloTopo5').on('hover', '.boxTopoLogin', function(b){ 68 $(this).addClass('itemMenuTopoAberto'); 69 $(this).siblings('.itemMenuTopo').removeClass('itemMenuTopoAberto'); 70 b.stopPropagation(); 71 }); 72 73 $('.estiloTopo5').on('hover', '.boxTopoCarrinho', function(c){ 74 $(this).siblings('.itemMenuTopo').removeClass('itemMenuTopoAberto'); 75 c.stopPropagation(); 76 });*/ 77 78 //Regras Modal "Esqueci minha senha" 79 $('.iframePopUpEsqueciMinhaSenha').attr('href', BASE_URL + 'login-esqueci_minha_senha/'); 80 $('.iframePopUp:not(.iframePopUpEsqueciMinhaSenha)').magnificPopup({ 81 type: 'iframe' 82 }); 83 84 85 86 $(document).on('load', function(){ 87 88 }); 89 90 //Verifica a altura e largura da imagem e testa se é quadrada. 91 //Caso positivo, ajusta o topo para que o logotipo tenha 200x200 pixels 92 /* 93 var img = $(".imgLogoTopo"); 94 $("<img>").attr("src", $(img).attr("src")).load(function(){ 95 var altura = this.width; 96 var largura = this.height; 97 var subtracao = altura - largura; 98 99 if( subtracao == 0 && altura >= 200 && largura >= 200) 100 { 101 $('.elementoTopo').addClass('logoQuadrado'); 102 }
103 //alert("Original width=" + largura + ", " + "Original height=" + altura); 104 105 }); 106 */ 107}); 108/** 109 * Created by BRUNO on 23/05/17. 110 */ 111 112/*FUNCAO QUE REMOVE ITEM DO CARRINHO PELO TOPO*/ 113 114var topoCarrinhoModule = (function($){ 115 var _removeItemCarrinho = function (value) 116 { 117 var uniqid = value.item.uniqid; 118 119 var confirmFunc = new confirmDialog(function(){ 120 $.ajax({ 121 url: BASE_URL + 'checkout-ajax_excluir_produto_carrinho', 122 data: {uniqid : uniqid }, 123 124 success: function(resp) { 125 console.log(resp); 126 if(resp.sucesso) { 127 topoCarrinho_config.vr_total_preco = resp.sucesso.dados_carrinho.total_produtos.vr_total_preco; 128 topoCarrinho_config.qtd_produto = resp.sucesso.dados_carrinho.total_produtos.qtd_total_prod; 129 topoCarrinho_arr_itens.splice(value.index, 1); 130 if(typeof carrinhoScope !== "undefined") 131 { 132 carrinhoScope.checkout = resp.sucesso; 133 } 134 if($('#btnFrete').length > 0) 135 { 136 $('#btnFrete').click(); 137 } 138 topoCarrinhoatualizaIndicadorQtdCarrinho(); 139 topoCarrinhoatualizaIndicadorPrecoCarrinho(); 140 if(typeof atualiza_resumo_carrinho !== "undefined") 141 { 142 atualiza_resumo_carrinho(); 143 } 144 } 145 }, 146 147 error: function(resp) { 148 console.log(resp); 149 } 150 }) 151 }); 152 confirmFunc.create('Tem certeza que deseja remover este produto?'); 153 }; 154 var _tipoCarrinhoAlteraQuantidadeProduto = function(sucesso) 155 { 156 if(typeof topoCarrinho_config != "undefined" && topoCarrinho_arr_itens != "undefined") { 157 topoCarrinho_config.qtd_produto = sucesso.dados_checkout.dados_carrinho.total_produtos.qtd_total_prod; 158 topoCarrinho_config.vr_total_preco = sucesso.dados_checkout.dados_carrinho.total_produtos.vr_total_preco; 159 160 //ATUALIZA CARRINHO 161 //limpa array 162 topoCarrinho_arr_itens.splice(0, topoCarrinho_arr_itens.length); 163 //atualiza array 164 for(var i=0; i < sucesso.dados_checkout.dados_carrinho.produtos_carrinho.length; i++) 165 { 166 topoCarrinho_arr_itens.push(sucesso.dados_checkout.dados_carrinho.produtos_carrinho[i]); 167 } 168 } 169 170 }; 171 172 return { 173 removeItemCarrinho: function(el, value) { 174 _removeItemCarrinho(value); 175 }, 176 tipoCarrinhoAlteraQuantidadeProduto : function (sucesso) 177 { 178 _tipoCarrinhoAlteraQuantidadeProduto(sucesso); 179 } 180 } 181 182 function topoCarrinhoatualizaIndicadorQtdCarrinho() 183 { 184 if(typeof carrinhoModule !=="undefined") 185 { 186 carrinhoModule.atualizaIndicadorQtdCarrinho(); 187 } 188 } 189 190 function topoCarrinhoatualizaIndicadorPrecoCarrinho() 191 { 192 if(typeof carrinhoModule !== "undefined") 193 { 194 carrinhoModule.atualizaIndicadorPrecoCarrinho(); 195 } 196 197 } 198}); 199 200var triggaEventosCarrinho = function(resp) 201{ 202 if (!resp.hasOwnProperty('sucesso')) return; 203 204 var data = resp.sucesso; 205 if (typeof fbq === 'function' && !data.produto_ja_adicionado) { 206 fbq('track', 'AddToCart', { 207 content_ids: [data.id_loja_produto], 208 content_type: 'product', 209 content_name: data.nome_produto, 210 value: data.vr_preco, 211 currency: 'BRL' 212 }); 213 } 214} 215 216$(function() { 217 topoCarrinhoModule = topoCarrinhoModule; 218}); 219 220 221$(function () { 222 // Exibe o input de busca ao clicar no botão de busca 223 $(document).on("click", ".botaoBuscaCabecalho", function (a) { 224 var valor_busca = $('.elementoTopo .inputBusca').val(); 225 if( valor_busca.length == 0 ) { 226 $(".boxBuscaTopo").show(); 227 $(this).addClass("exibeConteudoTopo"); 228 $('.elementoTopo .inputBusca').focus(); 229 a.stopPropagation(); 230 } 231 }); 232 233 // Impede que a busca seja fechada ao clicar no input 234 $(document).on("click", ".boxBusca", function (b) { 235 b.stopPropagation(); 236 }); 237 238 // Função de clique no corpo do site 239 $(document).on("click", function (a) { 240 //Retira a classe e esconde o input de busca 241 $(".boxBusca").hide(); 242 //Limpa o conteúdo do input da busca 243 $('.inputBuscaCabecalho').val(''); 244 }); 245}); 246 247//Mostrar Login ao passar o mouse 248 249/*$(document).ready(function () { 250 $('.loginTopo').on('mouseover', function () { 251 $('.boxLoginForm', this).show(); 252 }).on('mouseout', function (e) { 253 //Não esconder o login ao clicar no autocompletar do navegador 254 if (!$(e.target).is('input')) { 255 $('.boxLoginForm', this).hide(); 256 } 257 }); 258});*/ 259 260/* Revelar ao descer a página 261 * @author Samuel 262 * 263 */ 264jQuery(document).ready( function($) { 265 var revealClass = '.animated'; 266 var targetClass = '.has-scroll-reveal:not(' + revealClass + ')'; 267 var offset = 50; // Offset from bottom of viewport in pixels. 268 269 var winHeight = $(window).height(); 270
271 // Recalc height of window in case of resize 272 $(window).bind('resizeEnd', function() { 273 winHeight = $(window).height(); 274 }); 275 276 // Fire when page loads 277 triggerAnimation(revealClass, targetClass, offset, winHeight); 278 279 // Also fire on scroll 280 $(window).on('scroll', function() { 281 triggerAnimation(revealClass, targetClass, offset, winHeight); 282 }); // window.on('scroll') 283 284}); // document.ready 285 286function triggerAnimation(revealClass, targetClass, offset, winHeight) { 287 288 // Get current scrollPos 289 var trigger = $(window).scrollTop() + winHeight - offset; 290 291 // Loop through elements we're affecting 292 $(targetClass).each(function() { 293 var elementOffset = $(this).offset().top; 294 295 if( elementOffset < trigger ) { 296 297 $(this).addClass( revealClass.replace('.','') ); 298 } 299 }); 300 301} 302 303/* 304 * ResizeEnd 305 * 306 * Example: 307 * $(window).bind('resizeEnd', function() { 308 * console.log('resize ended 500ms ago'); 309 * }); 310 */ 311$(window).resize(function() { 312 313 if(this.resizeTO) clearTimeout(this.resizeTO); 314 315 this.resizeTO = setTimeout(function() { 316 $(this).trigger('resizeEnd'); 317 }, 500); 318 319}); 320$(function () { 321 // Fecha busca quando click fora 322 $(document).click(function(e) { 323 if (e.target.className != 'boxBuscaExpandida' 324 && e.target.className != 'inputBuscaCabecalho inputBusca') { 325 $(".boxBuscaExpandida").hide(); 326 } 327 }); 328 329 $('.inputBusca').keyup(function () { 330 buscaProdutosModule.buscaProdutos(this.value, this, this); 331 }); 332 333 $('body').on('click', '.buscaProdutosGet', function(){ 334 buscaProdutosModule.buscaProdutosGET($(this).parent().find('.inputBusca').val(), this); 335 //Foca no input, caso não tenha nada digitado 336 if ($(this).closest('.elementoTopo').length) { 337 if( $('.elementoTopo .inputBusca').val().length == 0 ) { 338 $('.elementoTopo .inputBusca').focus(); 339 } 340 } else { 341 if( $(this).parent().find('.inputBusca').val().length == 0 ) { 342 $(this).parent().find('.inputBusca').focus(); 343 } 344 } 345 }); 346 /* 347 $('.buscaProdutosGet').click(function () { 348 buscaProdutosModule.buscaProdutosGET($(this).parent().find('.inputBusca').val(), this); 349 }); 350 */ 351 352 $('.botaoBuscaReduzido').click(function () { 353 buscaProdutosModule.buscaProdutosGET($(this).parent().find('.inputTextBusca').val(), this); 354 }); 355 356 357 $('.inputBusca, .inputTextBusca').keypress(function (e) { 358 if (e.which == 13) { 359 buscaProdutosModule.buscaProdutosGET(this.value, this); 360 } 361 }); 362}); 363function logar(desc_email1,desc_senha,logaMobile,logaTopo) 364{ 365 $.ajax({ 366 url: BASE_URL+"login-ajax_valida_area_login", 367 data: { desc_email1 : desc_email1, desc_senha: desc_senha , cookies_enabled : navigator.cookieEnabled}, 368 type: "post", 369 dataType:"json", 370 success: function(resp) { 371 processandoDialog.remove(); 372 373 if(resp.sucesso) 374 { 375 // Evento do GA4 376 if (typeof LJVTGA4 !== 'undefined') { 377 LJVTGA4.login(); 378 } 379 380 // Ãcone dinâmico do Topo 5 - Topo 7 381 $('.iconeDinamicoLogin').removeClass('icon-unlocked icon-key').addClass('icon-icone_usuariologado_cx_geral'); 382 383 // Topos que possuem o texto "Meus pedidos" - Topo 2, Topo 3 384 $('.loginPedidosDinamico > :first-child').html('Meus pedidos'); 385
386 $('.bem-vindo p:last-child').html(resp.desc_nome); 387 388 // Topos que possuem o "Seja bem vindo, "nome cliente" - Topo 1, Topo 4, Topo 16 389 $('.boxSaudacaoDinamica > span').html(resp.desc_nome); 390 391 okDialogGeral.create('Login efetuado com sucesso. Seja bem vindo!'); 392 393 $('.conteudoAreaLogin').parent().html(resp.sucesso); 394 $('.topoConteudoAreaLoginLjvtv3').parent().html(resp.sucesso_topo_ljvt_v3); 395 396 if(flg_preco_apos_login == "1") { 397 window.location.reload(); 398 } 399 400 $('.erroLogarAreaLogin').css("display","none"); 401 402 if(logaMobile != undefined && logaMobile != null && logaMobile != "") { 403 logaMobile(); 404 } 405 } else { 406 407 408 if(logaTopo == true) { 409 410/* okDialogGeral.create('Login e/ou senha inválidos.'); 411 $('#desc_email1Topo, #desc_senhaTopo').css("border-bottom","1px solid #d52b2e"); 412 $('.okButton a').click(function(){ 413 $('#_customDialog').hide(); 414 $('body').removeClass('_bodydialogModal'); 415 });*/ 416 417 } else { 418 419 console.log(resp); 420 $('.erroLogarAreaLogin').css("display","flex"); 421 $('.containerCampoCaixaLateral .inputTextLateral').css("border-bottom","1px solid #d52b2e"); 422 if (resp == 401) { 423 okDialogGeral.create('Seu cadastro está sob análise. Em breve entraremos em contato.'); 424 $('.erroLogarAreaLogin').html("Cadastro sob análise"); 425 } else { 426 okDialogGeral.create('Login e/ou senha inválidos.'); 427 $('.erroLogarAreaLogin').html("Login e/ou senha inválidos."); 428 } 429 //$('.ajaxOkConteudo .icon-icone_check_modal').addClass('icon-icone_alerta_modal_geral').removeClass('icon-icone_check_modal'); 430 $('.ajaxOkConteudo .icon-icone_check_modal').addClass('icon-icone_alerta_modal_geral fa-triangle-exclamation fa-solid').removeClass('icon-icone_check_modal fa-clipboard-check'); 431 $('.ajaxOkConteudo .icon-icone_alerta_modal_geral').css({'font-size':'40px', 'margin-bottom':'10px', 'text-align':'center', 'color':'#FFA800' }); 432 } 433 } 434 435 if(resp.sucesso_topo) { 436/* $('.boxLoginCarrinhoTopoTema:not(.carrinhoTopo)').replaceWith(resp.sucesso_topo); 437 $('.boxLoginCarrinhoTopoTema').addClass('active');*/ 438 439 } else if(resp.bem_vindo) { 440 $('.bem-vindo').html(resp.bem_vindo); 441 442 } else if(resp.conteudo_minha_conta_mobile) { 443 $('.boxNavegacaoMinhaConta').after(resp.conteudo_minha_conta_mobile); 444 } 445 446 //atualiza_resumo_carrinho(); 447 }, 448 complete: function(){} 449 }); 450 451 return false; 452} 453 454$(function() { 455 456 $('.descEmail1').keyfilter(/[a-z0-9.@_-]/i); 457 $('.descSenha').keyfilter(/^\S*$/i); 458 459 var rules = { 460 desc_email1: { required: true, email: true }, 461 desc_senha: { required: true } 462 }; 463 464 $(".formLogin").each(function() { 465 $(this).validate({ 466 rules: rules, 467 messages: { 468 desc_email1: { 469 required: "Campo e-mail obrigatório", 470 email: "E-mail inválido" 471 }, 472 desc_senha: { 473 required: "Campo senha obrigatório" 474 } 475 }, 476 errorClass: "inputError", 477 errorPlacement: function(error, element) { 478 element.attr("placeholder", error.text()); 479 }, 480 submitHandler: function(form) { 481 // Handle form submission here 482 } 483 }); 484 }); 485 486 // usa trim para eliminar espaços 487 $('.descEmail1').on('keyup mouseup blur', function(){ 488 $(this).val($.trim($(this).val())); 489 $(this).valid(); 490 }); 491 492 //$(".descEmail1, .descSenha").keypress(function(e) { 493 $('.descEmail1, .descSenha').on('keypress', function(e){ 494 if(e.which == 13) { 495 $(this).closest('.boxLogin').find('.botaoEntrarLogin').click(); 496 } 497 }); 498
499 //$('.descEmail1, .descSenha').focusout(function() { 500 $('.descEmail1, .descSenha').on('focusout', function(){ 501 $(this).valid(); 502 }); 503 504 $('.descEmail1, .descSenha').keypress(function(e){ //fazer login quando apertar enter 505 if(e.which == 13){//Enter key pressed 506 $('#botaoEntrarLogin').click();//Trigger search button click event 507 } 508 }); 509 510 511 // verifica se login e senha da caixa lateral estão vazios e/ou incompletos 512 //- Cond 1. Campos vazios -> mostra o erro na validação antes da Função de Login 513 //- Cond 2. Campo de e-mail com erro e senha preenchida ou não -> mostra o erro na validação antes da Função de Login 514 //- Cond 3. Estando os campos corretamente preenchidos, a função de login é chamada 515 //$(".botaoEntrarLogin").click(function(){ 516 $('body').on('click', '.botaoEntrarLogin > input', function(){ 517 $descEmail1 = $(this).closest('section').find('.descEmail1'); 518 $descSenha = $(this).closest('section').find('.descSenha'); 519 520 if( ($descEmail1.val().length == 0) && ($descSenha.val().length == 0)) { 521 $descEmail1.valid(); 522 $descSenha.valid(); 523 } 524 else if( ($descEmail1.hasClass("inputError")) && 525 ($descEmail1.val().length > 0) && 526 ($descSenha.val().length > 0) || 527 ($descSenha.val().length == 0) ){ 528 529 $descEmail1.valid(); 530 $descSenha.valid(); 531 } 532 else { 533 var email = $descEmail1.val(), 534 senha = $descSenha.val(); 535 536 logar(email,senha); 537 } 538 }); 539 540 $(".botaoEntrarLogin").click(function(){ 541 $descEmail1 = $(this).closest('section').find('.descEmail1'); 542 $descSenha = $(this).closest('section').find('.descSenha'); 543 544 if( ($descEmail1.val().length == 0) && ($descSenha.val().length == 0)) { 545 $descEmail1.valid(); 546 $descSenha.valid(); 547 } 548 else if( ($descEmail1.hasClass("inputError")) && 549 ($descEmail1.val().length > 0) && 550 ($descSenha.val().length > 0) || 551 ($descSenha.val().length == 0) ){ 552 553 $descEmail1.valid(); 554 $descSenha.valid(); 555 } 556 else { 557 var email = $descEmail1.val(), 558 senha = $descSenha.val(); 559 560 logar(email,senha); 561 } 562 }); 563 564 565 $(".boxBotaoVerSenhaInput.topoLogin").click(function(){ 566 if ($(this).hasClass('ativo')) { 567 $(this).removeClass('ativo'); 568 $(this).siblings('[name="desc_senha"]').attr('type', 'password'); 569 } else { 570 $(this).addClass('ativo'); 571 $(this).siblings('[name="desc_senha"]').attr('type', 'text'); 572 } 573 }); 574}); 575 576 577$(function() { 578 $('.desc_email_newsletter').keyfilter(/[a-z0-9.@_-]/i); 579 580 // utilizei o "each" no form, para que a validação funcione quando houver mais de um elemento newsletter na loja 581 $('.formNewsletter').each( function(){ 582 var form = $(this); 583 form.validate({ 584 rules: { 585 desc_email_newsletter: { 586 required: true, 587 email: true 588 } 589 }, 590 messages: { 591 desc_email_newsletter: { 592 required: "Campo e-mail obrigatório", 593 email: "E-mail inválido" 594 } 595 }, 596 errorClass: "inputError", 597 errorPlacement: function(error, element) { 598 element.attr("placeholder", error.text()); 599 }, 600 submitHandler: function(form) { 601 602 } 603 }); 604 }); 605 606 /* 607 $(".formNewsletter").validate({ 608 rules: { 609 desc_email_newsletter: { 610 required: true, 611 email: true 612 } 613 }, 614 messages: { 615 desc_email_newsletter: { 616 required: "Campo e-mail obrigatório", 617 email: "E-mail inválido" 618 } 619 }, 620 errorClass: "inputError", 621 errorPlacement: function(error, element) { 622 element.attr("placeholder", error.text()); 623 }, 624 submitHandler: function(form) { 625 626 } 627 }); 628 */ 629 630 $(".botaoCadastrarNewsletterConteudo").click(function(){ 631 632 if (!$(this).parents('.elementoNewsletter').find(".formNewsletter").valid()) 633 { 634 return false;
635 } 636 var desc_email = $(this).parents('.elementoNewsletter').find('.desc_email_newsletter').val(); 637 var elem_newsletter = $(this).parents('.elementoNewsletter'); 638 var acao_email = "I"; 639 if(typeof $(this).parents('.elementoNewsletter').find('input[attr-radio=acao]:checked').val() != "undefined") 640 { 641 acao_email = $(this).parents('.elementoNewsletter').find('input[attr-radio=acao]:checked').val(); 642 } 643 644 $.ajax({ 645 url: BASE_URL+"ajax-ajax_newsletter", 646 data: { desc_email : desc_email, acao: acao_email }, 647 type: "post", 648 dataType:"json", 649 success: function(resp) { 650 if(resp.sucesso) 651 { 652 elem_newsletter.find('.desc_email_newsletter').val(''); 653 $(this).parents('.elementoNewsletter').find('.boxNewsletterDentro').html(resp.sucesso); 654 if(acao_email == 'I') 655 { 656 okDialogGeral.create('E-mail cadastrado com sucesso!'); 657 } 658 else if( acao_email == 'R' ) 659 { 660 okDialogGeral.create('E-mail removido com sucesso!'); 661 } 662 663 if (typeof LJVTGA4 !== 'undefined') { 664 LJVTGA4.generateLead(); 665 } 666 } 667 else 668 if (resp.ja_existe) 669 { 670 okDialogGeral.create("E-mail já cadastrado!"); 671 } 672 else 673 if(resp.nao_encontrado) 674 { 675 okDialogGeral.create("E-mail não encontrado!"); 676 } 677 }, 678 complete: function(){} 679 }); 680 681 return false; 682 }); 683 684 $('.desc_email_newsletter').focusout(function() { 685 $(this).closest('.formNewsletter').valid(); 686 }); 687}); 688 689
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.