1/* 2 * 3 * CF7 :: Disable auto-validation 4 * 5 */ 6if ( typeof wpcf7 !== 'undefined' ) { 7 wpcf7.validate = function( a, b ) { 8 return null; 9 }; 10} 11 12jQuery( document ).ready( function() { 13 sd_cf7_form_field_events(); 14} ); 15 16function sd_cf7_form_field_events() { 17 /* 18 * 19 * CF7 :: Popup show 20 * 21 */ 22 jQuery( document ).on( 'click', '.sd_cf7_popup_show, .et_pb_button[href^="https://sd_cf7_popup"]', function( event ) { 23 event.preventDefault(); 24 25 var show = jQuery( this ); 26 var form_id = show.attr( 'href' ).replace( 'https://', '#' ).replace( 'http://', '#' ); 27 var offset = jQuery( document ).scrollTop(); 28 29 jQuery( '#page-container' ).fadeOut( 'slow', function() { 30 jQuery( 'html, body' ).stop( true, false ).animate( { scrollTop: 0 }, 'slow', function() { 31 jQuery( 'body' ).addClass( 'sd_cf7_popup_active' ); 32 jQuery( form_id ).attr( 'offset', offset ).fadeIn( 'slow' ).addClass( 'active' ); 33 } ); 34 } ); 35 36 jQuery( form_id ).on( 'click', '.sd_cf7_popup_close', function() { 37 sd_cf7_popup_close( form_id ); 38 } ); 39 } ); 40 41 /* 42 * 43 * CF7 :: Field focus 44 * 45 */ 46 jQuery( document ).on( 'focus', '.sd_cf7_form .sd_cf7_field input:not(.sd_select), .sd_cf7_form .sd_cf7_field textarea', function() { 47 jQuery( this ).parents( '.sd_cf7_field' ).first().addClass( 'active' ); 48 } ); 49 50 jQuery( document ).on( 'focus', '.sd_cf7_form .sd_cf7_field input.sd_select', function() { 51 jQuery( this ).parents( '.sd_cf7_field' ).first().addClass( 'active' ); 52 jQuery( this ).parent().find( '.sd_form_select' ).show(); 53 } ); 54 55 /* 56 * 57 * CF7 :: Field blur 58 * 59 */ 60 jQuery( document ).on( 'blur', '.sd_cf7_form .sd_cf7_field input:not(.sd_select), .sd_cf7_form .sd_cf7_field textarea', function() { 61 if ( jQuery( this ).val() == '' ) { 62 jQuery( this ).parents( '.sd_cf7_field' ).first().removeClass( 'active' ); 63 } 64 } ); 65 66 jQuery( document ).on( 'change', 'input.walcf7-datepicker', function() { 67 if ( jQuery( this ).val() == '' ) { 68 jQuery( this ).parents( '.sd_cf7_field' ).first().removeClass( 'active' ); 69 } else { 70 jQuery( this ).parents( '.sd_cf7_field' ).first().addClass( 'active' ); 71 } 72 } ); 73 74 /* 75 * 76 * CF7 :: Accept field 77 * 78 */
79 sd_cf7_accept_field(); 80 81 jQuery( document ).on( 'change', '.sd_cf7_form input[name="accept"]', function() { 82 sd_cf7_accept_field(); 83 } ); 84 85 /* 86 * 87 * CF7 :: Signature field 88 * 89 */ 90 sd_cf7_signature_field(); 91 92 jQuery( document ).on( 'change', '.sd_cf7_form input[name="sd_sepa_signature"]', function() { 93 sd_cf7_signature_field(); 94 } ); 95} 96 97/* 98 * 99 * CF7 :: Popup hide 100 * 101 */ 102function sd_cf7_popup_close( sd_cf7_popup_id ) { 103 var offset = jQuery( sd_cf7_popup_id ).attr( 'offset' ); 104 105 jQuery( sd_cf7_popup_id ).attr( 'offset', '' ).removeClass( 'active' ).fadeOut( 'slow', function() { 106 jQuery( '#page-container' ).css( 'opacity', 0 ).fadeIn( 'slow', function() { 107 jQuery ( 'html, body' ).stop( true, false ).animate( { scrollTop: offset }, 'slow', function() { 108 jQuery ( '#page-container' ).animate( { opacity: 1 }, 'slow' ); 109 } ); 110 } ); 111 } ); 112} 113 114/* 115 * 116 * CF7 :: Select / Easydropdown 117 * 118 * https://github.com/patrickkunka/easydropdown 119 * 120 */ 121jQuery( document ).on( 'ready', function() { 122 if ( jQuery( '.sd_select' ).length > 0 ) { 123 jQuery( '.sd_select' ).each( function() { 124 var id = jQuery( this ).attr( 'id' ); 125 126 easydropdown( '#' + id, { 127 behavior: { 128 useNativeUiOnMobile: false 129 }, 130 callbacks: { 131 onOpen: () => sd_select_class_open( id ), 132 onClose: () => sd_select_class_close( id ) 133 } 134 } ); 135 } ); 136 } 137} ); 138 139function sd_select_class_open( id ) { 140 jQuery( '#' + id ).parents( '.sd_cf7_field' ).addClass( 'active' ); 141 jQuery( '#' + id ).parents( '.wpcf7-form-control-wrap' ).first().attr( 'data-type', 'edd_select' ); 142} 143 144function sd_select_class_close( id ) { 145 jQuery( '#' + id ).parents( '.wpcf7-form-control-wrap' ).first().attr( 'data-type', '' ); 146 147 if ( jQuery( '#' + id ).val() == '' ) { 148 jQuery( '#' + id ).parents( '.sd_cf7_field' ).removeClass( 'active' ); 149 } 150} 151 152/* 153 * 154 * CF7 :: Datetimepicker Pro 155 * 156 */ 157function sd_xdsoft_datetimepicker_set_current_date( input, datepicker ) { 158 if ( jQuery( input ).val() != '' ) { 159 var date_parts = jQuery( input ).val().split( '.' ); 160 161 if ( date_parts.length == 3 ) { 162 var day = date_parts[ 0 ]; 163 var month = parseInt( date_parts[ 1 ] ) - 1; 164 var year = date_parts[ 2 ]; 165 166 jQuery( datepicker ).find( '.xdsoft_calendar td:not([data-date="' + day + '"][data-month="' + month + '"][data-year="' + year + '"])' ).removeClass( 'xdsoft_current' ); 167 jQuery( datepicker ).find( '.xdsoft_calendar td[data-date="' + day + '"][data-month="' + month + '"][data-year="' + year + '"]' ).addClass( 'xdsoft_current' ); 168 } 169 } 170} 171 172/* 173 * 174 * CF7 :: Accept field 175 * 176 */ 177function sd_cf7_accept_field() { 178 var accept_field = jQuery( '.sd_cf7_form input[name="accept"]' ); 179 180 if ( jQuery( '#sd_form_submit, .sd_form_submit' ).parent().hasClass( 'inner' ) ) { 181 if ( jQuery( accept_field ).is( ':checked' ) ) { 182 jQuery( '#sd_form_submit, .sd_form_submit' ).parent().removeClass( 'disabled' ); 183 } else { 184 jQuery( '#sd_form_submit, .sd_form_submit' ).parent().addClass( 'disabled' ); 185 } 186 } 187} 188 189/* 190 * 191 * CF7 :: Signature field 192 * 193 */ 194function sd_cf7_signature_field() { 195 var signature = jQuery( '.sd_cf7_form input[name="sd_sepa_signature"]' ).val(); 196 197 if ( signature == '' ) { 198 jQuery( '#sd_form_submit, .sd_form_submit' ).attr( 'disabled', 'disabled' ); 199 } else { 200 jQuery( '#sd_form_submit, .sd_form_submit' ).removeAttr( 'disabled' ); 201 } 202} 203 204/* 205 * 206 * CF7 :: Spam 207 * 208 */ 209document.addEventListener( 'wpcf7spam', function( event ) { 210 jQuery.sd_confirm( { 211 type: 'confirm', 212 class: 'error', 213 content: event.detail.apiResponse.message, 214 cancel: { 215 show: false 216 } 217 } ); 218} ); 219 220/* 221 * 222 * CF7 :: Mail failed 223 * 224 */ 225document.addEventListener( 'wpcf7mailfailed', function( event ) { 226 jQuery.sd_confirm( { 227 type: 'confirm', 228 class: 'error', 229 content: event.detail.apiResponse.message, 230 cancel: { 231 show: false 232 } 233 } ); 234} ); 235 236/* 237 * 238 * CF7 :: Invalid 239 * 240 */ 241document.addEventListener( 'wpcf7invalid', function( event ) { 242 jQuery( '.sd_cf7_form select.edd-select' ).each( function() { 243 if ( jQuery( this ).val() == '' ) { 244 jQuery( this ).parents( '.sd_cf7_field' ).first().addClass( 'invali
244d' ); 245 } else { 246 jQuery( this ).parents( '.sd_cf7_field' ).first().removeClass( 'invalid' ); 247 } 248 } ); 249 250 var invalidFields = event.detail.apiResponse.invalid_fields.filter( e => e.field === 'sd_mathcaptcha' ); 251 252 if ( invalidFields.length > 0 ) { 253 jQuery( '.sd_cf7_form .sd_mathcaptcha_wrap' ).first().addClass( 'invalid' ); 254 } else { 255 jQuery( '.sd_cf7_form .sd_mathcaptcha_wrap' ).first().removeClass( 'invalid' ); 256 } 257 258 if ( jQuery( '#sd_sepa_signature' ).val() == '' ) { 259 jQuery( '.sd_cf7_form .dscf7_signature_inner' ).first().addClass( 'invalid' ); 260 } else { 261 jQuery( '.sd_cf7_form .dscf7_signature_inner' ).first().removeClass( 'invalid' ); 262 } 263 264 jQuery.sd_confirm( { 265 type: 'confirm', 266 class: 'error', 267 content: event.detail.apiResponse.message, 268 cancel: { 269 show: false 270 } 271 } ); 272 273 sd_cf7_form_field_events(); 274} ); 275 276/* 277 * 278 * CF7 :: Mail sent 279 * 280 */ 281// TODO: Reset form and close popup on wpcf7mailsent 282document.addEventListener( 'wpcf7mailsent', function( event ) { 283 jQuery.sd_confirm( { 284 type: 'confirm', 285 class: 'success', 286 content: event.detail.apiResponse.message, 287 confirm: { 288 callback: 'sd_reload_content' 289 }, 290 cancel: { 291 show: false 292 } 293 } ); 294} );
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.