1jQuery(document).on('gform_post_render', function(){ 2 function setAutocomplete( autocomplete, $container, catalog ) { 3 var label_text = $container.closest( '.gfield' ).find( '.gfield_label' ).text().replace( '*', '' ); 4 if ( catalog.includes( label_text ) ) { 5 $container.find( 'input' ).attr( 'autocomplete', autocomplete ); 6 } 7 } 8 9 /** 10 * Implement autocomplete attribute. 11 */ 12 jQuery( '.ginput_container_name .name_first input' ).attr( 'autocomplete', 'given-name' ); 13 jQuery( '.ginput_container_name .name_last input' ).attr( 'autocomplete', 'family-name' ); 14 jQuery( '.ginput_container_email input' ).attr( 'autocomplete', 'email' ); 15 jQuery( '.ginput_container_phone input' ).attr( 'autocomplete', 'tel-national' ); 16 jQuery( '.ginput_container_text' ).each(function(){ 17 setAutocomplete( 'given-name', jQuery( this ), [ 18 'First Name', 19 ]); 20 setAutocomplete( 'family-name', jQuery( this ), [ 21 'Last Name', 22 ]); 23 setAutocomplete( 'organization', jQuery( this ), [ 24 'Company', 25 'Organization', 26 'Organization/Company', 27 ]); 28 }); 29 30 /** 31 * Add role="group" and aria-label to checkbox fields. 32 */ 33 jQuery( '.ginput_container_checkbox' ).each(function(){ 34 var label = jQuery( this ).siblings( '.gfield_label' ).text(); 35 jQuery( this ).attr( 'role', 'group' ).attr( 'aria-label', label ); 36 }); 37 38 /** 39 * Convert .gfield_label to span to prevent orphaned 40 * labels on Name, Address and Checkboxes fields. 41 */ 42 jQuery( 43 '.ginput_container_name, ' 44 + '.ginput_container_address, ' 45 + '.ginput_container_checkbox' 46 ).each(function(){ 47 var $label = jQuery( this ).siblings( '.gfield_label' ); 48 var html = $label.html(); 49 $label.after( '<span class="gfield_label">' + html + '<span>' ); 50 $label.remove(); 51 }); 52 53 /** 54 * Set focus on the first input with errors. 55 */ 56 jQuery( '.gfield_error input' ).eq(0).focus(); 57 58 /** 59 * Implement aria-describedby to error inputs. 60 */ 61 jQuery( '.gfield_error input, .gfield_error select, .gfield_error textarea' ).each(function(){ 62 var id = jQuery(this).closest( '.gfield' ).find( '.validation_message' ).attr( 'id' ); 63 jQuery(this).attr( 'aria-describedby', '#' + id ); 64 }); 65});
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.