1"use strict"; 2 3( function( $ ) { 4 5 /* 6 * AJAX subscription 7 */ 8 $( document ).on( 'submit', '.pk-subscribe-form-wrap form', function( e ) { 9 10 var form = $( this ); 11 var formWrap = $( form ).closest('.pk-subscribe-form-wrap'); 12 var service = formWrap.data('service') || 'mailchimp'; 13 14 // If form is custom, let the native form submission happen 15 if (service === 'custom') { 16 // Check privacy first 17 var privacy = $( formWrap ).find( 'input[name="pk-privacy"]' ); 18 19 if ( $( privacy ).length > 0 && ! $( privacy ).prop( 'checked' ) ) { 20 e.preventDefault(); 21 $( privacy ).parent().after( '<p class="pk-alert pk-alert-warning">' + window.opt_in.warning_privacy + '</p>' ); 22 return false; 23 } 24 25 // Continue with the native form submission 26 return true; 27 } 28 29 // Remove messages. 30 $( formWrap ).find( '.pk-alert' ).remove(); 31 32 // Policies. 33 var privacy = $( formWrap ).find( 'input[name="pk-privacy"]' ); 34 35 if ( $( privacy ).length > 0 && ! $( privacy ).prop( 'checked' ) ) { 36 $( privacy ).parent().after( '<p class="pk-alert pk-alert-warning">' + window.opt_in.warning_privacy + '</p>' ); 37 38 return false; 39 } 40 41 if ( !$( form ).hasClass( 'pk-loading' ) ) { 42 $.ajax( { 43 type: 'POST', 44 url: window.opt_in.ajax_url + '?action=powerkit_subscription', 45 data: $( form ).serialize(), 46 beforeSend: function() { 47 $( form ).addClass( 'pk-loading' ); 48 }, 49 success: function( data ) { 50 $( form ).removeClass( 'pk-loading' ); 51 52 if ( data.success ) { 53 $( form ).after( '<p class="pk-alert pk-alert-success">' + data.data + '</p>' ); 54 } else { 55 $( form ).after( '<p class="pk-alert pk-alert-warning">' + data.data + '</p>' ); 56 } 57 }, 58 error: function() { 59 $( form ).after( '<p class="pk-alert pk-alert-warning">Error server!</p>' ); 60 61 $( form ).removeClass( 'pk-loading' ); 62 } 63 } ); 64 65 } 66 return false; 67 } ); 68 69} )( jQuery );
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.