PageSourceSearch

https://www.dornre.com/wp-content/plugins/placester/js/frontend/custom-landing.js

js dornre.com collected 2026-10-10 02:14:20 UTC 5,806 bytes, 185 lines download raw bytes

1/**
2* Form Validation used from jquerytools.org
3*
4*/
5
6var createCookie = function (name,value,minutes) {
7	if (minutes) {
8		var date = new Date();
9		date.setTime(date.getTime()+(minutes*60*1000));
10		var expires = "; expires="+date.toGMTString();
11	} else {
12		var expires = "";
13	}
14	document.cookie = name+"="+value+expires+"; path=/";
15};
16
17jQuery(document).ready(function($) {
18
19	setTimeout(function(){
20		$('[name="a_password"]').remove();
21	}, 10000);
22
23	var clear_form = function(form) {
24		form.find('input[type="text"], input[type="email"], input[type="phone"], textarea').val('');
25	};
26
27	var shouldFireFbPixelLeadEvent = _placester.entitlementsHandler.shouldFireFbPixelLeadEvent();
28	var hasPixelId = (_placester && _placester.fbPixelConfig && _placester.fbPixelConfig.fb_pixel_id) ? true : false;
29
30	if ($.fn.validator) {
31		// Validating on mousedown to beat Chrome to validation
32		$('.custom-form form input[type="submit"]').on('mousedown', function(e) {
33			// You always needs to download [0] because of checkValidity requirements
34			var form = $($(e.target).parents('form')[0]);
35			var messageClass = 'form-validator-error';
36			// Manual checkbox group validation
37			// TODO Use updated jQuery form validate plugin.
38			form.find('.checkbox-group[data-required=required]')
39				.each(function(i, el) {
40					el = $(el);
41					var cb = el.find('input[type=checkbox]:first');
42					if (!el.has('input[type=checkbox]:checked').length) {
43						var pos = el.position();
44						$('<div><span></span><p style="display: inline"></p></div>')
45							.addClass(messageClass)
46							.css({
47								position: 'absolute',
48								left: (pos.left - 65) + 'px',
49								top: pos.top + 'px'
50							})
51							.appendTo(document.body)
52							.find('p')
53							.text('Please select an option.');
54						cb.addClass('invalid');
55					} else {
56						cb.removeClass('invalid');
57					}
58				});
59
60			// get fields that are required from form and execute validator()
61			var inputs = form.find("input[required]:not(.stop-validation), textarea[required]").validator({
62				messageClass: messageClass,
63				message: '<div><span></span></div>',
64				position: 'top center'
65			});
66			// check required field's validity
67			inputs.data("validator").checkValidity();
68		});
69	}
70
71	// Submit
72	$('.custom-form form').submit(function(event) {
73		var widget = $(this).parent();
74		var str = $(this).serialize();
75		var form_uii = $(this).data('uii');
76		var form = $(this);
77
78		event.preventDefault();
79
80		// Stop bots from sending too many forms.
81		if ( $('[name="a_password"]').val() !== undefined ) {
82			widget.find(".error").show();
83			return false;
84		}
85
86		widget.find(".error").hide();
87
88		//PROM-XXXX : Removed the validation error tool tip after 5 seconds since they remain there forever until filled
89		//which causes issues on mobile view and user is unable to operate the UI properly.
90		setTimeout(function() {
91			$(".form-validator-error").hide();
92		}, 5000);
93
94		// Check for invalid fields. This is needed because autofill will allow the form to submit
95		if ($('.invalid', this).length) {
96			return false;
97		};
98
99		// Show loading
100		widget.find('.custom-landing--formLoading').show();
101
102		// If we get this far, send the contact form along!
103		jQuery.ajax({
104			type: 'POST',
105			url: info.ajaxurl,
106			data: 'action=placester_custom_contact&is_lead=true&' + str,
107			dataType: 'json',
108			success: function(result) {
109				if (result.error === '') { // Success!
110					// Firing FB lead event notification
111					if (hasPixelId && shouldFireFbPixelLeadEvent) {
112						try {
113							fbq('track', 'Lead');
114						} catch (err) {
115							console.warn("Error tracking Facebook Pixel event.");
116						}
117					}
118					// hide spinner
119					widget.find('.custom-landing--formLoading').fadeOut('fast');
120					if (typeof pl_inject_conversion_snippet === 'function')
121					pl_inject_conversion_snippet();
122					form.addClass('form_submitted');
123					form.find('input[type="submit"]').val('Sent!');
124					clear_form(form);
125					// remove all form errors and slide up the form
126					form.find('.form-validator-error').remove();
127					form.slideUp();
128
129					// Show success message
130					setTimeout(function() {
131						$(".sub-title").hide();
132						widget.find(".success").show('fast');
133						// mark contact form as submitted so lead capture's force-back functionality doesn't fire
134						form.find("input[name='form_submitted']").val(1);
135						createCookie('pl_contact_cookie','true', 0.5);
136					}, 500);
137
138					pl_membership.setLeadCaptured();
139					if (typeof _placester.uii === 'object' && result.lead_uuid) {
140						_placester.uii.addToPayLoad('lead_uuid', result.lead_uuid, true);
141						_placester.uii.send({
142							event: form_uii,
143							interaction_data: {
144								action: "submit-success",
145								result: result,
146								element_data_type: "target",
147								element_data: _placester.uii.getElementData(form.get(0))
148							},
149							form_data: _placester.uii.formSerializer(form.get(0))
150						});
151					}
152
153					// Redirection if success only.
154					if (result.account_created && result.account_url) {
155						setTimeout(function() {
156							window.location.href = result.account_url;
157						}, 3000);
158					} else if (result.redirect) {
159						window.open(result.redirect, result.redirect_target);
160					}
161
162				} else { // Unsuccessful!
163					// hide spinner
164					widget.find('.custom-landing--formLoading').hide();
165					widget.find(".error").html(result.error).show('fast');
166
167					if (typeof _placester.uii === 'object') {
168						// track server error
169						_placester.uii.send({
170							event: form_uii,
171							interaction_data: {
172								action: "submit-error",
173								result: result,
174								element_data_type: "target",
175								element_data: _placester.uii.getElementData(form.get(0))
176							},
177							form_data: _placester.uii.formSerializer(form.get(0))
178						});
179					}
180				}
181			}
182		});
183	});
184
185});

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.