1jQuery(function(){ 2 /** 3 * Gestion des formulaires en javascript/ajax 4 * @type {Function} 5 */ 6 var ajaxSubmitForm = (function (_this) { 7 $('.jqMessageNewAbonne').hide(); 8 $('.jqMessageErrorNewAbonne').hide(); 9 // @TODO: Ajout d'un loader 10 $.ajax({ 11 url: _this.attr('action'), 12 type: _this.attr('method'), 13 data: new FormData( _this[0] ), 14 processData: false, 15 contentType: false, 16 statusCode: { 17 //traitement en cas de succès 18 200: function(response) { 19 if (_this.hasClass('formabonne')) { 20 $('.jqMessageAbonne').fadeIn('slow'); 21 $('.jqMessageErrorAbonne').fadeOut('slow'); 22 } 23 if (_this.hasClass('formNewAbonne')) { 24 $('.jqMessageNewAbonne').fadeIn('slow'); 25 $('.jqMessageErrorNewAbonne').fadeOut('slow'); 26 } 27 // var successMessage = response.successMessage ; 28 }, 29 //traitement en cas d'erreur (on peut aussi traiter le cas erreur 500...) 30 412: function(response) { 31 if (_this.hasClass('formabonne')) { 32 $('.jqMessageAbonne').fadeOut('slow'); 33 $('.jqMessageErrorAbonne').fadeIn('slow'); 34 } 35 if (_this.hasClass('formNewAbonne')) { 36 $('.jqMessageNewAbonne').fadeOut('slow'); 37 $('.jqMessageErrorNewAbonne').fadeIn('slow'); 38 } 39 var dataList = response.responseJSON.data; 40 for (var key in dataList) { 41 $(_this.find('[name*="' + key + '"]')[0]).addClass('error'); 42 } 43 44 // var errorrsFm = response.responseJSON.formErrors ; 45 }, 46 } 47 }); 48 }); 49 50 // Affichage du formulaire pour être recontacté 51 $('#btnAppel').on('click', function(event) { 52 event.preventDefault(); 53 54 $('#blocAboHpComD').hide(); 55 $('#newblocAboHpComD').fadeIn('slow').removeAttr('style'); 56 }); 57 58 // Affichage du formulaire déjà abonné 59 // @TODO: Décommenter pour la gestion de l'abonné 60 /* 61 $('.closeForm').on('click', function(event) { 62 event.preventDefault(); 63 64 $('#newblocAboHpComD').hide(); 65 $('#blocAboHpComD').fadeIn('slow').show(); 66 }); 67 */ 68 69 $('body').on('submit', '.formabonne', function(e) { 70 e.preventDefault(); 71 ajaxSubmitForm($(this)); 72 }).on('submit', '.formNewAbonne', function(e) { 73 e.preventDefault(); 74 ajaxSubmitForm($(this)); 75 }); 76});
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.