var cestaCarregada = false; var carregando = false; var request = null; var mouseSobreMenu = false; var conteudoCesta = null; $(document).ready(function(){ $.ajaxSetup({ type: "POST" }); $("#input-busca-topo").autocomplete({ source: "/produtoPesquisaAutocomplete.do", delay: 300, minLength: 2, select: function(event, ui) { event.preventDefault(); var item = ui.item; $(this).val(item.value); document.formBuscaTopo.submit(); } }); $('#minha-cesta').mouseover(function(event){ event.preventDefault(); mouseSobreMenu = true; var url = (DIR_THEME == "/" ? "" : DIR_THEME )+"/cestaCompras.do"; var data = {action : "view", actionView : "json2"}; if(!carregando){ if(!cestaCarregada){ carregando = true; $("#carrinho-compras").addClass('ajaxLoader'); request = $.ajax({ url: url, data: data, //dataType: "text", success: function(saida) { conteudoCesta = saida; var html = ""; for(var i=0; i"; html += ""; html += ""; html += "
"; html += item.quantidade+ " item por "; html += "R$ " +item.valorTotal+ ""; html += "
"; html += "
"; html += ""; } $("#menu-compras ul").html(html); if(mouseSobreMenu){ if( conteudoCesta.cesta.itens.length > 0 ) $("#menu-compras").fadeIn(500); } $("#carrinho-compras").removeClass('ajaxLoader'); cestaCarregada = true; carregando = false; request = null; }, error: function(req, textStatus, errorT){ alert(textStatus+" - "+errorT); } }); }else{ if( !$("#menu-compras").is(":visible") && conteudoCesta.cesta.itens.length > 0 ) $("#menu-compras").fadeIn(500); } }else{ $("#carrinho-compras").addClass('ajaxLoader'); } }); $('#minha-cesta').mouseout(function(event){ mouseSobreMenu = false; setTimeout(function(){ if(!mouseSobreMenu){ if(carregando){ $("#carrinho-compras").removeClass('ajaxLoader'); request = null; } if( $("#menu-compras").is(":visible") ) $("#menu-compras").fadeOut(500); } },500); }); $(".ie7 #buscaRodape .botoes-busca").css("position","static"); setTimeout(function(){ $(".ie7 #buscaRodape .botoes-busca").css("position","relative"); },100); $(".ie8 #conteudo-wrapper").css("width","auto"); setTimeout(function(){ $(".ie8 #conteudo-wrapper").css("width","100%"); },100); $(".produtoFoto a").imagensRoller(); });