Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.     $(".e").mouseover(function() {
  3.         $(this).hide();
  4.         $(this).html($(this).html()+", contato: papadopolis_@live.com");
  5.         $(this).attr("style","color:black");
  6.         $(this).fadeIn('fast');
  7.     })
  8.    
  9.     $(".d").mouseover(function() {
  10.         $(this).hide();
  11.         $(this).attr("style","color:black");
  12.         $(this).fadeIn('fast');
  13.     })
  14.    
  15.     $(".e").mouseout(function() {
  16.         $(this).html($(this).html().match(/(.*?)\,/)[1]);
  17.         $(this).attr("style","color:#ddd");
  18.         $(this).fadeIn('fast');
  19.     })
  20.    
  21.     $(".d").mouseout(function() {
  22.         $(this).hide();
  23.         $(this).attr("style","color:#ddd");
  24.         $(this).fadeIn('fast');
  25.     })
  26.    
  27.     $("form").submit(function() {
  28.         form = {dados:""};
  29.    
  30.         $("#"+this.id+" :input").each(function() {
  31.             form.dados += this.name+"="+this.value+"&";
  32.         });
  33.        
  34.         form.dados   = form.dados.substr(0,form.dados.length-1);
  35.         form.type    = $(this).attr("method");
  36.         form.action  = $(this).attr("action");
  37.         form.id      = this.id;
  38.        
  39.         if(form.action == "" || form.action == null)
  40.             form.action = window.location.href.match(/((.*?\x3F|.*))/i)[2];
  41.        
  42.         if(form.type == "" || form.type == null)
  43.             form.type = "POST";
  44.        
  45.         //alert([form.dados,form.action,form.type]); //DEBUG
  46.         form.load = false;
  47.        
  48.         $.ajax({
  49.             type:   form.type,
  50.             url:    form.action,
  51.             data:   form.dados,
  52.             beforeSend: function() {
  53.                 if($("#"+form.id+" #floatLoad").val("1")) {
  54.                     $("#"+form.id+" #load").html("processando formulário...");
  55.                     $("#"+form.id+" #load").show('fast');
  56.                 } else {
  57.                     if($("#"+form.id+" #ajaxCarregar").is(":hidden")) {
  58.                         $("#"+form.id+" #ajaxCarregar").show('fast')
  59.                         form.load = true
  60.                     }
  61.                 }
  62.                    
  63.                 $("#"+form.id+" #ajaxCarregar").attr("class","ajaxCarregar");
  64.             },
  65.             success: function(data) {
  66.                 if(data[0] == '\x7B') {
  67.                     eval("r = "+data);
  68.                     switch(r.status) {
  69.                         case 1:
  70.                             if(r.target!==undefined) {
  71.                                 $("#"+r.target).fadeOut('fast');
  72.                                 $("#"+r.target).html(r.html);
  73.                                 $("#"+r.target).fadeIn('fast');
  74.                             }
  75.                            
  76.                             if(r.mensagem!==undefined)
  77.                                 alert(r.mensagem);
  78.                                
  79.                             if(r.redirect!==undefined)
  80.                                 window.location.href = r.redirect;
  81.                                
  82.                             if(r.some!==undefined)
  83.                                 $("#"+form.id).fadeOut('fast');
  84.                                
  85.                             if(r.script !== undefined)
  86.                                 eval(r.script);
  87.                         break;
  88.                         default:
  89.                             f = "Ocorreu algum erro ao enviar o formulário.\n\n";
  90.                             alert(f+r.mensagem);
  91.                             return 1;
  92.                     }
  93.                 } else
  94.                     return 0;
  95.             },
  96.             complete: function() {
  97.                 if(form.load == true) {
  98.                     $("#"+form.id+" #ajaxCarregar").fadeOut('fast');
  99.                     $("#"+form.id+" #load").fadeOut('fast');
  100.                 } else
  101.                     $("#"+form.id+" #ajaxCarregar").attr("class","subs");
  102.             },
  103.             error: function(){alert("[FORMULÁRIO]\n\nOcorreu algum erro ao processar o formulário, tente novamente.")},
  104.             timeout: function(){alert("[FORMULÁRIO]\n\nO servidor demorou muito para responder, tente novamente.")},
  105.         });
  106.        
  107.         return false;
  108.     });
  109.    
  110.     f=1;
  111.     $("form[id*=ajaxForm]").each(function() {
  112.        $(this).attr("id",this.id+f);
  113.        f++;
  114.     });
  115. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement