PageSourceSearch

https://dmstechnology.com/wp-content/themes/enfold/config-template…?ver=52e2849b5fc9fccfd5aa142ee564ac54

js dmstechnology.com collected 2026-10-04 05:23:12 UTC 7,813 bytes, 301 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				send =
22				{
23					formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
24					validationError:false,
25					button : form.find('input:submit'),
26					dataObj : {}
27				},
28
29				responseContainer = form.next(options.responseContainer+":eq(0)");
30
31				send.button.on('click', checkElements);
32				
33				
34				//change type of email forms on mobile so the e-mail keyboard with @ sign is used
35				if($.avia_utilities.isMobile)
36				{
37					send.formElements.each(function(i)
38					{
39						var currentElement = $(this), is_email = currentElement.hasClass('is_email');
40						if(is_email) currentElement.attr('type','email');
41					});
42				}
43			
44
45			function checkElements( e )
46			{
47				// reset validation var and send data
48				send.validationError = false;
49				send.datastring = 'ajax=true';
50
51				send.formElements.each(function(i)
52				{
53					var currentElement = $(this),
54						surroundingElement = currentElement.parent(),
55						value = currentElement.val(),
56						name = currentElement.attr('name'),
57					 	classes = currentElement.attr('class'),
58					 	nomatch = true;
59
60					 	if(currentElement.is(':checkbox'))
61					 	{
62					 		if(currentElement.is(':checked')) { value = true } else {value = ''}
63					 	}
64					 	
65					 	send.dataObj[name] = encodeURIComponent(value);
66
67					 	if(classes && classes.match(/is_empty/))
68						{
69							if(value == '' || value == null)
70							{
71								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
72								send.validationError = true;
73							}
74							else
75							{
76								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
77							}
78							nomatch = false;
79						}
80
81						if(classes && classes.match(/is_email/))
82						{
83							if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
84							{
85								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
86								send.validationError = true;
87							}
88							else
89							{
90								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
91							}
92							nomatch = false;
93						}
94						
95						if(classes && classes.match(/is_ext_email/))
96						{
97							//  also allowed would be: ! # $ % & ' * + - / = ? ^ _ ` { | } ~
98							if( ! value.match( /^[\w|\.|\-|ÄÖÜäöü]+@\w[\w|\.|\-|ÄÖÜäöü]*\.[a-zA-Z]{2,20}$/ ) )
99							{
100								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
101								send.validationError = true;
102							}
103							else
104							{
105								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
106							}
107							nomatch = false;
108						}
109						
110						if(classes && classes.match(/is_phone/))
111						{
112							if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
113							{
114								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
115								send.validationError = true;
116							}
117							else
118							{
119								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
120							}
121							nomatch = false;
122						}
123
124						if(classes && classes.match(/is_number/))
125						{
126							if(!($.isNumeric(value)) || value == "")
127							{
128								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
129								send.validationError = true;
130							}
131							else
132							{
133								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
134							}
135							nomatch = false;
136						}
137
138						if(classes && classes.match(/captcha/))
139						{
140							var verifier 	= form.find("#" + name + "_verifier").val(),
141								lastVer		= verifier.charAt(verifier.length-1),
142								finalVer	= verifier.charAt(lastVer);
143
144							if(value != finalVer)
145							{
146								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
147								send.validationError = true;
148							}
149							else
150							{
151								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
152							}
153							nomatch = false;
154						}
155
156						if(nomatch && value != '')
157						{
158							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
159						}
160				});
161
162				if(send.validationError == false)
163				{
164					if(form.data('av-custom-send'))
165					{
166						mailchimp_send();	
167					}
168					else
169					{
170						send_ajax_form();
171					}
172				}
173				
174				return false;
175			}
176			
177			
178			function send_ajax_form()
179			{
180				if(form_sent){ return false; }
181
182				form_sent = true;
183				send.button.addClass('av-sending-button');
184				send.button.val(send.button.data('sending-label'));
185				
186				var redirect_to = form.data('avia-redirect') || false,
187					action		= form.attr('action');
188				
189				responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
190				{
191					if(redirect_to && action != redirect_to)
192					{
193						form.attr('action', redirect_to);
194						location.href = redirect_to;
195						// form.submit();
196					}
197					else
198					{
199						responseContainer.removeClass('hidden').css({display:"block"});
200						form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
201					}
202				});
203			}
204			
205			
206			function mailchimp_send()
207			{
208				if(form_sent){ return false; }
209
210				form_sent = true;
211				
212				var original_label = send.button.val();
213
214				send.button.addClass('av-sending-button');
215				send.button.val(send.button.data('sending-label'));
216				send.dataObj.ajax_mailchimp = true;
217				
218				var redirect_to 		= form.data('avia-redirect') || false,
219					action				= form.attr('action'),
220					error_msg_container = form.find('.av-form-error-container'),
221					form_id 			= form.data('avia-form-id'); 
222				
223				$.ajax({
224					url: action,
225					type: "POST",
226					data:send.dataObj,
227					beforeSend: function()
228					{
229						if(error_msg_container.length)
230						{
231							error_msg_container.slideUp(400, function()
232							{
233								error_msg_container.remove();
234								$('body').trigger('av_resize_finished');
235							});
236						}
237					},
238					success: function(responseText)
239					{
240						var response	= jQuery("<div>").append(jQuery.parseHTML(responseText)),
241							error		= response.find('.av-form-error-container');	
242						
243						if(error.length)
244						{
245							form_sent = false;
246							form.prepend(error);
247							error.css({display:"none"}).slideDown(400, function()
248							{
249								$('body').trigger('av_resize_finished');
250							});
251
252							send.button.removeClass('av-sending-button');
253							send.button.val(original_label);
254						}
255						else
256						{
257							if(redirect_to && action != redirect_to)
258							{
259								form.attr('action', redirect_to);
260								location.href = redirect_to;
261								// form.submit();
262							}
263							else
264							{
265								var success_text = response.find(options.responseContainer + "_" + form_id);
266								
267								responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
268								
269								form.slideUp(400, function()
270								{
271									responseContainer.slideDown(400, function()
272									{ 
273										$('body').trigger('av_resize_finished'); 
274									});
275									
276								send.formElements.val('');
277							});
278							}
279						}
280						
281					},
282					error: function()
283					{
284						
285					},
286					complete: function()
287					{
288					    
289					}
290				});
291
292			}
293			
294			
295		});
296	};
297})(jQuery);
298
299
300
301

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.