1 2jQuery(document).ready(function($) { 3 var mailchimp_form = { 4 init: function() { 5 $('.incsub-mailchimp-form').submit( mailchimp_form.on_submit_form ); 6 }, 7 8 on_submit_form: function( e ) { 9 e.preventDefault(); 10 var form_id = $(this).attr('id'); 11 12 var form_data = $( '#' + form_id ).serializeArray(); 13 var errors_container = $( '#' + form_id + ' .incsub-mailchimp-error' ); 14 var success_container = $( '#' + form_id + ' .incsub-mailchimp-updated' ); 15 var spinner = $( '#' + form_id ).find( '.mailchimp-spinner' ); 16 17 var ajax_data = {} 18 for ( var i = 0; i < form_data.length -1; i++ ) { 19 ajax_data[ form_data[i]['name'] ] = form_data[i]['value']; 20 } 21 22 errors_container.slideUp().find('*').detach(); 23 spinner.css('visibility', 'visible'); 24 25 $.ajax({ 26 url: mailchimp_form_captions.ajaxurl, 27 type: 'post', 28 data: ajax_data, 29 dataType: 'json' 30 }) 31 .done(function( data ) { 32 33 spinner.css('visibility', 'hidden'); 34 35 if ( data.success ){ 36 success_container.slideDown(); 37 $( '#' + form_id ).find('*').not('.incsub-mailchimp-updated').detach(); 38 } 39 else { 40 for ( var i = 0; i < data.data.errors.length; i++ ) { 41 var error = $('<li></li>').text( data.data.errors[i] ); 42 errors_container.append( error ); 43 } 44 errors_container.slideDown(); 45 } 46 47 48 49 }); 50 51 return false; 52 } 53 } 54 55 mailchimp_form.init(); 56});
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.