var restrict = { /* * This options will be overrided in setTitle (if needed) * They will hold some options for each page. */ options: { maskEnabled: true, mask: '99999999999999999', maskPrefix: '', loginLabelPrefix: 'Nº do cartão' }, init: function() { this.corners(); this.setContent(); this.login.init(); this.resetPassword(); this.changePassword.init(); }, setContent : function(){ var holder = '#wrapper-content'; var target = $("#login_tipo").val(); var title = $('> h3:first-child', '#box-area-access div.details'); var online_services = $('#services-online', holder); online_services.addClass(target); switch(target) { case 'particular': title.html('Acesso - Cliente Plano Particular'); online_services.show(); $('#box-area-access #register-call').add('#box-area-access .forgotten-password').show(); break; case 'empresarial': title.html('Acesso - Cliente Plano Empresarial'); online_services.show(); $('.forgotten-password').show(); $('#box-area-access #register-call').show(); <<<<<<< HEAD restrict.options.loginLabelPrefix = 'Número do Contrato'; ======= restrict.options.loginLabelPrefix = 'Número do contratos'; >>>>>>> ea1468e6c2d97119c8cdb6a4a71d2bd92a4a3600 break; case 'corretores': title.html('Acesso - Corretores'); online_services.show(); $('.forgotten-password').show(); $('.icon1', online_services).text('Consulta Comissões'); $('.icon2', online_services).text('Consulta Inadimplências'); $('.icon3', online_services).text('Demonstrativo Analítico'); $('.icon4', online_services).text('Extrato Produtor'); $('div.extra > div.opme, .corretores').show(); helpers.listFx( $('> ul', '#downloads.corretores') ); $('div.extra > section, .corretores').cornerz( { radius : 6, background : '#f8f8e9' } ); //$('#box-area-access #register-call').hide(); /* * Corretores uses a special numbering schema. Overwrite the mask */ restrict.options.loginLabelPrefix = 'Login'; restrict.options.mask = 'aaa99999'; restrict.options.maskPrefix = ''; break; case 'redemedica': title.html('Acesso - Rede Médica'); $('.forgotten-password').show(); //$('#box-area-access #register-call').hide(); online_services.show(); $('.icon1', online_services).text('Materiais e Medicamentos'); $('.icon2', online_services).text('Extrato de Pagamento'); $('.icon3', online_services).text('Controle de Acesso'); $('.icon4', online_services).text('Solicitação de Autorização'); $('div.extra > div.opme').show(); //cornerz $('div.extra > section, #downloads.redemedica').cornerz( { radius : 6, background : '#f8f8e9' } ); restrict.options.loginLabelPrefix = 'Usuário'; restrict.options.maskEnabled = false; restrict.options.maskPrefix = ''; break; case 'medicocooperado': title.html('Acesso - Médico Cooperado'); $('#box-area-access form #input-card').val('Código'); online_services.show(); $('#box-area-access #register-call').add('#box-area-access .forgotten-password').show(); restrict.options.loginLabelPrefix = 'Código'; restrict.options.maskPrefix = ''; break; case 'colaborador': //$('#box-area-access #register-call').hide(); $('.forgotten-password').show(); title.html('Acesso - Sistema Unimed'); $('#downloads.colaborador, #contact').show(); helpers.listFx( $('> ul', '#downloads.colaborador') ); $( '#contact' ).cornerz( { radius : 6, corners : 'tl tr bl', background : '#f8f8e9' } ); $( '#downloads.colaborador' ).cornerz( { radius : 6, background : '#f8f8e9' } ); /* * Sistema Unimed uses a special numbering schema. Disable maskering */ restrict.options.maskEnabled = false; restrict.options.maskPrefix = ''; break; } }, login : { init : function(){ var self = this; // Masking input (if necessary) var login_input = $('#box-area-access form #input-card'); login_input = (restrict.options.maskEnabled ? login_input.setMask( restrict.options.mask) : login_input ); // Set the appropriate on/off behaviour login_input.val( restrict.options.loginLabelPrefix ).focusin( function() { $( this ).val( restrict.options.maskPrefix ); } ).focusout( function() { if( $( this ).val() == restrict.options.maskPrefix ) $( this ).val( restrict.options.loginLabelPrefix ); }); /* $( '#box-area-access form #input-pass' ).focusin( function() { helpers.text2password( $(this).get(0) ); } ); */ $('#box-area-access form').submit(function() { self.validate(); return false; }); }, validate : function(){ var form = $('#box-area-access form'); if( $('#input-card', form).val() == 'Nº da cartão'){ helpers.errorAlert( $('#box-area-access'), 'Número do cartão está incorreto.'); } else if( $('#input-pass', form).val().length < 1 /*|| $('#input-pass', form).val() == 'Senha'*/){ helpers.errorAlert( $('#box-area-access'), 'Preencha corretamente sua senha.'); } else { this.sendData(); } }, sendData : function(){ var fx_wait = helpers.errorAlert( $('#box-area-access form'), 'Aguarde...', {'bgcolor':'#d3d3c3', 'color':'#3c493e', 'cornerzColor': '#ebebdd', 'autoFadeOut': false, 'animTime':0}); var form = $('#box-area-access form'); url = form.attr('action'); data = { cartao: $("#input-card", form).val(), senha: $("#input-pass", form).val() } $.ajax({ url: url, data: data, type: 'POST', success: function(data) { window.location = '/area-exclusiva' }, error: function(request){ helpers.errorAlert( $('#box-area-access form'), 'Dados incorretos.', {'cornerzColor': '#ebebdd'}); } }); return false; } }, resetPassword : function () { // Chamar a modal que está em helpers.js $('#form-login .forgotten-password a').bind('click', function() { helpers.openModal( $( this ).attr( 'href' ), helpers.popForgotPassword.onLoadPop, {w:410, h:310}); return false; }); }, changePassword : { init : function() { var self = this; $('#update_pass').bind('click', function() { self.validate(); return false; }); }, validate : function () { if ($('#senha_atual').val().length < 3) { helpers.errorAlert( $('#restrito .details'), 'Digite a senha atual'); $('#senha_atual').focus(); } else if ($('#nova_senha').val().length < 3) { helpers.errorAlert( $('#restrito .details'), 'Digite a nova senha'); $('#nova_senha').focus(); } else if ($('#senha_confirma').val().length < 3) { helpers.errorAlert( $('#restrito .details'), 'Digite a confirmação da nova senha.'); $('#senha_confirma').focus(); } else if ($('#nova_senha').val() != $('#senha_confirma').val()) { helpers.errorAlert( $('#restrito .details'), 'As senhas não conferem.'); } else { this.sendData(); } }, sendData : function () { var fx_wait = helpers.errorAlert( $('#restrito .details'), 'Aguarde...', {'bgcolor':'#d3d3c3', 'color':'#3c493e', 'cornerzColor': '#ebebdd', 'autoFadeOut': false, 'animTime':0}); //helpers.errorAlert($('.pop-password'), 'Aguarde.', {'bgcolor':'#d3d3c3', 'color':'#3c493e', 'autoFadeOut': true}); var data = { senha_atual: $('#senha_atual').val(), nova_senha: $('#nova_senha').val() }; $.ajax({ url: ALTERAR_SENHA_URL, data: data, type: 'POST', success: function(data) { if (data == 'alterado') { helpers.pop.showSuccess( $('#box-area-access'), 'Senha alterada com sucesso' ); location.reload(); } else { helpers.errorAlert( $('#restrito .details'), 'Erro ao alterar a senha'); } }, error: function(request){ helpers.errorAlert( $('#restrito .details'), 'Erro ao alterar a senha: '+request.responseText ); } }); } }, corners : function() { $( '#box-area-access' ).cornerz( { radius : 6, corners : 'tl tr bl', background : '#f8f8e9' } ); $( '#exchange ul li' ).cornerz( { radius : 6, corners : 'tl tr bl', background : '#f8f8e9' } ); $( '#box-area-access form fieldset .login, #box-area-access form fieldset .password' ).cornerz( { radius : 6, background : '#ebebdd' } ); // $( '.buttons' ).cornerz( { radius : 6, background : '#f8f8e9' } ); $( '.buttons' ).cornerz( { radius : 6, background : '#ebebdd' } ); $( '#senha_borda, #senha_confirma_borda, #senha_atual_borda' ).cornerz( { radius : 6, background : '#ebebdd' } ); }, } $( document ).ready( function() { helpers.init(); structure.init(); restrict.init(); });