1 2/* global dotdigital_form_data */ 3( function( $ ) { 4 'use strict'; 5 $( 6 function() { 7 $( 'form.dotdigital-signup-form' ).on( 8 'submit', 9 function( event ) { 10 const form = $( this ); 11 const is_ajax = form.find( "input[name='is_ajax']" ); 12 if ( is_ajax[ 0 ].value !== '1' ) { 13 return; 14 } 15 const email = form.find( "input[name='email']" ); 16 let responseMessage = ''; 17 event.preventDefault(); 18 $.ajax( 19 { 20 beforeSend( xhr ) { 21 xhr.setRequestHeader( 'X-WP-Nonce', dotdigital_form_data.nonce ); 22 }, 23 url: dotdigital_form_data.ajax_url + 'dotdigital/v1/signup-widget', 24 type: 'POST', 25 dataType: 'json', 26 data: { 27 redirection: form.find( "input[name='redirection']" )[ 0 ].value, 28 is_ajax: true, 29 email: $( email ).val(), 30 lists: form.find( "input[name='lists[]']" ).map( 31 function() { 32 if ( $( this ).is( ':checked' ) || $( this ).is( ':hidden' ) ) { 33 return $( this ).val(); 34 } 35 return undefined; 36 } ).get(), 37 datafields: form.find( '.datafield' ).map( 38 function( i, element ) { 39 if ( $( element ).parent().attr( 'class' ) === 'ddg-form-group' ) { 40 return { key: $( element ).data( 'datafield-name' ), value: element.value, required: $( element ).data( 'required' ) }; 41 } 42 if ( $( element )[ 0 ].checked ) { 43 return { key: $( element ).data( 'datafield-name' ), value: element.value, required: $( element ).data( 'required' ) }; 44 } 45 return undefined; 46 } ).get(), 47 }, success( response ) { 48 if ( response.success ) { 49 $( form )[ 0 ].reset(); 50 if ( response.redirection ) { 51 window.location.href = response.redirection; 52 } 53 responseMessage = $( '<p/>', { 54 class: 'dd-wordpress-success-msg', 55 html: response.message, 56 } ); 57 } else { 58 responseMessage = $( '<p/>', { 59 class: 'dd-wordpress-error-msg', 60 html: response.message, 61 } ); 62 } 63 form.next( '.form_messages' ).empty().append( responseMessage ).fadeIn( 'fast' ).delay( 9000 ).fadeOut( 'slow' ); 64 }, error() { 65 responseMessage = $( '<p/>', { 66 class: 'dd-wordpress-error-msg', 67 html: dotdigital_form_data.generic_failure_message, 68 } ); 69 form.next( '.form_messages' ).empty().append( responseMessage ); 70 }, 71 }, 72 ); 73 }, 74 ); 75 }, 76 ); 77}( 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.