1( function( $ ) { 2 'use strict'; 3 4 $( document ).ready( function() { 5 6 // Get the parent container. 7 var parentContainer = '.woocommerce-shipping-fields'; 8 9 // Get the container holding our Gift Aid markup. 10 var container = '#woocommerce-gift-aid'; 11 12 // The country code for the United Kingdom. 13 var home = 'GB'; 14 15 // When the billing country <select> changes. 16 $( '#billing_country' ).on( 'change', function( e ) { 17 18 // Get the currently selected country. 19 var country = $( e.target ).find( "option:selected" ).val(); 20 21 if ( country !== home && $( container ).length > 0 ) { 22 // If the newly selected country isn't GB, and the 23 // container exists then remove it. 24 $( container ).remove(); 25 26 } else if ( country === home && $( container ).length < 1 ) { 27 // Fetch and append the container if the country 28 // is GB and the container doesn't exist. 29 var data = { 30 action: 'gift_aid_html', // WP action suffix. 31 security: giftaidhtml.security // Nonce string. 32 }; 33 34 $.post( 35 giftaidhtml.ajax_url, // AJAX url for WP. 36 data, 37 function( response ) { 38 if ( response !== 0 ) { 39 // Append the response to the parent container. 40 $( parentContainer ).append( response ); 41 } 42 } 43 ); 44 } 45 46 return false; 47 } ); 48 } ); 49 50} )( 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.