PageSourceSearch

https://ayuntamientopalaciosdelpan.es/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=4.7

js ayuntamientopalaciosdelpan.es collected 2026-10-03 02:45:15 UTC 13,676 bytes, 507 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	$.fn.wpcf7InitForm = function() {
15		this.ajaxForm( {
16			beforeSubmit: function( arr, $form, options ) {
17				$form.wpcf7ClearResponseOutput();
18				$form.find( '[aria-invalid]' ).attr( 'aria-invalid', 'false' );
19				$form.find( '.ajax-loader' ).addClass( 'is-active' );
20				return true;
21			},
22			beforeSerialize: function( $form, options ) {
23				$form.find( '[placeholder].placeheld' ).each( function( i, n ) {
24					$( n ).val( '' );
25				} );
26				return true;
27			},
28			data: { '_wpcf7_is_ajax_call': 1 },
29			dataType: 'json',
30			success: $.wpcf7AjaxSuccess,
31			error: function( xhr, status, error, $form ) {
32				var e = $( '<div class="ajax-error"></div>' ).text( error.message );
33				$form.after( e );
34			}
35		} );
36
37		if ( _wpcf7.cached ) {
38			this.wpcf7OnloadRefill();
39		}
40
41		this.wpcf7ToggleSubmit();
42
43		this.find( '.wpcf7-submit' ).wpcf7AjaxLoader();
44
45		this.find( '.wpcf7-acceptance' ).click( function() {
46			$( this ).closest( 'form' ).wpcf7ToggleSubmit();
47		} );
48
49		this.find( '.wpcf7-exclusive-checkbox' ).wpcf7ExclusiveCheckbox();
50
51		this.find( '.wpcf7-list-item.has-free-text' ).wpcf7ToggleCheckboxFreetext();
52
53		this.find( '[placeholder]' ).wpcf7Placeholder();
54
55		if ( _wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date ) {
56			this.find( 'input.wpcf7-date[type="date"]' ).each( function() {
57				$( this ).datepicker( {
58					dateFormat: 'yy-mm-dd',
59					minDate: new Date( $( this ).attr( 'min' ) ),
60					maxDate: new Date( $( this ).attr( 'max' ) )
61				} );
62			} );
63		}
64
65		if ( _wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number ) {
66			this.find( 'input.wpcf7-number[type="number"]' ).each( function() {
67				$( this ).spinner( {
68					min: $( this ).attr( 'min' ),
69					max: $( this ).attr( 'max' ),
70					step: $( this ).attr( 'step' )
71				} );
72			} );
73		}
74
75		this.find( '.wpcf7-character-count' ).wpcf7CharacterCount();
76
77		this.find( '.wpcf7-validates-as-url' ).change( function() {
78			$( this ).wpcf7NormalizeUrl();
79		} );
80
81		this.find( '.wpcf7-recaptcha' ).wpcf7Recaptcha();
82	};
83
84	$.wpcf7AjaxSuccess = function( data, status, xhr, $form ) {
85		if ( ! $.isPlainObject( data ) || $.isEmptyObject( data ) ) {
86			return;
87		}
88
89		_wpcf7.inputs = $form.serializeArray();
90
91		var $responseOutput = $form.find( 'div.wpcf7-response-output' );
92
93		$form.wpcf7ClearResponseOutput();
94
95		$form.find( '.wpcf7-form-control' ).removeClass( 'wpcf7-not-valid' );
96		$form.removeClass( 'invalid spam sent failed' );
97
98		if ( data.captcha ) {
99			$form.wpcf7RefillCaptcha( data.captcha );
100		}
101
102		if ( data.quiz ) {
103			$form.wpcf7RefillQuiz( data.quiz );
104		}
105
106		if ( data.invalids ) {
107			$.each( data.invalids, function( i, n ) {
108				$form.find( n.into ).wpcf7NotValidTip( n.message );
109				$form.find( n.into ).find( '.wpcf7-form-control' ).addClass( 'wpcf7-not-valid' );
110				$form.find( n.into ).find( '[aria-invalid]' ).attr( 'aria-invalid', 'true' );
111			} );
112
113			$responseOutput.addClass( 'wpcf7-validation-errors' );
114			$form.addClass( 'invalid' );
115
116			$( data.into ).wpcf7TriggerEvent( 'invalid' );
117
118		} else if ( 1 == data.spam ) {
119			$form.find( '[name="g-recaptcha-response"]' ).each( function() {
120				if ( '' == $( this ).val() ) {
121					var $recaptcha = $( this ).closest( '.wpcf7-form-control-wrap' );
122					$recaptcha.wpcf7NotValidTip( _wpcf7.recaptcha.messages.empty );
123				}
124			} );
125
126			$responseOutput.addClass( 'wpcf7-spam-blocked' );
127			$form.addClass( 'spam' );
128
129			$( data.into ).wpcf7TriggerEvent( 'spam' );
130
131		} else if ( 1 == data.mailSent ) {
132			$responseOutput.addClass( 'wpcf7-mail-sent-ok' );
133			$form.addClass( 'sent' );
134
135			if ( data.onSentOk ) {
136				$.each( data.onSentOk, function( i, n ) { eval( n ) } );
137			}
138
139			$( data.into ).wpcf7TriggerEvent( 'mailsent' );
140
141		} else {
142			$responseOutput.addClass( 'wpcf7-mail-sent-ng' );
143			$form.addClass( 'failed' );
144
145			$( data.into ).wpcf7TriggerEvent( 'mailfailed' );
146		}
147
148		if ( data.onSubmit ) {
149			$.each( data.onSubmit, function( i, n ) { eval( n ) } );
150		}
151
152		$( data.into ).wpcf7TriggerEvent( 'submit' );
153
154		if ( 1 == data.mailSent ) {
155			$form.resetForm();
156		}
157
158		$form.find( '[placeholder].placeheld' ).each( function( i, n ) {
159			$( n ).val( $( n ).attr( 'placeholder' ) );
160		} );
161
162		$responseOutput.append( data.message ).slideDown( 'fast' );
163		$responseOutput.attr( 'role', 'alert' );
164
165		$.wpcf7UpdateScreenReaderResponse( $form, data );
166	};
167
168	$.fn.wpcf7TriggerEvent = function( name ) {
169		return this.each( function() {
170			var elmId = this.id;
171			var inputs = _wpcf7.inputs;
172
173			/* DOM event */
174			var event = new CustomEvent( 'wpcf7' + name, {
175				bubbles: true,
176				detail: {
177					id: elmId,
178					inputs: inputs
179				}
180			} );
181
182			this.dispatchEvent( event );
183
184			/* jQuery event */
185			$( this ).trigger( 'wpcf7:' + name );
186			$( this ).trigger( name + '.wpcf7' ); // deprecated
187		} );
188	};
189
190	$.fn.wpcf7ExclusiveCheckbox = function() {
191		return this.find( 'input:checkbox' ).click( function() {
192			var name = $( this ).attr( 'name' );
193			$( this ).closest( 'form' ).find( 'input:checkbox[name="' + name + '"]' ).not( this ).prop( 'checked', false );
194		} );
195	};
196
197	$.fn.wpcf7Placeholder = function() {
198		if ( _wpcf7.supportHtml5.placeholder ) {
199			return this;
200		}
201
202		return this.each( function() {
203			$( this ).val( $( this ).attr( 'placeholder' ) );
204			$( this ).addClass( 'placeheld' );
205
206			$( this ).focus( function() {
207				if ( $( this ).hasClass( 'placeheld' ) ) {
208					$( this ).val( '' ).removeClass( 'placeheld' );
209				}
210			} );
211
212			$( this ).blur( function() {
213				if ( '' === $( this ).val() ) {
214					$( this ).val( $( this ).attr( 'placeholder' ) );
215					$( this ).addClass( 'placeheld' );
216				}
217			} );
218		} );
219	};
220
221	$.fn.wpcf7AjaxLoader = function() {
222		return this.each( function() {
223			$( this ).after( '<span class="ajax-loader"></span>' );
224		} );
225	};
226
227	$.fn.wpcf7ToggleSubmit = function() {
228		return this.each( function() {
229			var form = $( this );
230
231			if ( this.tagName.toLowerCase() != 'form' ) {
232				form = $( this ).find( 'form' ).first();
233			}
234
235			if ( form.hasClass( 'wpcf7-acceptance-as-validation' ) ) {
236				return;
237			}
238
239			var submit = form.find( 'input:submit' );
240
241			if ( ! submit.length ) {
242				return;
243			}
244
245			var acceptances = form.find( 'input:checkbox.wpcf7-acceptance' );
246
247			if ( ! acceptances.length ) {
248				return;
249			}
250
251			submit.removeAttr( 'disabled' );
252			acceptances.each( function( i, n ) {
253				n = $( n );
254
255				if ( n.hasClass( 'wpcf7-invert' ) && n.is( ':checked' )
256						|| ! n.hasClass( 'wpcf7-invert' ) && ! n.is( ':checked' ) ) {
257					submit.attr( 'disabled', 'disabled' );
258				}
259			} );
260		} );
261	};
262
263	$.fn.wpcf7ToggleCheckboxFreetext = function() {
264		return this.each( function() {
265			var $wrap = $( this ).closest( '.wpcf7-form-control' );
266
267			if ( $( this ).find( ':checkbox, :radio' ).is( ':checked' ) ) {
268				$( this ).find( ':input.wpcf7-free-text' ).prop( 'disabled', false );
269			} else {
270				$( this ).find( ':input.wpcf7-free-text' ).prop( 'disabled', true );
271			}
272
273			$wrap.find( ':checkbox, :radio' ).change( function() {
274				var $cb = $( '.has-free-text', $wrap ).find( ':checkbox, :radio' );
275				var $freetext = $( ':input.wpcf7-free-text', $wrap );
276
277				if ( $cb.is( ':checked' ) ) {
278					$freetext.prop( 'disabled', false ).focus();
279				} else {
280					$freetext.prop( 'disabled', true );
281				}
282			} );
283		} );
284	};
285
286	$.fn.wpcf7CharacterCount = function() {
287		return this.each( function() {
288			var $count = $( this );
289			var name = $count.attr( 'data-target-name' );
290			var down = $count.hasClass( 'down' );
291			var starting = parseInt( $count.attr( 'data-starting-value' ), 10 );
292			var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 );
293			var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 );
294
295			var updateCount = function( $target ) {
296				var length = $target.val().length;
297				var count = down ? starting - length : length;
298				$count.attr( 'data-current-value', count );
299				$count.text( count );
300
301				if ( maximum && maximum < length ) {
302					$count.addClass( 'too-long' );
303				} else {
304					$count.removeClass( 'too-long' );
305				}
306
307				if ( minimum && length < minimum ) {
308					$count.addClass( 'too-short' );
309				} else {
310					$count.removeClass( 'too-short' );
311				}
312			};
313
314			$count.closest( 'form' ).find( ':input[name="' + name + '"]' ).each( function() {
315				updateCount( $( this ) );
316
317				$( this ).keyup( function() {
318					updateCount( $( this ) );
319				} );
320			} );
321		} );
322	};
323
324	$.fn.wpcf7NormalizeUrl = function() {
325		return this.each( function() {
326			var val = $.trim( $( this ).val() );
327
328			// check the scheme part
329			if ( val && ! val.match( /^[a-z][a-z0-9.+-]*:/i ) ) {
330				val = val.replace( /^\/+/, '' );
331				val = 'http://' + val;
332			}
333
334			$( this ).val( val );
335		} );
336	};
337
338	$.fn.wpcf7NotValidTip = function( message ) {
339		return this.each( function() {
340			var $into = $( this );
341
342			$into.find( 'span.wpcf7-not-valid-tip' ).remove();
343			$into.append( '<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>' );
344
345			if ( $into.is( '.use-floating-validation-tip *' ) ) {
346				$( '.wpcf7-not-valid-tip', $into ).mouseover( function() {
347					$( this ).wpcf7FadeOut();
348				} );
349
350				$( ':input', $into ).focus( function() {
351					$( '.wpcf7-not-valid-tip', $into ).not( ':hidden' ).wpcf7FadeOut();
352				} );
353			}
354		} );
355	};
356
357	$.fn.wpcf7FadeOut = function() {
358		return this.each( function() {
359			$( this ).animate( {
360				opacity: 0
361			}, 'fast', function() {
362				$( this ).css( { 'z-index': -100 } );
363			} );
364		} );
365	};
366
367	$.fn.wpcf7OnloadRefill = function() {
368		return this.each( function() {
369			var url = $( this ).attr( 'action' );
370
371			if ( 0 < url.indexOf( '#' ) ) {
372				url = url.substr( 0, url.indexOf( '#' ) );
373			}
374
375			var id = $( this ).find( 'input[name="_wpcf7"]' ).val();
376			var unitTag = $( this ).find( 'input[name="_wpcf7_unit_tag"]' ).val();
377
378			$.getJSON( url,
379				{ _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() },
380				function( data ) {
381					if ( data && data.captcha ) {
382						$( '#' + unitTag ).wpcf7RefillCaptcha( data.captcha );
383					}
384
385					if ( data && data.quiz ) {
386						$( '#' + unitTag ).wpcf7RefillQuiz( data.quiz );
387					}
388				}
389			);
390		} );
391	};
392
393	$.fn.wpcf7RefillCaptcha = function( captcha ) {
394		return this.each( function() {
395			var form = $( this );
396
397			$.each( captcha, function( i, n ) {
398				form.find( ':input[name="' + i + '"]' ).clearFields();
399				form.find( 'img.wpcf7-captcha-' + i ).attr( 'src', n );
400				var match = /([0-9]+)\.(png|gif|jpeg)$/.exec( n );
401				form.find( 'input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]' ).attr( 'value', match[ 1 ] );
402			} );
403		} );
404	};
405
406	$.fn.wpcf7RefillQuiz = function( quiz ) {
407		return this.each( function() {
408			var form = $( this );
409
410			$.each( quiz, function( i, n ) {
411				form.find( ':input[name="' + i + '"]' ).clearFields();
412				form.find( ':input[name="' + i + '"]' ).siblings( 'span.wpcf7-quiz-label' ).text( n[ 0 ] );
413				form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[ 1 ] );
414			} );
415		} );
416	};
417
418	$.fn.wpcf7ClearResponseOutput = function() {
419		return this.each( function() {
420			$( this ).find( 'div.wpcf7-response-output' ).hide().empty().removeClass( 'wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked' ).removeAttr( 'role' );
421			$( this ).find( 'span.wpcf7-not-valid-tip' ).remove();
422			$( this ).find( '.ajax-loader' ).removeClass( 'is-active' );
423		} );
424	};
425
426	$.fn.wpcf7Recaptcha = function() {
427		return this.each( function() {
428			var events = 'wpcf7:spam wpcf7:mailsent wpcf7:mailfailed';
429			$( this ).closest( 'div.wpcf7' ).on( events, function( e ) {
430				if ( recaptchaWidgets && grecaptcha ) {
431					$.each( recaptchaWidgets, function( index, value ) {
432						grecaptcha.reset( value );
433					} );
434				}
435			} );
436		} );
437	};
438
439	$.wpcf7UpdateScreenReaderResponse = function( $form, data ) {
440		$( '.wpcf7 .screen-reader-response' ).html( '' ).attr( 'role', '' );
441
442		if ( data.message ) {
443			var $response = $form.siblings( '.screen-reader-response' ).first();
444			$response.append( data.message );
445
446			if ( data.invalids ) {
447				var $invalids = $( '<ul></ul>' );
448
449				$.each( data.invalids, function( i, n ) {
450					if ( n.idref ) {
451						var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) );
452					} else {
453						var $li = $( '<li></li>' ).append( n.message );
454					}
455
456					$invalids.append( $li );
457				} );
458
459				$response.append( $invalids );
460			}
461
462			$response.attr( 'role', 'alert' ).focus();
463		}
464	};
465
466	$.wpcf7SupportHtml5 = function() {
467		var features = {};
468		var input = document.createElement( 'input' );
469
470		features.placeholder = 'placeholder' in input;
471
472		var inputTypes = [ 'email', 'url', 'tel', 'number', 'range', 'date' ];
473
474		$.each( inputTypes, function( index, value ) {
475			input.setAttribute( 'type', value );
476			features[ value ] = input.type !== 'text';
477		} );
478
479		return features;
480	};
481
482	$( function() {
483		_wpcf7.supportHtml5 = $.wpcf7SupportHtml5();
484		$( 'div.wpcf7 > form' ).wpcf7InitForm();
485	} );
486
487} )( jQuery );
488
489/*
490 * Polyfill for Internet Explorer
491 * See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
492 */
493( function () {
494	if ( typeof window.CustomEvent === "function" ) return false;
495
496	function CustomEvent ( event, params ) {
497		params = params || { bubbles: false, cancelable: false, detail: undefined };
498		var evt = document.createEvent( 'CustomEvent' );
499		evt.initCustomEvent( event,
500			params.bubbles, params.cancelable, params.detail );
501		return evt;
502	}
503
504	CustomEvent.prototype = window.Event.prototype;
505
506	window.CustomEvent = CustomEvent;
507} )();

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.