PageSourceSearch

https://www.greenconsulting.it/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.2.2

js greenconsulting.it collected 2026-09-25 01:33:53 UTC 14,105 bytes, 527 lines download raw bytes

1( function( $ ) {
2
3	'use strict';
4
5	if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) {
6		return;
7	}
8
9	wpcf7 = $.extend( {
10		cached: 0,
11		inputs: []
12	}, wpcf7 );
13
14	$( function() {
15		wpcf7.supportHtml5 = ( function() {
16			var features = {};
17			var input = document.createElement( 'input' );
18
19			features.placeholder = 'placeholder' in input;
20
21			var inputTypes = [ 'email', 'url', 'tel', 'number', 'range', 'date' ];
22
23			$.each( inputTypes, function( index, value ) {
24				input.setAttribute( 'type', value );
25				features[ value ] = input.type !== 'text';
26			} );
27
28			return features;
29		} )();
30
31		$( 'div.wpcf7 > form' ).each( function() {
32			var $form = $( this );
33			wpcf7.initForm( $form );
34
35			if ( wpcf7.cached ) {
36				wpcf7.refill( $form );
37			}
38		} );
39	} );
40
41	wpcf7.getId = function( form ) {
42		return parseInt( $( 'input[name="_wpcf7"]', form ).val(), 10 );
43	};
44
45	wpcf7.initForm = function( form ) {
46		var $form = $( form );
47
48		wpcf7.setStatus( $form, 'init' );
49
50		$form.submit( function( event ) {
51			if ( ! wpcf7.supportHtml5.placeholder ) {
52				$( '[placeholder].placeheld', $form ).each( function( i, n ) {
53					$( n ).val( '' ).removeClass( 'placeheld' );
54				} );
55			}
56
57			if ( typeof window.FormData === 'function' ) {
58				wpcf7.submit( $form );
59				event.preventDefault();
60			}
61		} );
62
63		$( '.wpcf7-submit', $form ).after( '<span class="ajax-loader"></span>' );
64
65		wpcf7.toggleSubmit( $form );
66
67		$form.on( 'click', '.wpcf7-acceptance', function() {
68			wpcf7.toggleSubmit( $form );
69		} );
70
71		// Exclusive Checkbox
72		$( '.wpcf7-exclusive-checkbox', $form ).on( 'click', 'input:checkbox', function() {
73			var name = $( this ).attr( 'name' );
74			$form.find( 'input:checkbox[name="' + name + '"]' ).not( this ).prop( 'checked', false );
75		} );
76
77		// Free Text Option for Checkboxes and Radio Buttons
78		$( '.wpcf7-list-item.has-free-text', $form ).each( function() {
79			var $freetext = $( ':input.wpcf7-free-text', this );
80			var $wrap = $( this ).closest( '.wpcf7-form-control' );
81
82			if ( $( ':checkbox, :radio', this ).is( ':checked' ) ) {
83				$freetext.prop( 'disabled', false );
84			} else {
85				$freetext.prop( 'disabled', true );
86			}
87
88			$wrap.on( 'change', ':checkbox, :radio', function() {
89				var $cb = $( '.has-free-text', $wrap ).find( ':checkbox, :radio' );
90
91				if ( $cb.is( ':checked' ) ) {
92					$freetext.prop( 'disabled', false ).focus();
93				} else {
94					$freetext.prop( 'disabled', true );
95				}
96			} );
97		} );
98
99		// Placeholder Fallback
100		if ( ! wpcf7.supportHtml5.placeholder ) {
101			$( '[placeholder]', $form ).each( function() {
102				$( this ).val( $( this ).attr( 'placeholder' ) );
103				$( this ).addClass( 'placeheld' );
104
105				$( this ).focus( function() {
106					if ( $( this ).hasClass( 'placeheld' ) ) {
107						$( this ).val( '' ).removeClass( 'placeheld' );
108					}
109				} );
110
111				$( this ).blur( function() {
112					if ( '' === $( this ).val() ) {
113						$( this ).val( $( this ).attr( 'placeholder' ) );
114						$( this ).addClass( 'placeheld' );
115					}
116				} );
117			} );
118		}
119
120		if ( wpcf7.jqueryUi && ! wpcf7.supportHtml5.date ) {
121			$form.find( 'input.wpcf7-date[type="date"]' ).each( function() {
122				$( this ).datepicker( {
123					dateFormat: 'yy-mm-dd',
124					minDate: new Date( $( this ).attr( 'min' ) ),
125					maxDate: new Date( $( this ).attr( 'max' ) )
126				} );
127			} );
128		}
129
130		if ( wpcf7.jqueryUi && ! wpcf7.supportHtml5.number ) {
131			$form.find( 'input.wpcf7-number[type="number"]' ).each( function() {
132				$( this ).spinner( {
133					min: $( this ).attr( 'min' ),
134					max: $( this ).attr( 'max' ),
135					step: $( this ).attr( 'step' )
136				} );
137			} );
138		}
139
140		// Character Count
141		wpcf7.resetCounter( $form );
142
143		// URL Input Correction
144		$form.on( 'change', '.wpcf7-validates-as-url', function() {
145			var val = $.trim( $( this ).val() );
146
147			if ( val
148			&& ! val.match( /^[a-z][a-z0-9.+-]*:/i )
149			&& -1 !== val.indexOf( '.' ) ) {
150				val = val.replace( /^\/+/, '' );
151				val = 'http://' + val;
152			}
153
154			$( this ).val( val );
155		} );
156	};
157
158	wpcf7.submit = function( form ) {
159		if ( typeof window.FormData !== 'function' ) {
160			return;
161		}
162
163		var $form = $( form );
164
165		$( '.ajax-loader', $form ).addClass( 'is-active' );
166		wpcf7.clearResponse( $form );
167
168		var formData = new FormData( $form.get( 0 ) );
169
170		var detail = {
171			id: $form.closest( 'div.wpcf7' ).attr( 'id' ),
172			status: 'init',
173			inputs: [],
174			formData: formData
175		};
176
177		$.each( $form.serializeArray(), function( i, field ) {
178			if ( '_wpcf7' == field.name ) {
179				detail.contactFormId = field.value;
180			} else if ( '_wpcf7_version' == field.name ) {
181				detail.pluginVersion = field.value;
182			} else if ( '_wpcf7_locale' == field.name ) {
183				detail.contactFormLocale = field.value;
184			} else if ( '_wpcf7_unit_tag' == field.name ) {
185				detail.unitTag = field.value;
186			} else if ( '_wpcf7_container_post' == field.name ) {
187				detail.containerPostId = field.value;
188			} else if ( field.name.match( /^_/ ) ) {
189				// do nothing
190			} else {
191				detail.inputs.push( field );
192			}
193		} );
194
195		wpcf7.triggerEvent( $form.closest( 'div.wpcf7' ), 'beforesubmit', detail );
196
197		var ajaxSuccess = function( data, status, xhr, $form ) {
198			detail.id = $( data.into ).attr( 'id' );
199			detail.status = data.status;
200			detail.apiResponse = data;
201
202			switch ( data.status ) {
203				case 'init':
204					wpcf7.setStatus( $form, 'init' );
205					break;
206				case 'validation_failed':
207					$.each( data.invalid_fields, function( i, n ) {
208						$( n.into, $form ).each( function() {
209							wpcf7.notValidTip( this, n.message );
210							$( '.wpcf7-form-control', this ).addClass( 'wpcf7-not-valid' );
211							$( '[aria-invalid]', this ).attr( 'aria-invalid', 'true' );
212						} );
213					} );
214
215					wpcf7.setStatus( $form, 'invalid' );
216					wpcf7.triggerEvent( data.into, 'invalid', detail );
217					break;
218				case 'acceptance_missing':
219					wpcf7.setStatus( $form, 'unaccepted' );
220					wpcf7.triggerEvent( data.into, 'unaccepted', detail );
221					break;
222				case 'spam':
223					wpcf7.setStatus( $form, 'spam' );
224					wpcf7.triggerEvent( data.into, 'spam', detail );
225					break;
226				case 'aborted':
227					wpcf7.setStatus( $form, 'aborted' );
228					wpcf7.triggerEvent( data.into, 'aborted', detail );
229					break;
230				case 'mail_sent':
231					wpcf7.setStatus( $form, 'sent' );
232					wpcf7.triggerEvent( data.into, 'mailsent', detail );
233					break;
234				case 'mail_failed':
235					wpcf7.setStatus( $form, 'failed' );
236					wpcf7.triggerEvent( data.into, 'mailfailed', detail );
237					break;
238				default:
239					wpcf7.setStatus( $form,
240						'custom-' + data.status.replace( /[^0-9a-z]+/i, '-' )
241					);
242			}
243
244			wpcf7.refill( $form, data );
245
246			wpcf7.triggerEvent( data.into, 'submit', detail );
247
248			if ( 'mail_sent' == data.status ) {
249				$form.each( function() {
250					this.reset();
251				} );
252
253				wpcf7.toggleSubmit( $form );
254				wpcf7.resetCounter( $form );
255			}
256
257			if ( ! wpcf7.supportHtml5.placeholder ) {
258				$form.find( '[placeholder].placeheld' ).each( function( i, n ) {
259					$( n ).val( $( n ).attr( 'placeholder' ) );
260				} );
261			}
262
263			$( '.wpcf7-response-output', $form )
264				.html( '' ).append( data.message ).slideDown( 'fast' );
265
266			$( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() {
267				var $response = $( this );
268				$response.html( '' ).append( data.message );
269
270				if ( data.invalid_fields ) {
271					var $invalids = $( '<ul></ul>' );
272
273					$.each( data.invalid_fields, function( i, n ) {
274						if ( n.idref ) {
275							var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) );
276						} else {
277							var $li = $( '<li></li>' ).append( n.message );
278						}
279
280						$invalids.append( $li );
281					} );
282
283					$response.append( $invalids );
284				}
285
286				$response.focus();
287			} );
288
289			if ( data.posted_data_hash ) {
290				$form.find( 'input[name="_wpcf7_posted_data_hash"]' ).first()
291					.val( data.posted_data_hash );
292			}
293		};
294
295		$.ajax( {
296			type: 'POST',
297			url: wpcf7.apiSettings.getRoute(
298				'/contact-forms/' + wpcf7.getId( $form ) + '/feedback' ),
299			data: formData,
300			dataType: 'json',
301			processData: false,
302			contentType: false
303		} ).done( function( data, status, xhr ) {
304			ajaxSuccess( data, status, xhr, $form );
305			$( '.ajax-loader', $form ).removeClass( 'is-active' );
306		} ).fail( function( xhr, status, error ) {
307			var $e = $( '<div class="ajax-error"></div>' ).text( error.message );
308			$form.after( $e );
309		} );
310	};
311
312	wpcf7.triggerEvent = function( target, name, detail ) {
313		var event = new CustomEvent( 'wpcf7' + name, {
314			bubbles: true,
315			detail: detail
316		} );
317
318		$( target ).get( 0 ).dispatchEvent( event );
319	};
320
321	wpcf7.setStatus = function( form, status ) {
322		var $form = $( form );
323		var prevStatus = $form.data( 'status' );
324
325		$form.data( 'status', status );
326		$form.addClass( status );
327
328		if ( prevStatus && prevStatus !== status ) {
329			$form.removeClass( prevStatus );
330		}
331	}
332
333	wpcf7.toggleSubmit = function( form, state ) {
334		var $form = $( form );
335		var $submit = $( 'input:submit', $form );
336
337		if ( typeof state !== 'undefined' ) {
338			$submit.prop( 'disabled', ! state );
339			return;
340		}
341
342		if ( $form.hasClass( 'wpcf7-acceptance-as-validation' ) ) {
343			return;
344		}
345
346		$submit.prop( 'disabled', false );
347
348		$( '.wpcf7-acceptance', $form ).each( function() {
349			var $span = $( this );
350			var $input = $( 'input:checkbox', $span );
351
352			if ( ! $span.hasClass( 'optional' ) ) {
353				if ( $span.hasClass( 'invert' ) && $input.is( ':checked' )
354				|| ! $span.hasClass( 'invert' ) && ! $input.is( ':checked' ) ) {
355					$submit.prop( 'disabled', true );
356					return false;
357				}
358			}
359		} );
360	};
361
362	wpcf7.resetCounter = function( form ) {
363		var $form = $( form );
364
365		$( '.wpcf7-character-count', $form ).each( function() {
366			var $count = $( this );
367			var name = $count.attr( 'data-target-name' );
368			var down = $count.hasClass( 'down' );
369			var starting = parseInt( $count.attr( 'data-starting-value' ), 10 );
370			var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 );
371			var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 );
372
373			var updateCount = function( target ) {
374				var $target = $( target );
375				var length = $target.val().length;
376				var count = down ? starting - length : length;
377				$count.attr( 'data-current-value', count );
378				$count.text( count );
379
380				if ( maximum && maximum < length ) {
381					$count.addClass( 'too-long' );
382				} else {
383					$count.removeClass( 'too-long' );
384				}
385
386				if ( minimum && length < minimum ) {
387					$count.addClass( 'too-short' );
388				} else {
389					$count.removeClass( 'too-short' );
390				}
391			};
392
393			$( ':input[name="' + name + '"]', $form ).each( function() {
394				updateCount( this );
395
396				$( this ).keyup( function() {
397					updateCount( this );
398				} );
399			} );
400		} );
401	};
402
403	wpcf7.notValidTip = function( target, message ) {
404		var $target = $( target );
405		$( '.wpcf7-not-valid-tip', $target ).remove();
406
407		$( '<span></span>' ).attr( {
408			'class': 'wpcf7-not-valid-tip',
409			'role': 'alert',
410			'aria-hidden': 'true',
411		} ).text( message ).appendTo( $target );
412
413		if ( $target.is( '.use-floating-validation-tip *' ) ) {
414			var fadeOut = function( target ) {
415				$( target ).not( ':hidden' ).animate( {
416					opacity: 0
417				}, 'fast', function() {
418					$( this ).css( { 'z-index': -100 } );
419				} );
420			};
421
422			$target.on( 'mouseover', '.wpcf7-not-valid-tip', function() {
423				fadeOut( this );
424			} );
425
426			$target.on( 'focus', ':input', function() {
427				fadeOut( $( '.wpcf7-not-valid-tip', $target ) );
428			} );
429		}
430	};
431
432	wpcf7.refill = function( form, data ) {
433		var $form = $( form );
434
435		var refillCaptcha = function( $form, items ) {
436			$.each( items, function( i, n ) {
437				$form.find( ':input[name="' + i + '"]' ).val( '' );
438				$form.find( 'img.wpcf7-captcha-' + i ).attr( 'src', n );
439				var match = /([0-9]+)\.(png|gif|jpeg)$/.exec( n );
440				$form.find( 'input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]' ).attr( 'value', match[ 1 ] );
441			} );
442		};
443
444		var refillQuiz = function( $form, items ) {
445			$.each( items, function( i, n ) {
446				$form.find( ':input[name="' + i + '"]' ).val( '' );
447				$form.find( ':input[name="' + i + '"]' ).siblings( 'span.wpcf7-quiz-label' ).text( n[ 0 ] );
448				$form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[ 1 ] );
449			} );
450		};
451
452		if ( typeof data === 'undefined' ) {
453			$.ajax( {
454				type: 'GET',
455				url: wpcf7.apiSettings.getRoute(
456					'/contact-forms/' + wpcf7.getId( $form ) + '/refill' ),
457				beforeSend: function( xhr ) {
458					var nonce = $form.find( ':input[name="_wpnonce"]' ).val();
459
460					if ( nonce ) {
461						xhr.setRequestHeader( 'X-WP-Nonce', nonce );
462					}
463				},
464				dataType: 'json'
465			} ).done( function( data, status, xhr ) {
466				if ( data.captcha ) {
467					refillCaptcha( $form, data.captcha );
468				}
469
470				if ( data.quiz ) {
471					refillQuiz( $form, data.quiz );
472				}
473			} );
474
475		} else {
476			if ( data.captcha ) {
477				refillCaptcha( $form, data.captcha );
478			}
479
480			if ( data.quiz ) {
481				refillQuiz( $form, data.quiz );
482			}
483		}
484	};
485
486	wpcf7.clearResponse = function( form ) {
487		var $form = $( form );
488		$form.siblings( '.screen-reader-response' ).html( '' );
489
490		$( '.wpcf7-not-valid-tip', $form ).remove();
491		$( '[aria-invalid]', $form ).attr( 'aria-invalid', 'false' );
492		$( '.wpcf7-form-control', $form ).removeClass( 'wpcf7-not-valid' );
493
494		$( '.wpcf7-response-output', $form ).hide().empty();
495	};
496
497	wpcf7.apiSettings.getRoute = function( path ) {
498		var url = wpcf7.apiSettings.root;
499
500		url = url.replace(
501			wpcf7.apiSettings.namespace,
502			wpcf7.apiSettings.namespace + path );
503
504		return url;
505	};
506
507} )( jQuery );
508
509/*
510 * Polyfill for Internet Explorer
511 * See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
512 */
513( function () {
514	if ( typeof window.CustomEvent === "function" ) return false;
515
516	function CustomEvent ( event, params ) {
517		params = params || { bubbles: false, cancelable: false, detail: undefined };
518		var evt = document.createEvent( 'CustomEvent' );
519		evt.initCustomEvent( event,
520			params.bubbles, params.cancelable, params.detail );
521		return evt;
522	}
523
524	CustomEvent.prototype = window.Event.prototype;
525
526	window.CustomEvent = CustomEvent;
527} )();

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.