PageSourceSearch

https://www.diariodesuzano.com.br/application/themes/diariodesuzano.com.br/js/usuario.js

js diariodesuzano.com.br collected 2026-09-25 00:32:16 UTC 16,370 bytes, 594 lines download raw bytes

1/*
2DIÁRIO DO LITORAL
3*/
4
5
6$(document).ready(function() {
7
8	$(".js_btCadastro").click(function() {
9		$('.js_cadastro1').toggleClass('none');
10		$('.js_cadastro2').toggleClass('none');
11		$('.js_loginContentCadastro').toggleClass('loginContentCadastro');
12	});
13
14	$(".js_esqueci").click(function() {
15		$('.js_senha').toggleClass('none');
16		$('.js_login').toggleClass('none');
17	});
18
19	// FAZ A VALIDAÇAO E SUBMIT DO FORMULARIO DE ATENDIMENTO em (/atendimento/)
20	if(jQuery().validate) {
21		$("#ds_formAtendimento").validate({
22			errorPlacement: function (error, element) {
23				if (element.attr("name")=="assunto"){
24					//$(element).closest('.fsSelect').addClass('error');
25					$(element).addClass('error');
26				}else{
27					$(element).addClass('error');
28				}
29			},
30			rules: {
31				nome: {required: true, minlength: 5},
32				email: {required: true, email:true},
33				assunto: {required: true},
34				mensagem: {required: true},
35				senha: {required: '#checkIdentificar:checked'}
36			},
37			messages: {
38				nome: {required: '' , minlength : ''},
39				email: {required: '', email:'Informe um e-mail válido'},
40				assunto: {required: ''},
41				mensagem: {required: ''},
42				senha: {required: '' }
43			},
44			submitHandler: function(form){
45				// REMOVE TODAS AS CLASSES ERROR CASO HAJA
46				$('#ds_formAtendimento fieldset, #ds_formAtendimento input, #ds_formAtendimento textarea').removeClass('error');
47				$('#ds_formAtendimento input.bt').hide();
48				$('.fsBt').html('<div id="ds_retornoAtendimento"><div class="bt">processando...</div></div>');
49
50				// ENVIA O FORMULARIO
51				$.post('atendimento/enviar_contato/', $(form).serializeArray(), function(data){
52					$('#ds_retornoAtendimento').html(data.msg);
53					$('#ds_formAtendimento input.bt').show();
54
55					if(data.rs == 'sucesso'){
56						window.location = SITE_URL+'atendimento/acompanhamento/'+data.hash;
57					}
58
59					if(data.rs == 'erro_captcha'){
60						$('fieldset.captcha').addClass('error');
61					}
62				}, "json");
63
64				return false;
65			}
66		});
67
68		// ABRE TEXTO DE UMA ITERACAO
69		$('.toggleIteracao').click(function(){
70			var seletor = $(this);
71			seletor.next('.textoBt').show();
72			seletor.find('.dvAberto').hide();
73		});
74
75		// OCULTA TEXTO DE UMA ITERACAO
76		$('.textoBt .ocultarTexto').click(function(){
77			var seletor = $(this).parent('.textoBt');
78			seletor.hide();
79			$(this).closest('.textoHelpDesk').find('.dvAberto').show();
80		});
81
82		// ABRE/OCULTA FORM DE ITERACOES EM atendimento/acompanhamento/
83		$('.dn_ResponderAtendimento').click(function(){
84			$('.textAreaHelpDesk').show();
85		});
86
87		// FECHA UM ATENDIMENTO em atendimento/acompanhamento/
88		$('.dn_FinalizarAtendimento').click(function(){
89			var post = geraObj();
90			post['id'] = $(this).data('id_contato');
91			post['prefixo'] = '';
92
93			$.post('atendimento/fechar/', post, callbackFechaAtendimento, "json");
94		});
95		function callbackFechaAtendimento(data)
96		{
97			flashMessage(data.rs, data.msg);
98			if(data.rs == 'sucesso') 
99				window.location = SITE_URL;//+'cliente/meus-atendimentos/'
100		};
101		
102		// VALIDACAO DO FORMULARIO DE LOGIN
103		// em usuario/login
104		$(".dn_FormLogin").validate({
105			rules: {
106				identity: {required: true, email:true},
107				password: {required: true}
108			},
109			messages: {
110				identity: {required: '', email:'Informe um e-mail válido'},
111				password: {required: '' }
112			},
113			submitHandler: function(form){
114				$('.dn_FormLogin fieldset, .dn_FormLogin input').removeClass('error');
115				$('.dn_FormLogin input.bt').replaceWith('<div class="bt"><img src="'+STATIC_URL+'gfx/preloader-azul.gif" class="preloader1"></div>');
116
117				// ENVIA O FORMULARIO
118				$.post(SITE_URL + 'usuario/logar/', $(form).serializeArray(), function(data){
119					flashMessage(data.rs, data.msg);
120					$('.dn_FormLogin div.bt').replaceWith('<input type="submit" class="bt" alt="" value="Entrar">');
121
122					if(data.rs=='sucesso'){
123						window.location = data.url+'?login='+$(".dn_FormLogin input[name=identity]").val();
124					}else{
125						$("#preloder").css("display", "none");
126						alert(data.msg);
127					}
128					return false;
129				}, "json");
130				return false;
131			}
132		});
133		
134		// VALIDACAO DO FORMULARIO DE CADASTRO
135		$(".dn_FormCadastro").validate({
136			rules: {
137				nome_completo: { required:true },
138				email: { required:true, email:true },
139				senha: { required:true },
140				resenha: { required:true, equalTo:'.ds_senha' },
141				telefone: { required:true },
142				cpf: { required:'.dn_CadFis:checked' },
143				data_nascimento: { required:'.dn_CadFis:checked' },
144				nome_fantasia: { required:'.dn_CadJur:checked' },
145				razao_social: { required:'.dn_CadJur:checked' },
146				cnpj: { required:'.dn_CadJur:checked' },
147				cep: { required:'.dn_CadEnd:checked' },
148				logradouro: { required:'.dn_CadEnd:checked' },
149				numero: { required:'.dn_CadEnd:checked' },
150				bairro: { required:'.dn_CadEnd:checked' },
151				cidade: { required:'.dn_CadEnd:checked' },
152				uf: { required:'.dn_CadEnd:checked' }
153			},
154			messages: {
155				nome_completo: { required:'Informe o seu nome' },
156				email: { required:'Informe o seu e-mail', email:'Informe um e-mail válido' },
157				senha: { required:'Informe a senha' },
158				resenha: { required:'Repita', equalTo:'Repita' },
159				telefone: { required:'Informe seu telefone' },
160				cpf: { required:'Informe seu CPF' },
161				data_nascimento: { required:'Informe' },
162				nome_fantasia: { required:'Informe o Nome Fantasia' },
163				razao_social: { required:'Informe a Razão Social' },
164				cnpj: { required:'Informe o CNPJ' },
165				cep: { required:'Informe o CEP' },
166				logradouro: { required:'Informe o Logradouro' },
167				numero: { required:'Informe o Número' },
168				bairro: { required:'Informe o Bairro' },
169				cidade: { required:'Informe a Cidade' },
170				uf: { required:'Informe a UF' }
171			},
172			errorPlacement: function(error,element){
173				error.insertAfter(element);
174				if($(element).attr('data-erro')=='sim'){
175					$(element).parent("fieldset").find("label[for='"+$(element).attr("id")+"']").addClass($(element).attr('data-classeErro'));
176				}
177			},
178			submitHandler: function(form){
179				$('.dn_FormCadastro fieldset, .dn_FormCadastro input, .dn_FormCadastro textarea').removeClass('error');
180				$('.dn_FormCadastro input.bt').replaceWith('<div class="bt"><img src="'+STATIC_URL+'gfx/preloader-azul.gif" class="preloader1"></div>');
181
182				// ENVIA O FORMULARIO
183				$.post('usuario/cadastrar/', $(form).serializeArray(), function(data){
184					flashMessage(data.rs, data.msg);
185					$('.dn_FormCadastro div.bt').replaceWith('<input type="submit" class="bt" alt="" value="Criar minha Conta">');
186					
187					if(data.rs=='sucesso'){
188						window.location = data.url;
189					}
190				}, "json");
191				return false;
192			}
193		});
194		
195		// TROCA TIPO DE PESSOA: PJ OU PF
196		$('input[name=tipo_pessoa]').on('click',function(){
197			var tipo = $(this).val().toLowerCase();
198			$('.dados_de_pj, .dados_de_pf').addClass('none');
199			$('.dados_de_'+tipo).removeClass('none');
200		});
201		
202		// VALIDACAO DO FORMULARIO DE ATUALIZACAO DE CADASTRO DO USUARIO
203		// /usuario/meu_cadastro/
204		$(".dn_FormAtualizarCadastro").validate({
205			rules: {
206				'dados[nome_completo]': { required:true },
207				'dados[telefone]': { required:true },
208				'dados[cpf]': { required:'.dn_CadFis:checked' },
209				'dados[data_nascimento]': { required:'.dn_CadFis:checked' },
210				'dados[cnpj]': { required:'.dn_CadJur:checked' },
211				'dados[nome_fantasia]': { required:'.dn_CadJur:checked' }
212			},
213			messages: {
214				'dados[nome_completo]': { required:'Informe o seu nome' },
215				'dados[telefone]': { required:'Informe seu telefone' },
216				'dados[cpf]': { required:'Informe seu CPF' },
217				'dados[data_nascimento]': { required:'Informe' },
218				'dados[cnpj]': { required:'Informe seu CNPJ' },
219				'dados[nome_fantasia]': { required:'Informe o nome fantasia' }
220			},
221			submitHandler: function(form){
222				$('.dn_FormAtualizarCadastro fieldset, .dn_FormAtualizarCadastro input').removeClass('error');
223				
224				$('input.btSalvar').hide();
225				$('.loginProcessando').show();
226
227				// ENVIA O FORMULARIO
228				$.post('usuario/alterar_cadastro/', $(form).serializeArray(), function(data){
229					
230					flashMessageTimeOut(data.rs, data.msg);
231					$('input.btSalvar').show();
232					$('.loginProcessando').hide();
233					
234				}, "json");
235				return false;
236			}
237		});
238
239
240		if($('.dn_CepObrigatorio').css('display')){
241			// TROCA CLASSE OBRIGATORIA
242			$('.dn_FormCadastro .dn_CadEnd').on('click',function(){
243				enderecoClasse();
244			});
245
246			enderecoClasse();
247		}
248
249		$('.dn_CadEnd').on('click',function(){
250			if($(this).is(':checked')){
251				$('#div_com_endereco').show();
252			}else{
253				$('#div_com_endereco').hide();
254			}
255		});
256		
257		// VALIDACAO DO FORMULARIO DE ESQUECI MINHA SENHA
258		$(".dn_EsqueciSenha").validate({
259			rules: {
260				email: { required: true, email:true }
261			},
262			messages: {
263				email: { required: '', email:'' }
264			},
265			submitHandler: function(form){
266				$('.dn_EsqueciSenha fieldset, .dn_EsqueciSenha input').removeClass('error');
267				$('.dn_EsqueciSenha input.bt').replaceWith('<div class="bt"><img src="'+STATIC_URL+'gfx/preloader-azul.gif" class="preloader1"></div>');
268
269				// ENVIA O FORMULARIO
270				$.post(SITE_URL+'usuario/esqueci_minha_senha/', $(form).serializeArray(), function(data){
271					flashMessage(data.rs, data.msg);
272					$('.dn_EsqueciSenha div.bt').replaceWith('<input type="submit" class="bt js_btEnviar" alt="" value="Enviar">');
273
274					if(data.rs=='sucesso'){
275						$('.dn_EsqueciSenha input[name=email]').val('');
276					}
277				}, "json");
278				return false;
279			}
280		});
281
282	} // if(jQuery().validate) {
283
284
285
286
287    /**
288    * Esculta o evento on Blur para consulta de CEP
289    * O ID do elemento sera o prefixo do nome do campo para retorno do cep
290    */
291	$('.dnConsultaDadosCorreio').blur(function(){
292		email = $(this).val().trim();
293		if (IsEmail(email)){
294			consultaDadosCorreio(email);
295		}
296	});
297
298	
299	/**
300	* Mostra/oculta a div com o os dados de endereco para o usuario preencher na hora do login
301	* Exemplo em usuario/login/
302	*/
303	$('.dn_FormCadastro input[name="informar_endereco[]"]').change(function(){
304		if(this.checked){
305			$('#div_com_endereco').css("display", "block");;
306		}else{
307			$('#div_com_endereco').css("display", "none");
308		}
309	});
310
311    /** 
312    * QUANDO A PAGINA CARREGAR, ELE VAI VER SE O CHECKBOX PARA INFORMAR O ENDERCO ESTA MARCADO
313    * E MOSTRA OU NAO OS CAMPOS PARA PREENCHIMENTO DE ENDERECO
314    */
315	if ($('.dn_FormCadastro input[name="informar_endereco[]"]').is(':checked')){
316		$('#div_com_endereco').css("display", "block");
317	}else{
318		$('#div_com_endereco').css("display", "none");
319	}
320
321
322
323	/**
324	* Alterna entre dados de PF E PJ
325	* Exemplo em usuario/login/
326	*/
327	$('.dn_FormCadastro input[name=tipo_pessoa]').on('ifChecked',function(e){
328	var parent = $(this).parent().get(0);
329		var checkboxId = parent .getElementsByTagName('input')[0].value;
330		if (checkboxId == 'PJ') {
331			mostra_dados_pj();
332		} else if (checkboxId == 'PF') {
333			mostra_dados_pf();
334		}
335	});
336
337	/** 
338    * QUANDO A PAGINA CARREGAR, ELE VAI CHECAR SE O  CHECKBOX PF OU PF ESTA MARCADO
339    * E MOSTRA OS CAMPOS REALTIVOS A PJ OU PF
340    */
341	if ($('.dn_FormCadastro input[name=tipo_pessoa]').is(':checked')){
342		var valor =  $('input[type=radio][name=tipo_pessoa]:checked').val();
343		if (valor == 'PJ') {
344			mostra_dados_pj();
345		} else if (valor == 'PF') {
346			mostra_dados_pf();
347		}
348	}
349
350    /**
351    * Esculta o evento on Blur para consulta de CEP
352    * O ID do elemento sera o prefixo do nome do campo para retorno do cep
353    */
354	$('.dsConsultaCepOnBlur').blur(function(){
355		cep = $(this).val();
356		prefixo =  $(this).attr('id');
357		consultaEnderecoByCep(cep,prefixo);
358	});
359
360
361
362});//$(document).ready(function() {
363
364
365
366
367
368
369/**
370*
371*/
372function consultaDadosCorreio(email){
373	
374
375	var data = geraObj();
376	
377	data['email'] = email;
378		
379	$('.blankCadastro').css("display", "block");
380	
381	$.post( SITE_URL + 'ce_integracoes/busca_dados_assinante/',data, retornoDadosAssinante, "json");
382
383
384	
385};
386
387
388
389
390
391/**
392* Preenche o formulario de cadastro do usuário, com os dados do leitor
393*
394*	
395*/
396function retornoDadosAssinante(rs){
397
398	$('.blankCadastro').css("display", "none");
399	// PF
400	if (rs.idTipoDePessoa == 1 && rs.rs == 'ok' )
401	{
402		jQuery("#opt1").attr('checked', 'checked');
403		mostra_dados_pf();
404		
405		if (rs.nomeRazaoSocial) { $("input[name=nome_completo]").val( rs.nomeRazaoSocial.trim() ) } ;
406		if (rs.identMF) { $("input[name=cpf]").val( rs.identMF.trim() ).mask("999.999.999-99") } ;
407
408
409		var ndata = normalizaDataNascimento( rs.dataNascimento );
410		if (ndata) { $("input[name=data_nascimento]").val( ndata ) } ;
411	}
412	// PJ 
413	else if (rs.idTipoDePessoa == 2 && rs.rs == 'ok' )
414	{
415
416		jQuery("#opt2").attr('checked', 'checked');
417		mostra_dados_pj();
418
419		if (rs.nomeRazaoSocial) { $("input[name=nome_fantasia]").val( rs.nomeRazaoSocial.trim() ) } ;
420		if (rs.identMF) { $("input[name=cnpj]").val( rs.identMF.trim() ).mask("99.999.999/9999-99") } ;
421		
422
423	}
424
425	if ( rs.rs == 'ok' )
426	{
427
428
429		$("input[name=telefone]").val(''); 
430		$("input[name=celular]").val('');
431
432		var ntel = normalizaTelefone( rs.telefone );
433		var ncel = normalizaTelefone( rs.celular );
434		
435		 
436		if (ntel) { $("input[name=telefone]").val( ntel ).mask("(99) 9999-9999") } ;
437		if (ncel) { $("input[name=celular]").val( ncel ).mask("(99) 9999-9999") } ;
438		
439		if (rs.cep) { $("input[name=cep]").val( rs.cep.trim() ).mask("99.999-999") } ;
440		if (rs.cidade) { $("input[name=cidade]").val( rs.cidade.trim() ) } ;
441		if (rs.endereco) { $("input[name=logradouro]").val( rs.endereco.trim() ) } ;
442		if (rs.complemento) {  $("input[name=complemento]").val( rs.complemento.trim() ) }; 
443		if (rs.numero) {  $("input[name=numero]").val( rs.numero.trim() ) } ;
444		if (rs.bairro) { $("input[name=bairro]").val( rs.bairro.trim() ) } ;
445		if (rs.uf) { $("input[name=uf]").val( rs.uf.trim() ) } ;
446	}
447
448
449}
450
451
452
453/**
454* Normaliza uma data de nascimento 
455*	19/6/2014 -> 19/06/2014
456*   8/6/2014 -> 08/06/2014
457*/
458function normalizaDataNascimento(data)
459{
460
461	if(! data){
462   		return;
463	}
464
465	var mystr = data;
466	var myarr = mystr.split("/");
467
468	if (myarr[0] <= 9)
469		myarr[0] = '0'+myarr[0]
470
471	if (myarr[1] <= 9)
472		myarr[1] = '0'+myarr[1]
473
474	return myarr[0] +'/'+ myarr[1] +'/'+ myarr[2];
475}
476
477/**
478* Normaliza telefone adicionando 67 caso não haja no telefone
479*/
480function normalizaTelefone(telefone) {
481	
482
483	if(! telefone){
484   		return;
485	}
486
487
488	telefone = telefone.replace(/^0+/, '');
489	telefone = telefone.trim();
490
491
492	var ddd = telefone.substring(0, 2);
493		
494
495	if (ddd != '67' )
496		telefone = '67'+telefone;
497
498	
499	//return telefone.mask("(99) 9999-9999");
500	return telefone;
501}
502
503
504
505/**
506* Verifica se é um email
507*/
508function IsEmail(email) {
509  var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
510  return regex.test(email);
511}
512
513
514
515/**
516* Consulta o endereço atraves do CEP informado
517* 
518*/
519function consultaEnderecoByCep(cep,prefixo){
520	
521	var reDigits = /^\d+$/;// EXPRESSAO REGULAR PARA ACEITAR APENAS NUMEROS INTEIROS
522	
523	cep = remove(cep, ".");
524	cep = remove(cep, "-");
525	cep = remove(cep, "/");
526	cep = remove(cep, "_");
527
528	if(cep.length == 8 && reDigits.test(cep)){
529		//$('#'+prefixo+'LoadingCep').show(); 
530		var post = geraObj();
531		post['cep'] = cep;
532		post['prefixo'] = prefixo;
533
534		$.post('correios/consulta_cep/',post, retornoEndereco, "json");
535	}else{
536		limpaEndereco(prefixo);
537	}
538	
539};
540function retornoEndereco(rs){
541	$('#'+prefixo+'LoadingCep').hide(); 
542	
543	if(rs.rs == "ok"){
544		$("input[name="+rs.prefixo+"logradouro]").val(rs.logradouro);
545		$("input[name="+rs.prefixo+"bairro]").val(rs.bairro);
546		$("input[name="+rs.prefixo+"cidade]").val(rs.cidade);
547		$("input[name="+rs.prefixo+"uf]").val(rs.uf);
548	}else{
549		limpaEndereco(rs.prefixo)
550	}
551}
552
553function limpaEndereco(prefixo){
554	$("input[name="+prefixo+"logradouro]").val('');
555	$("input[name="+prefixo+"bairro]").val('');
556	$("input[name="+prefixo+"cidade]").val('');
557	$("input[name="+prefixo+"uf]").val('');
558	$('#'+prefixo+'loader').fadeOut();
559};
560
561
562/**
563* No cadastro do usuario mostra os dados de PF
564* Exemploe em usuario/login/
565*/
566function mostra_dados_pf()
567{
568    $('.dados_de_pj').css("display", "none");
569    $('.dados_de_pf').css("display", "block");
570}
571
572
573
574/**
575* No cadastro do usuario mostra os dados de PJ
576* Exemploe em usuario/login/
577*/
578function mostra_dados_pj()
579{
580	$('.dados_de_pf').css("display", "none");
581	$('.dados_de_pj').css("display", "block");
582}
583
584
585/** FUNCAOO SEMELHANTE A str_replace DO PHP
586*
587*/
588function remove(str, sub) {
589	i = str.indexOf(sub);
590	r = "";
591	if (i == -1) return str;
592	r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
593	return r;
594};

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.