PageSourceSearch

https://www.mtc.es/js/scripts.js

js mtc.es collected 2026-10-02 11:05:23 UTC 7,976 bytes, 275 lines download raw bytes

1(function($) {
2	$('body')
3		.on('click', '.button-subscribe-newsletter', function(){
4			event.preventDefault();
5
6			const idFrom = $(this).parents('form').attr('id');
7			if($(`#${idFrom}-response`).length > 0) {
8				$(`#${idFrom}-response`).remove();
9			}
10			const form = document.getElementById(idFrom)
11			if(form.checkValidity()){
12				$.post($(`#${idFrom}`).attr('action'), $(`#${idFrom}`).serialize())
13					.done(function(response){
14						console.log(response)
15						let alert = `<div class="alert alert-success" id="${idFrom}-response">${response.message}</div>`
16						$(`#${idFrom}`).append(alert);
17					})
18					.error(function(response){
19						console.log(response)
20						let alert = `<div class="alert alert-danger" id="${idFrom}-response">${response.responseJSON.message}</div>`
21						$(`#${idFrom}`).append(alert);
22					});
23			}
24			else {
25				form.reportValidity();
26			}
27		})
28
29	$(function() {
30		try {
31			if (typeof _wpcf7 == 'undefined' || _wpcf7 === null)
32				_wpcf7 = {};
33
34			_wpcf7 = $.extend({ cached: 0 }, _wpcf7);
35
36			_wpcf7.supportHtml5Placeholder
37				= 'placeholder' in document.createElement('input');
38
39			$('div.wpcf7 > form').ajaxForm({
40				beforeSubmit: function(formData, jqForm, options) {
41					jqForm.wpcf7ClearResponseOutput();
42					jqForm.find('img.ajax-loader').css({ visibility: 'visible' });
43					return true;
44				},
45				beforeSerialize: function(jqForm, options) {
46					jqForm.find('[placeholder].placeheld').each(function(i, n) {
47						$(n).val('');
48					});
49					return true;
50				},
51				data: { '_wpcf7_is_ajax_call': 1 },
52				dataType: 'json',
53				success: function(data) {
54					if (! $.isPlainObject(data) || $.isEmptyObject(data))
55						return;
56
57					var ro = $(data.into).find('div.wpcf7-response-output');
58					$(data.into).wpcf7ClearResponseOutput();
59
60					$(data.into).find('.wpcf7-form-control').removeClass('wpcf7-not-valid');
61					$(data.into).find('form.wpcf7-form').removeClass('invalid spam sent failed');
62
63					if (data.captcha)
64						$(data.into).wpcf7RefillCaptcha(data.captcha);
65
66					if (data.quiz)
67						$(data.into).wpcf7RefillQuiz(data.quiz);
68
69					if (data.invalids) {
70						$.each(data.invalids, function(i, n) {
71							$(data.into).find(n.into).wpcf7NotValidTip(n.message);
72							$(data.into).find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid');
73						});
74
75						ro.addClass('wpcf7-validation-errors');
76						$(data.into).find('form.wpcf7-form').addClass('invalid');
77
78						$(data.into).trigger('invalid.wpcf7');
79
80					} else if (1 == data.spam) {
81						ro.addClass('wpcf7-spam-blocked');
82						$(data.into).find('form.wpcf7-form').addClass('spam');
83
84						$(data.into).trigger('spam.wpcf7');
85
86					} else if (1 == data.mailSent) {
87						ro.addClass('wpcf7-mail-sent-ok');
88						$(data.into).find('form.wpcf7-form').addClass('sent');
89
90						if (data.onSentOk)
91							$.each(data.onSentOk, function(i, n) { eval(n) });
92
93						$(data.into).trigger('mailsent.wpcf7');
94
95					} else {
96						ro.addClass('wpcf7-mail-sent-ng');
97						$(data.into).find('form.wpcf7-form').addClass('failed');
98
99						$(data.into).trigger('mailfailed.wpcf7');
100					}
101
102					if (data.onSubmit)
103						$.each(data.onSubmit, function(i, n) { eval(n) });
104
105					$(data.into).trigger('submit.wpcf7');
106
107					if (1 == data.mailSent)
108						$(data.into).find('form').resetForm().clearForm();
109
110					$(data.into).find('[placeholder].placeheld').each(function(i, n) {
111						$(n).val($(n).attr('placeholder'));
112					});
113
114					$(data.into).wpcf7FillResponseOutput(data.message);
115				}
116			});
117
118			$('div.wpcf7 > form').each(function(i, n) {
119				if (_wpcf7.cached)
120					$(n).wpcf7OnloadRefill();
121
122				$(n).wpcf7ToggleSubmit();
123
124				$(n).find('.wpcf7-submit').wpcf7AjaxLoader();
125
126				$(n).find('.wpcf7-acceptance').click(function() {
127					$(n).wpcf7ToggleSubmit();
128				});
129
130				$(n).find('.wpcf7-exclusive-checkbox').each(function(i, n) {
131					$(n).find('input:checkbox').click(function() {
132						$(n).find('input:checkbox').not(this).removeAttr('checked');
133					});
134				});
135
136				$(n).find('[placeholder]').each(function(i, n) {
137					var input = $(n);
138
139					if (_wpcf7.supportHtml5Placeholder)
140						return;
141
142					input.val(input.attr('placeholder'));
143					input.addClass('placeheld');
144
145					input.focus(function() {
146						if ($(this).hasClass('placeheld'))
147							$(this).val('').removeClass('placeheld');
148					});
149
150					input.blur(function() {
151						if ('' == $(this).val()) {
152							$(this).val($(this).attr('placeholder'));
153							$(this).addClass('placeheld');
154						}
155					});
156				});
157			});
158
159		} catch (e) {
160		}
161	});
162
163	$.fn.wpcf7AjaxLoader = function() {
164		return this.each(function() {
165			var loader = $('<img class="ajax-loader" />')
166				.attr({ src: _wpcf7.loaderUrl, alt: _wpcf7.sending })
167				.css('visibility', 'hidden');
168
169			$(this).after(loader);
170		});
171	};
172
173	$.fn.wpcf7ToggleSubmit = function() {
174		return this.each(function() {
175			var form = $(this);
176			if (this.tagName.toLowerCase() != 'form')
177				form = $(this).find('form').first();
178
179			if (form.hasClass('wpcf7-acceptance-as-validation'))
180				return;
181
182			var submit = form.find('input:submit');
183			if (! submit.length) return;
184
185			var acceptances = form.find('input:checkbox.wpcf7-acceptance');
186			if (! acceptances.length) return;
187
188			submit.removeAttr('disabled');
189			acceptances.each(function(i, n) {
190				n = $(n);
191				if (n.hasClass('wpcf7-invert') && n.is(':checked')
192				|| ! n.hasClass('wpcf7-invert') && ! n.is(':checked'))
193					submit.attr('disabled', 'disabled');
194			});
195		});
196	};
197
198	$.fn.wpcf7NotValidTip = function(message) {
199		return this.each(function() {
200			var into = $(this);
201			into.append('<span class="wpcf7-not-valid-tip">' + message + '</span>');
202			$('span.wpcf7-not-valid-tip').mouseover(function() {
203				$(this).fadeOut('fast');
204			});
205			into.find(':input').mouseover(function() {
206				into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast');
207			});
208			into.find(':input').focus(function() {
209				into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast');
210			});
211		});
212	};
213
214	$.fn.wpcf7OnloadRefill = function() {
215		return this.each(function() {
216			var url = $(this).attr('action');
217			if (0 < url.indexOf('#'))
218				url = url.substr(0, url.indexOf('#'));
219
220			var id = $(this).find('input[name="_wpcf7"]').val();
221			var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val();
222
223			$.getJSON(url,
224				{ _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() },
225				function(data) {
226					if (data && data.captcha)
227						$('#' + unitTag).wpcf7RefillCaptcha(data.captcha);
228
229					if (data && data.quiz)
230						$('#' + unitTag).wpcf7RefillQuiz(data.quiz);
231				}
232			);
233		});
234	};
235
236	$.fn.wpcf7RefillCaptcha = function(captcha) {
237		return this.each(function() {
238			var form = $(this);
239
240			$.each(captcha, function(i, n) {
241				form.find(':input[name="' + i + '"]').clearFields();
242				form.find('img.wpcf7-captcha-' + i).attr('src', n);
243				var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n);
244				form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]);
245			});
246		});
247	};
248
249	$.fn.wpcf7RefillQuiz = function(quiz) {
250		return this.each(function() {
251			var form = $(this);
252
253			$.each(quiz, function(i, n) {
254				form.find(':input[name="' + i + '"]').clearFields();
255				form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]);
256				form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]);
257			});
258		});
259	};
260
261	$.fn.wpcf7ClearResponseOutput = function() {
262		return this.each(function() {
263			$(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked');
264			$(this).find('span.wpcf7-not-valid-tip').remove();
265			$(this).find('img.ajax-loader').css({ visibility: 'hidden' });
266		});
267	};
268
269	$.fn.wpcf7FillResponseOutput = function(message) {
270		return this.each(function() {
271			$(this).find('div.wpcf7-response-output').append(message).slideDown('fast');
272		});
273	};
274
275})(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.