PageSourceSearch

https://heritage.edu/wp-content/themes/enfold/config-templatebuild…/contact/contact.js?ver=5.6.12

js heritage.edu collected 2026-10-01 11:53:45 UTC 10,701 bytes, 396 lines download raw bytes

1// -------------------------------------------------------------------------------------------
2// contact form ajax
3// -------------------------------------------------------------------------------------------
4
5(function($)
6{
7	$.fn.avia_ajax_form = function(variables)
8	{
9		var defaults =
10		{
11			sendPath: 'send.php',
12			responseContainer: '.ajaxresponse'
13		};
14
15		var options = $.extend(defaults, variables);
16
17		return this.each(function()
18		{
19			var form = $(this),
20				form_sent = false,
21				msgFieldsWithError = form.data( 'fields-with-error' ),
22				send =
23				{
24					formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
25					validationError:false,
26					button : form.find('input:submit'),
27					dataObj : {},
28					withError: []
29				},
30
31				responseContainer = form.next(options.responseContainer).eq( 0 );
32
33				send.button.on('click', checkElements);
34
35
36				//change type of email forms on mobile so the e-mail keyboard with @ sign is used
37				if($.avia_utilities.isMobile)
38				{
39					send.formElements.each(function(i)
40					{
41						var currentElement = $(this),
42							is_email = currentElement.hasClass('is_email');
43
44						if(is_email) currentElement.attr('type','email');
45					});
46				}
47
48
49			function checkElements( e )
50			{
51				// reset validation var and send data
52				send.validationError = false;
53				send.datastring = 'ajax=true';
54
55				//	Get in js added element (e.g. from reCAPTCHA)
56				send.formElements = form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden], input[type=email]');
57
58				send.formElements.each( function(i)
59				{
60					var currentElement = $(this),
61						surroundingElement = currentElement.parent(),
62						value = currentElement.val(),
63						label = surroundingElement.find("label").text().replace(/\*/g, '').trim(),
64						name = currentElement.attr('name'),
65						classes = currentElement.attr('class'),
66						nomatch = true;
67
68					if( currentElement.is(':checkbox') )
69					{
70						if( currentElement.is(':checked') )
71						{
72							value = true;
73						}
74						else
75						{
76							value = '';
77						}
78					}
79
80					send.dataObj[name] = encodeURIComponent(value);
81
82					if(classes && classes.match(/is_empty/))
83					{
84						if(value == '' || value == null)
85						{
86							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
87							send.validationError = true;
88							send.withError.push(label);
89						}
90						else
91						{
92							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
93						}
94						nomatch = false;
95					}
96
97					if(classes && classes.match(/is_email/))
98					{
99						if( ! value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
100						{
101							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
102							send.validationError = true;
103							send.withError.push(label);
104						}
105						else
106						{
107							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
108						}
109						nomatch = false;
110					}
111
112					if(classes && classes.match(/is_ext_email/))
113					{
114						if( ! value.match( /^[\w\.\-ÄÖÜäöü]+@\w[\w\.\-ÄÖÜäöü]*\.[a-zA-Z]{2,20}$/ ) )
115						{
116							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
117							send.validationError = true;
118							send.withError.push(label);
119						}
120						else
121						{
122							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
123						}
124						nomatch = false;
125					}
126
127					if(classes && classes.match(/is_special_email/))
128					{
129						//  also allowed would be: ! # $ % & ' * + - / = ? ^ _ ` { | } ~  see https://de.wikipedia.org/wiki/E-Mail-Adresse#Der_Lokalteil_(Local_Part)
130						if( ! value.match( /^[a-zA-Z0-9.!#$%&'*+\-\/=?^_`{|}~ÄÖÜäöü]+@\w[\w\.\-ÄÖÜäöü]*\.[a-zA-Z]{2,20}$/ ) )
131						{
132							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
133							send.validationError = true;
134							send.withError.push(label);
135						}
136						else
137						{
138							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
139						}
140						nomatch = false;
141					}
142
143					if(classes && classes.match(/is_phone/))
144					{
145						if( ! value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
146						{
147							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
148							send.validationError = true;
149							send.withError.push(label);
150						}
151						else
152						{
153							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
154						}
155						nomatch = false;
156					}
157
158					if(classes && classes.match(/is_number/))
159					{
160						if( ! value.match( /^-?\s*(0|[1-9]\d*)([\.,]\d+)?$/ ) )
161						{
162							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
163							send.validationError = true;
164							send.withError.push(label);
165						}
166						else
167						{
168							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
169						}
170						nomatch = false;
171					}
172
173					if(classes && classes.match(/is_positiv_number/))
174					{
175						if( ! ( av_isNumeric( value ) ) || value == "" || value < 0 )
176						{
177							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
178							send.validationError = true;
179							send.withError.push(label);
180						}
181						else
182						{
183							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
184						}
185						nomatch = false;
186					}
187
188					if(classes && classes.match(/captcha/) && ! classes.match(/recaptcha/) )
189					{
190						var verifier 	= form.find("#" + name + "_verifier").val(),
191							lastVer		= verifier.charAt(verifier.length-1),
192							finalVer	= verifier.charAt(lastVer);
193
194						if(value != finalVer)
195						{
196							surroundingElement.removeClass("valid error ajax_alert").addClass("error");
197							send.validationError = true;
198						}
199						else
200						{
201							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
202						}
203						nomatch = false;
204					}
205
206					if(nomatch && value != '')
207					{
208						surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
209					}
210				});
211
212				form.find( '.av-fields-with-error' ).remove();
213
214				if( send.validationError == false )
215				{
216					if(form.data('av-custom-send'))
217					{
218						mailchimp_send();
219					}
220					else
221					{
222						send_ajax_form();
223					}
224				}
225				else
226				{
227					if( form.is('.av-show-form-errors') && send.withError.length > 0 )
228					{
229						var withErrorFields = send.withError.join(', ');
230						var withErrorContainer = $('<p class="av-fields-with-error"></p').insertAfter( $(send.button).parent() );
231
232						let msg = msgFieldsWithError ? msgFieldsWithError + ' ' : 'Found errors in the following field(s): ';
233						withErrorContainer.text( msg + withErrorFields);
234						send.withError = [];
235					}
236				}
237
238				return false;
239			}
240
241
242			function send_ajax_form()
243			{
244				if( form_sent )
245				{
246					return false;
247				}
248
249				if( send.button.hasClass( 'avia_button_inactive' ) )
250				{
251					return false;
252				}
253
254				form_sent = true;
255				send.button.addClass('av-sending-button');
256				send.button.val(send.button.data('sending-label'));
257
258				var redirect_to = form.data('avia-redirect') || false,
259				    action = form.attr('action'),
260				    label = form.is( '.av-form-labels-style' );
261
262				if( label )
263				{
264					return;
265				}
266
267				responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
268				{
269					if(redirect_to && action != redirect_to)
270					{
271						form.attr('action', redirect_to);
272						location.href = redirect_to;
273						// form.submit();
274					}
275					else
276					{
277						responseContainer.removeClass('hidden').css({display:"block"});
278						form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
279					}
280				});
281			}
282
283
284			function mailchimp_send()
285			{
286				if(form_sent)
287				{
288					return false;
289				}
290
291				form_sent = true;
292
293				var original_label = send.button.val();
294
295				send.button.addClass('av-sending-button');
296				send.button.val(send.button.data('sending-label'));
297				send.dataObj.ajax_mailchimp = true;
298
299				var redirect_to 		= form.data('avia-redirect') || false,
300					action				= form.attr('action'),
301					error_msg_container = form.find('.av-form-error-container'),
302					form_id 			= form.data('avia-form-id');
303
304				$.ajax({
305					url: action,
306					type: "POST",
307					data:send.dataObj,
308					beforeSend: function()
309					{
310						if(error_msg_container.length)
311						{
312							error_msg_container.slideUp(400, function()
313							{
314								error_msg_container.remove();
315								$('body').trigger('av_resize_finished');
316							});
317						}
318					},
319					success: function(responseText)
320					{
321						var response	= jQuery("<div>").append(jQuery.parseHTML(responseText)),
322							error		= response.find('.av-form-error-container');
323
324						if(error.length)
325						{
326							form_sent = false;
327							form.prepend(error);
328							error.css({display:"none"}).slideDown(400, function()
329							{
330								$('body').trigger('av_resize_finished');
331							});
332
333							send.button.removeClass('av-sending-button');
334							send.button.val(original_label);
335						}
336						else
337						{
338							if(redirect_to && action != redirect_to)
339							{
340								form.attr('action', redirect_to);
341								location.href = redirect_to;
342								// form.submit();
343							}
344							else
345							{
346								var success_text = response.find(options.responseContainer + "_" + form_id);
347
348								responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
349
350								form.slideUp(400, function()
351								{
352									responseContainer.slideDown(400, function()
353									{
354										$('body').trigger('av_resize_finished');
355									});
356
357								send.formElements.val('');
358							});
359							}
360						}
361
362					},
363					error: function()
364					{
365
366					},
367					complete: function()
368					{
369
370					}
371				});
372
373			}
374
375			/**
376			 * jQuery.isNumeric() is deprecated with 3.3
377			 * This is the replacement implementation
378			 *
379			 * As of jQuery 3.0, isNumeric is limited to strings and numbers (primitives or objects) that can be coerced to finite numbers (gh-2662)
380			 * parseFloat NaNs numeric-cast false positives ("") ...but misinterprets leading-number strings, particularly hex literals ("0x...")
381			 * subtraction forces infinities to NaN
382			 *
383			 * @since 4.9.1
384			 * @param {mixed} obj
385			 * @returns {boolean}
386			 */
387			function av_isNumeric( obj )
388			{
389				//	Fix for Android < 2.3 from jQuery has been skipped (release date 2010)
390				var type = typeof obj;
391				return ( type === "number" || type === "string" ) && ! isNaN( obj - parseFloat( obj ) );
392			}
393
394		});
395	};
396})(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.