Advertisement
yeshuadesign

js/custom.js

Oct 23rd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. $('form[name="form_login"]').submit(function () {
  4. var forma = $(this);
  5. var botao = $(this).find(':button');
  6.  
  7. $.ajax({
  8. url: "ajax/controller.php",
  9. type: "POST",
  10. data: "acao=login&"+forma.serialize(),
  11. beforeSend: function(){
  12. botao.attr('disabled', true);
  13. $('.load').fadeIn('slow');
  14. },
  15. success: function(retorno){
  16. $('.load').fadeOut('slow', function (){
  17. botao.attr('disabled', false);
  18. });
  19.  
  20. if(retorno === 'noif'){
  21. msg('Este login não é válido', 'erro');
  22. }else if(retorno === 'diffpass'){
  23. msg('Senha não confere com o login', 'alerta');
  24. }else if (retorno === 'non') {
  25. msg('Você não tem permissão para continuar com seu login!', 'info');
  26. }else{
  27. forma.fadeOut('fast', function(){
  28. msg('Login efetuado com sucesso, aguarde...', 'sucesso');
  29. $('#load').fadeIn('slow');
  30. });
  31.  
  32. setTimeout(function(){
  33. $(location).attr('href', 'painel.php');
  34. }, 3000);
  35.  
  36. }
  37. }
  38. });
  39.  
  40. return false;
  41. });
  42.  
  43. //FUNÇÕES GERAL
  44. function msg(msg, tipo){
  45. var retorno = $('.retorno');
  46. var tipo = (tipo === 'sucesso') ? 'success' : (tipo === 'alerta') ? 'warning' : (tipo === 'erro') ? 'danger' : (tipo === 'info') ? 'info' : alert('INFORME MENSAGENS DE SUCESSO, ALERTA, ERRO E INFO');
  47.  
  48. retorno.empty().fadeOut('fast', function(){
  49. return $(this).html('<div class="alert alert-'+tipo+'">'+msg+'</div>').fadeIn('slow');
  50. });
  51.  
  52. setTimeout(function() {
  53. retorno.fadeOut('slow').empty();
  54. }, 5000);
  55. }
  56.  
  57.  
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement