1$(function(){ 2 3 var $window = $(window); 4 5 // --- mascara 6 var SPMaskBehavior = function(val){ 7 return val.replace(/\D/g,'').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; 8 }, 9 spOptions = { 10 onKeyPress : function(val,e,field,options){ 11 field.mask(SPMaskBehavior.apply({},arguments),options); 12 } 13 }; 14 $('input.telefone').mask(SPMaskBehavior,spOptions); 15 $('input.cnpj').mask('00.000.000/0000-00'); 16 17 // --- contato x curriculo 18 $('#form-contato').ajaxForm({ 19 dataType : 'json', 20 beforeSubmit : function(arr,$form,options){ 21 22 var tipo = $('#tipo'), 23 tipo_contato = $('input[name^=tipo_contato]:checked').val(), 24 nome = $('#nome'), 25 arquivo = $('#arquivo'), 26 empresa = $('#empresa'), 27 cnpj = $('#cnpj'), 28 email = $('#email'), 29 telefone = $('#telefone'), 30 uf = $('#uf'), 31 idcidade = $('#idcidade'), 32 mensagem = $('#mensagem'), 33 retorno = $form.find('.retorno').removeClass('fundo-sucesso').addClass('fundo-erro'); 34 35 if(tipo.val() == 'contato'){ // --- contato 36 if(tipo_contato == undefined){ 37 retorno.html('Selecione o tipo de contato!'); 38 return false; 39 } 40 } 41 42 if(nome.val() == ''){ 43 retorno.html('Preencha seu nome!'); 44 nome.addClass('erro').focus(); 45 return false; 46 } else { 47 nome.removeClass('erro'); 48 } 49 if(tipo.val() == 'contato' && tipo_contato == 'lojista'){ // --- contato 50 if(empresa.val() == ''){ 51 retorno.html('Preencha a empresa!'); 52 empresa.addClass('erro').focus(); 53 return false; 54 } else { 55 empresa.removeClass('erro'); 56 } 57 if(cnpj.val() == ''){ 58 retorno.html('Preencha o CNPJ!'); 59 cnpj.addClass('erro').focus(); 60 return false; 61 } else { 62 cnpj.removeClass('erro'); 63 } 64 if(isCNPJ(cnpj.val()) == false){ 65 retorno.html('O CNPJ inserido é inválido!'); 66 cnpj.addClass('erro').focus(); 67 return false; 68 } else { 69 cnpj.removeClass('erro'); 70 } 71 } 72 if(validaMail(email.val()) == false){ 73 retorno.html('Preencha seu e-mail corretamente!'); 74 email.addClass('erro').focus(); 75 return false; 76 } else { 77 email.removeClass('erro'); 78 } 79 if(telefone.val() == ''){ 80 retorno.html('Preencha seu telefone/WhatsApp!'); 81 telefone.addClass('erro').focus(); 82 return false; 83 } else { 84 telefone.removeClass('erro'); 85 } 86 if(uf.val() == 0){ 87 retorno.html('Selecione o estado!'); 88 uf.addClass('erro').focus(); 89 return false; 90 } else { 91 uf.removeClass('erro'); 92 } 93 if(idcidade.val() == 0){ 94 retorno.html('Selecione a cidade!'); 95 idcidade.addClass('erro').focus(); 96 return false; 97 } else { 98 idcidade.removeClass('erro'); 99 } 100 if(tipo.val() == 'curriculo'){ // --- curriculo 101 if(arquivo.val() == ''){ 102 retorno.html('Selecione o arquivo do seu currÃculo!'); 103 arquivo.addClass('erro').focus(); 104 return false; 105 } else { 106 arquivo.removeClass('erro'); 107 } 108 } 109 if(mensagem.val() == ''){ 110 retorno.html('Escreva sua mensagem!'); 111 mensagem.addClass('erro').focus(); 112 return false; 113 } else { 114 mensagem.removeClass('erro'); 115 } 116 117 if($('input[name^=concordo]').is(':checked') == false){ 118 retorno.html('Você precisa concordar com a polÃtica de privacidade e de termos de uso!'); 119 return false; 120 } 121 122 if($('textarea[name^=g-recaptcha-response]').val() == ''){ 123 retorno.html('à preciso autenticar o captcha para continuar!'); 124 return false; 125 } 126 127 // -- // 128 129 var validate = false; 130 $.ajax({ url:http+'ajax/valida-post/', type:'post', async:false, data: { 'validate' : $('#captcha').val() }, success : function(json){ 131 validate = json.status; 132 }}); 133 134 if(!validate){ 135 retorno.removeClass('sucesso').addClass('erro').html('Não foi possÃvel enviar sua mensagem, por favor atualize a página e tente novamente!'); 136 return false; 137 } 138 139 retorno.html('Enviando...').removeClass('fundo-erro').addClass('fundo-sucesso'); 140 $('#enviar-contato').attr('disabled',true); 141 142 }, 143 success : function(retorno,statusText,xhr,$form){ 144 145 var ok = retorno.ok, 146 msg = retorno.msg; 147 148 if(ok == false){ //erro 149 150 var retorno2 = $form.find('.retorno').removeClass('fundo-sucesso').addClass('fundo-erro'); 151 retorno2.html(msg); 152 153 $form[0].reset(); 154 $('#enviar-contato').attr('disabled',false); 155 156 } else { //sucesso 157 158 if($('#tipo').val() == 'contato'){ // --- contato 159 window.location.href = http + 'contato/sucesso/'; 160 } else { // --- curriculo 161 window.location.href = http + 'curriculo/sucesso/'; 162 } 163 164 //window.location.href = http + 'contato/sucesso/'; 165 166 } 167 } 168 }); 169 170 // --- newsletter 171 $('#form-newsletter').submit(function(evt){ 172 evt.preventDefault(); 173 var $this = $(this), 174 email = $('#email-news'), 175 retorno = $this.find('.retorno'); 176 177 if(validaMail(email.val()) == false){ 178 retorno.html('Preencha seu e-mail corretamente!'); 179 email.addClass('erro').focus(); 180 return false;
181 } else { 182 email.removeClass('erro'); 183 } 184 185 if($('input[name^=concordo]').is(':checked') == false){ 186 retorno.html('Você precisa concordar com a polÃtica de privacidade e de termos de uso!'); 187 return false; 188 } 189 190 var data = $this.serialize(); 191 $.ajax({ url:http+'ajax/newsletter/', type:'POST', data:data, cache:false, success:function(response){ 192 if(response == 'ok'){ 193 retorno.html('E-mail cadastrado com sucesso!'); 194 $this.get(0).reset(); 195 } 196 else if(response == 'cadastrado'){ 197 retorno.html('O e-mail já foi cadastrado anteriormente, aguarde nossas novidades! ;)'); 198 } 199 else { 200 retorno.html('Ocorreu um erro ao cadastrar seu email. Nos informe por telefone para que possamos corrigir o problema!'); 201 } 202 }}); 203 }); 204 205 // --- novidade download 206 $('#form-novidades-download').on('submit',function(evt){ 207 evt.preventDefault(); 208 var $this = $(this), 209 210 idnovidade = $('#idnovidade'), 211 nome = $('#nome'), 212 email = $('#email'), 213 telefone = $('#telefone'), 214 concordo = $('#concordo-novidade-download').is(':checked'), 215 retorno = $this.find('.retorno').removeClass('fundo-sucesso').addClass('fundo-erro'); 216 217 if(!$this.hasClass('enviando')){ 218 219 if(nome.val() == ''){ 220 retorno.html('Preencha seu nome!'); 221 nome.addClass('erro').focus(); 222 return false; 223 } else { 224 nome.removeClass('erro'); 225 } 226 if(validaMail(email.val()) == false){ 227 retorno.html('Preencha o e-mail corretamente!'); 228 email.addClass('erro').focus(); 229 return false; 230 } else { 231 email.removeClass('erro'); 232 } 233 if(telefone.val() == ''){ 234 retorno.html('Preencha seu telefone!'); 235 telefone.addClass('erro').focus(); 236 return false; 237 } else { 238 telefone.removeClass('erro'); 239 } 240 241 if(concordo == false){ 242 retorno.html('Concorda com a polÃtica de privacidade da Supremo Fios?!'); 243 return false; 244 } 245 246 var validate = false; 247 $.ajax({ url: http + 'ajax/valida-post/', async:false, type:'POST', data:{ 'validate' : $this.find('input[name^=captcha]').val() }, success:function(json){ 248 validate = json.status; 249 }}); 250 251 if(!validate){ 252 retorno.removeClass('sucesso').addClass('erro').html('Não foi possÃvel enviar sua mensagem, por favor atualize a página e tente novamente!'); 253 return false; 254 } 255 256 $this.addClass('enviando'); 257 retorno.html('Enviando...').removeClass('fundo-erro').addClass('fundo-sucesso'); 258 259 var data = $this.serialize(); 260 $.ajax({ url : http + 'ajax/novidade-download/', type:'POST', data:data, cache:false, success:function(response){ 261 262 if(response == 'ok'){ 263 264 /* 265 retorno.html('Cadastro realizado com sucesso. Você receberá o link de acesso para o arquivo no seu e-mail!'); 266 retorno.removeClass('fundo-erro').addClass('fundo-sucesso'); 267 $this.get(0).reset(); 268 $this.removeClass('enviando'); 269 */ 270 271 var $protocolo = window.location.protocol + '//', 272 $host = window.location.host, 273 $complemento = window.location.pathname; 274 275 window.location.href = $protocolo + $host + $complemento + 'sucesso/'; 276 277 } else { 278 retorno.html('Ocorreu um erro ao realizar seu cadastro. Nos informe por telefone para que possamos corrigir o problema!').removeClass('fundo-sucesso').addClass('fundo-erro'); 279 $this.removeClass('enviando'); 280 } 281 }}); 282 283 } else { 284 retorno.html('Ainda enviando... aguarde! ;)').removeClass('fundo-erro').addClass('fundo-sucesso'); 285 } 286 }); 287 288});
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.