1 2jQuery(document).ready(function($){ 3 4 $('form.ajax_form *[type=submit]').each(function() { 5 $(this).data('texte', $(this).text()); 6 $(this).before('<span class="result_maj"></span>'); 7 8 form_id = $(this).parents('form').attr('id'); 9 $(this).after('<img src="'+_src_img_ajax_loader+'" id="ajax-loader'+form_id+'" style="visibility:hidden;margin:0 5px;" />'); 10 $('img#ajax-loader'+form_id).css('opacity', 0); 11 }); 12 13 $('form.ajax_form *[type=submit]').click(function(e) { 14 15 e.preventDefault(); 16 17 $('.gwp_result_form').remove(); 18 $('img#ajax-loader'+form_id).css('opacity', 1); 19 20 my_button = $(this); 21 my_button_text = $(this).text(); 22 my_button.text('En attente...'); 23 24 $('img#ajax-loader'+form_id).css('visibility', 'visible'); 25 26 le_form = $(this).parents('form'); 27 form_id = le_form.attr('id'); 28 29 result_maj = $(this).siblings('.result_maj'); 30 31 console.info(le_form); 32 33 le_form.find('input').removeClass('input_error'); 34 le_form.find('textarea').removeClass('input_error'); 35 le_form.find('select').removeClass('input_error'); 36 $('.msg_error').remove(); 37 38 var data = { 39 'action': 'traiter_le_formulaire', 40 'whatever': le_form.serialize() 41 }; 42 $.post(_ajax_url, data, function(response) { 43 44 console.log('Got this from the SERVER: ' + response); 45 my_button.text(my_button.data('texte')); 46 $('img#ajax-loader'+form_id).animate({opacity: 0}, 500); 47 48 if (gwp_is_json(response) == false) { 49 console.warn('Mauvais format de retour (JSON attendu)'); 50 return; 51 } 52 the_response = JSON.parse(response); 53 result = the_response.result; 54 which_form = the_response.which_form; 55 champs = the_response.champs; 56 texte = the_response.texte; 57 58 if (result == 'success') { 59 60 result_maj.html(texte).addClass('success').removeClass('error').show().css('opacity',1); 61 if (typeof(the_response.delai) != 'undefined') { 62 delai = the_response.delai; 63 } 64 else { 65 delai = 2000; 66 } 67 setTimeout(function(){ 68 result_maj.animate({ 69 opacity:0, 70 }, 400, function() {}); 71 }, delai); 72 73 // Quelle action effectuer en fonction du form validé. 74 console.log(which_form); 75 if (which_form == 'form_inscription_compagnie') { 76 err = '<ul id="which_form_'+which_form+'" class="gwp_result_form woocommerce-message"><li>'+texte+'</li></ul>'; 77 le_form.before(err); 78 le_form.remove(); 79 $('#txt_intro_insc_compagnie').remove(); 80 81 $('html, body').animate({ 82 scrollTop: $('#which_form_'+which_form).offset().top 83 }, 1000); 84 console.log('Inscription compagnie validée'); 85 } 86 else { 87 // Le cas générique 88 alert('form valide'); 89 } 90 } 91 else if (result == 'error') { 92 err = '<ul class="gwp_result_form woocommerce-error"><li>'+texte+'</li></ul>'; 93 le_form.before(err); 94 console.warn(champs); 95 $.each(champs, function(index, value) { 96 if ($('form#'+form_id+' [name='+index+']').length < 1) { 97 /* 98 Ceci pour le cas où une erreur est renvoyée, mais relative à aucun champ en particulier 99 (car particulier et rare) 100 */ 101 msg = '<p class="msg_error" style="border:1px red solid;padding:20px;color:red;">'+value+'</p>'; 102 le_form.before(msg); 103 } 104 else { 105 $('form#'+form_id+' [name='+index+']').addClass('input_error').after('<span class="msg_error">'+value+'</span>'); 106 } 107 }); 108 } 109 else { 110 if(typeof texte == 'undefined') { 111 texte = 'Action non effectuée'; 112 } 113 result_maj.addClass('error').removeClass('success').show().html(texte); 114 } 115 }); 116 }); 117 118}); 119 120 121 122 123 124 125 126 127
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.