Created
August 21, 2012 16:31
-
-
Save patrickmaciel/3417093 to your computer and use it in GitHub Desktop.
teste
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($j) { | |
$j("input#submit_busca") | |
.click( | |
function() { | |
uf_de = $j('#resultado_busca select#uf_de').val(); | |
cidade_de = $j('#resultado_busca select#cidade_de') | |
.val(); | |
uf_para = $j('#resultado_busca select#uf_para').val(); | |
cidade_para = $j('#resultado_busca select#cidade_para') | |
.val(); | |
data = $j('#resultado_busca input.data').val(); | |
error = 0; | |
if (uf_de == 0) { | |
error += 1; | |
} | |
if (cidade_de == 0 || cidade_de == "") { | |
error += 1; | |
} | |
if (uf_para == 0) { | |
error += 1; | |
} | |
if (cidade_para == 0 || cidade_para == "") { | |
error += 1; | |
} | |
if (data == "") { | |
error += 1; | |
} else { | |
hoje = new Date(); | |
dia = hoje.getDate(); | |
mes = hoje.getMonth() + 1; | |
ano = hoje.getFullYear(); | |
if (mes != '11' && mes != '12') { | |
mes = '0' + mes; | |
} | |
// console.log(Date.parse(hoje)); | |
// console.log(Date.parse(parseDate(ano + '-' + mes + '-' + dia))); | |
// dataAtual = Date.parse(hoje); | |
dataAtual = Date.parse(parseDate(ano + '-' + mes + '-' + dia)); | |
// console.log(dataAtual); | |
// console.log(dataAtual); | |
// console.log(dataSelecionada); | |
// dataAtual = dia + mes + ano; | |
// dataAtual = parseInt(dataAtual); | |
// console.log(dataAtual); | |
// dataAtualString = dia + '' + mes + '' + ano; | |
// dataAtualString = parseInt(dataAtualString); | |
// console.log(dataAtualString); | |
// datateste = data.replace(/\//g, '-'); | |
dataar = data.split("/"); | |
dataSelecionada = Date.parse(parseDate(dataar[2] + '-' + dataar[1] + '-' + dataar[0])); | |
// console.log(dataSelecionada); | |
// console.log(dataar[1]); | |
// dataSelecionada = data.replace(/\//g, '-'); | |
// dataSelecionada = parseInt(dataSelecionada); | |
// console.log(dataSelecionada); | |
if (dataSelecionada < dataAtual) { | |
alert('Selecione uma data maior ou igual a hoje.'); | |
return false; | |
} | |
} | |
// alert(error); | |
if (error >= 1) { | |
alert('Todos os campos da pesquisa são obrigatórios e devem ser preenchidos.'); | |
return false; | |
} | |
}); | |
/* | |
* $("#contatoTelefone").bind('click', function() { | |
* if($(this).attr("checked")) { if(!$('#cartaz #telefone').val()) { | |
* alert('Por favor insira um telefone válido'); } } }); | |
* | |
* $("#contatoEmail").bind('click', function() { if($(this).attr("checked")) { | |
* if(!$('#cartaz #email').val()) { alert('Por favor insira um e-mail | |
* válido'); } } }); | |
*/ | |
$("#submit_cartaz").click(function() { | |
error = 0; | |
msg = "Por favor preencha os campo obrigatórios."; | |
if ($("#contatoTelefone").attr("checked")) { | |
if (!$('#cartaz #telefone').val()) { | |
error += 1; | |
msg = msg + "\nTelefone"; | |
} | |
} | |
if ($("#contatoEmail").attr("checked")) { | |
if (!$('#cartaz #email').val()) { | |
error += 1; | |
msg = msg + "\nEmail"; | |
} | |
} | |
if (error >= 1) { | |
alert(msg); | |
return false; | |
} | |
}); | |
// Abre em nova aba links que o atributo rel='external' | |
$j('a[rel="external"]').attr('target', '_blank'); | |
// Abre o modal com o video de explicação | |
$j(".bt_laranja356, li a.como_funciona").click(function() { | |
$j("#modal_video").modal(); | |
return false; | |
}); | |
// Abre o modal com os termos | |
$j("#label_termos").click(function() { | |
$j("#modal_termos").modal(); | |
return false; | |
}); | |
// Abre o modal com os formulario de orçamento | |
$j(".bt-amarelo199").click(function() { | |
$j("#modal_orcamento").modal({ | |
containerId : "orcamento" | |
}); | |
return false; | |
}); | |
// Mostra e esconde a caixa de login | |
$j('.bt-login').click(function() { | |
if ($j(this).hasClass('aberto')) { | |
$j('.topo .login fieldset').css('display', 'none'); | |
$j(this).removeClass('aberto'); | |
} else { | |
$j('.topo .login fieldset').css('display', 'block'); | |
$j(this).addClass('aberto'); | |
} | |
}); | |
// Esconde o estilo padrão dos selects | |
if (!$j.browser.opera) { | |
$j('select.select').each( | |
function() { | |
var title = $j(this).attr('title'); | |
var name = $j(this).attr('name'); // criei | |
if ($j('option:selected', $j(this)).val() != '') | |
title = $j('option:selected', this).text(); | |
$j(this).css({ | |
'z-index' : 10, | |
'opacity' : 0, | |
'-khtml-appearance' : 'none' | |
}) | |
// alterei pra poder receber options por ajax e limpar o | |
// valor | |
// padrao | |
.after( | |
'<span class="select" id="span-' + name + '">' | |
+ title + '</span>').change(function() { | |
var val = $j('option:selected', this).text(); | |
$j(this).next().text(val); | |
}) | |
}); | |
} | |
; | |
// Remove o valor padrão dos inputs de usuario e senha | |
$j('.limpar_valor').click(function() { | |
$(this).val(''); | |
}); | |
// Modifica o formulario conforme o tipo de pessoa | |
$j('input#fisica').click(function() { | |
$j('#form_juridica').css('display', 'none'); | |
$j('#form_fisica').css('display', 'block'); | |
}); | |
$j('input#juridica').click(function() { | |
$j('#form_fisica').css('display', 'none'); | |
$j('#form_juridica').css('display', 'block'); | |
}); | |
}); | |
// carrega options com cidades | |
function cidades(attach, uf) { | |
// fade | |
$("#span-" + attach).fadeTo('fast', 0.5); | |
$.ajaxSetup({ | |
beforeSend : function() { | |
$.blockUI({ | |
message : '<center><h1><span style="font-family:arial;font-size:15px;color:#fff;">Por favor aguarde, carregando cidades</span></h1><p><img src="img/ajax-loader.gif" /></p></center>', | |
css: { | |
border: 'none', | |
padding: '15px', | |
backgroundColor: '#000', | |
'-webkit-border-radius': '10px', | |
'-moz-border-radius': '10px', | |
opacity: .5, | |
color: '#fff' | |
} | |
}); | |
}, | |
complete : function() { | |
setTimeout($.unblockUI, 1000); | |
}, | |
success : function() { | |
} | |
}); | |
// dispara estado | |
$.ajax({ | |
url : "php/classes.php?do=load-cidades&uf=" + uf | |
}) | |
.done(function(msg) { | |
// mostra select | |
$("#span-" + attach).fadeTo('fast', 1); | |
// apaga options | |
$("#" + attach + " option").remove(); | |
// apaga valorpadrao do span | |
$("#span-" + attach).html(''); | |
// coloca | |
$(msg).appendTo("#" + attach); | |
}); | |
} | |
// parse a date in yyyy-mm-dd format | |
function parseDate(input) { | |
var parts = input.match(/(\d+)/g); | |
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]]) | |
return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment