PageSourceSearch

https://cereriamolla.us/DesktopModules/EasyDNNmailChimpPlus/static/edForm/jquery.edForm.js?cdv=618

js cereriamolla.us collected 2026-09-29 22:58:27 UTC 12,649 bytes, 476 lines download raw bytes

1(function ($, undefined) {
2	'use strict';
3
4	var showClass = 'edOverlay__show',
5		bodyClass = 'edOverlay__active',
6		hideDisabledClass = 'edOverlay__hideDisabled';
7
8	var defaultOptions = {
9		additionalClasses: '',
10		content: '',
11		moduleId: 0,
12		showDelay: 0,
13		showOnLeave: false,
14		showOnKeyInHref: '',
15		language: '',
16		showOnScroll: {
17			amount: 0,
18			unit: 'px'
19		},
20		showOnlyOnce: {
21			cookie: '',
22			cookieDuration: 0,
23			successCookieDuration: 0
24		},
25		showByPageviews: {
26			cookie: '',
27			condition: '>=',
28			threshold: 10
29		},
30		showOnQueryConditions: [],
31		showOnUrlHash: '',
32		showOnElementClick: false,
33		onDomInit: undefined,
34		onHide: undefined,
35		disableHide: false,
36		urlParams: ''
37	};
38
39	var escapeRegEx = function (value) {
40		if (!value)
41			return "";
42
43		return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
44	};
45
46	function edOverlay(params) {
47		var self = this;
48
49		self.$body = $('body');
50		self.$window = $(window);
51
52		self.options = $.extend(true, {}, defaultOptions, params);
53		self.shownOnce = false;
54		self.$overlay = $();
55
56		var showConditionDefined = false;
57
58		if (self.options.showDelay > 0) {
59			setTimeout(function () {
60				self.show();
61			}, self.options.showDelay);
62			showConditionDefined = true;
63		}
64
65		if (self.options.showOnLeave) {
66			self.$body.on('mouseleave', function () {
67				if (self.shownOnce)
68					return;
69
70				self.show();
71			});
72			showConditionDefined = true;
73		}
74
75		if (self.options.showOnScroll.amount > 0) {
76			self.$window.on('scroll', function () {
77				if (self.shownOnce)
78					return;
79
80				var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
81					referenceHeight = self.$body.outerHeight(true) - self.$window.height();
82
83				if (
84					self.options.showOnScroll.unit == 'px' && scrollTop >= self.options.showOnScroll.amount ||
85					self.options.showOnScroll.unit == '%' && scrollTop / referenceHeight * 100 >= self.options.showOnScroll.amount
86				)
87					self.show();
88			});
89			showConditionDefined = true;
90		}
91
92		if (self.options.showOnElementClick) {
93			$(self.$body).on('click', '.edMailChimpForm_' + self.options.moduleId, function () {
94				self.show(true);
95			});
96			showConditionDefined = true;
97		}
98
99		if (!showConditionDefined) {
100			self.show();
101		}
102	}
103
104	edOverlay.prototype = {
105		show: function (overrideCookie) {
106			var self = this;
107
108			if (!overrideCookie && self.options.showOnlyOnce.cookie && Cookies.get(self.options.showOnlyOnce.cookie))
109				return;
110
111			var abort = true,
112				showConditionsSet = false;
113
114			if (self.options.showOnKeyInHref) {
115				showConditionsSet = true;
116
117				var keys = self.options.showOnKeyInHref.split(','),
118					i = 0,
119					l = keys.length;
120
121				for (; i < l; i++) {
122					if (location.href.indexOf(encodeURIComponent(keys[i].trim())) == -1)
123						continue;
124
125					abort = false;
126					break;
127				}
128			}
129
130			if (self.options.showOnQueryConditions && self.options.showOnQueryConditions.length) {
131				showConditionsSet = true;
132
133				var i = 0,
134					l = self.options.showOnQueryConditions.length,
135					queryString = self.options.urlParams;
136
137				for (; i < l; i++) {
138					var condition = self.options.showOnQueryConditions[i],
139						regex;
140
141					if (condition.QueryCondition == 0)
142						regex = new RegExp('(&|\\?)' + escapeRegEx(condition.QueryKey) + '=' + escapeRegEx(condition.QueryValue) + '(&|$)', 'ig');
143					else
144						regex = new RegExp('(&|\\?)' + escapeRegEx(condition.QueryKey) + '(=|&|$)', 'ig');
145
146					if (queryString.match(regex)) {
147						abort = false;
148						break;
149					}
150				}
151			}
152
153			if (abort && self.options.showOnUrlHash) {
154				showConditionsSet = true;
155
156				if (location.hash == '#' + self.options.showOnUrlHash)
157					abort = false;
158			}
159
160			if (abort && self.options.showByPageviews.cookie) {
161				showConditionsSet = true;
162
163				var userPageviews = Cookies.get(self.options.showByPageviews.cookie);
164
165				if (
166					(self.options.showByPageviews.condition == '>=' && userPageviews >= self.options.showByPageviews.threshold) ||
167					(self.options.showByPageviews.condition == '<=' && userPageviews <= self.options.showByPageviews.threshold)
168				)
169					abort = false;
170			}
171
172			if (showConditionsSet && abort)
173				return;
174
175			self.shownOnce = true;
176
177			if (self.$overlay.length === 0) {
178				var additionalClasses = '';
179
180				if (self.options.additionalClasses)
181					additionalClasses = ' ' + self.options.additionalClasses;
182
183				if (self.options.disableHide)
184					additionalClasses += ' ' + hideDisabledClass;
185
186				self.$overlay = $(
187						'<div class="edOverlay' + additionalClasses + '">' +
188							'<div class="edOverlay__mainWrapper">' +
189								'<div class="edOverlay__contentWrapper"></div>' +
190								'<div class="edOverlay__hideTrigger"></div>' +
191							'</div>' +
192						'</div>'
193					)
194						.appendTo(self.$body);
195
196				self.$mainWrapper = $('> .edOverlay__mainWrapper', self.$overlay);
197				self.$contentWrapper = $('> .edOverlay__contentWrapper', self.$mainWrapper);
198
199				self.$mainWrapper.on('click', '.edOverlay__hideTrigger', function () {
200					self.hide();
201				});
202
203				self.$contentWrapper.html(self.options.content);
204
205				if (typeof self.options.onDomInit == 'function')
206					self.options.onDomInit.call(self);
207			}
208
209			self.$body.addClass(bodyClass);
210			self.$overlay.addClass(showClass);
211			var requestParams = {
212				portalId: self.options.portalId,
213				moduleId: self.options.moduleId,
214				action: 'increaseviews'
215			};
216			$.ajax({
217				type: 'POST',
218				url: self.options.websiteRoot + 'DesktopModules/EasyDNNmailChimpPlus/Services/UserSubscription.ashx?portalid=' + self.options.portalId+ (self.options.language.length>0?'&language='+self.options.language:''),
219				data: requestParams,
220				timeout: 150000,
221				success: function (response) {
222				}
223			});
224		},
225		hide: function () {
226			var self = this;
227
228			if (self.options.disableHide)
229				return;
230
231			if (self.options.showOnlyOnce.cookie && !Cookies.get(self.options.showOnlyOnce.cookie))
232				Cookies.set(self.options.showOnlyOnce.cookie, '1', { expires: self.options.showOnlyOnce.cookieDuration });
233
234			self.$body.removeClass(bodyClass);
235			self.$overlay.removeClass(showClass);
236
237			if (typeof self.options.onHide == 'function')
238				self.options.onHide.call(self);
239		},
240		enableHide: function () {
241			var self = this;
242
243			self.options.disableHide = false;
244			self.$overlay.removeClass(hideDisabledClass);
245		}
246	};
247
248	window.edOverlay = edOverlay;
249
250})(eds3_5_jq);
251
252(function ($, undefined) {
253	'use strict';
254
255	var requestingClass = 'edForm__requesting';
256
257	var defaultOptions = {
258		portalId: 0,
259		moduleId: 0,
260		websiteRoot: '',
261		language: '',
262		formSelector: '',
263		multiGroupMode: false,
264		successfulSubscriptionRedirect: '',
265		formOverlay: {}
266	};
267
268	var init = function () {
269		var self = this;
270
271		self.validator = self.$form.validate({
272			ignore: "",
273			onsubmit: false
274		});
275
276		self.clearFormAfterResponse = false;
277
278		self.$formWrapper
279			.on('click', '.edForm__subscribe, .edForm__unsubscribe', function (ev) {
280				ev.preventDefault();
281
282				if (self.requestInProgress)
283					return;
284
285				$('.edForm__responseMessage', self.$formWrapper).html('');
286				self.$formWrapper.removeClass('edForm__showResponse edForm__responseError edForm__responseSuccess');
287
288				var $clicked = $(this),
289					requestParams = {
290						portalId: self.options.portalId,
291						moduleId: self.options.moduleId
292					},
293					checkedRadioGroups = {},
294					subscribing = $clicked.hasClass('edForm__subscribe');
295
296				var formValid = true;
297
298				$(':input', self.$formWrapper).each(function () {
299					var $formEl = $(this),
300						elName = $formEl.attr('name');
301
302					if (!elName)
303						return;
304
305					if (!$formEl.valid()) {
306						formValid = false;
307						return;
308					}
309
310					if ($formEl.is('[type="radio"]')) {
311						if (checkedRadioGroups[elName])
312							return;
313
314						checkedRadioGroups[elName] = true;
315
316						var $checkedRadio = $('input[type="radio"][name="' + elName + '"]', self.$formWrapper).filter(':checked');
317
318						if ($checkedRadio.length > 0)
319							requestParams[elName] = $checkedRadio.val();
320
321						return;
322					}
323
324					if (elName.slice(-2) == '[]') {
325						if (!this.checked)
326							return;
327
328						if (requestParams[elName]) {
329							requestParams[elName] += ',' + $formEl.val();
330							return;
331						}
332					}
333
334					requestParams[elName] = $formEl.val();
335				});
336				if (self.options.multiGroupMode) {
337					var anyGroupChecked = false;
338					var checks = $('[type = "checkbox"].eds_multiGroupMode', self.$formWrapper).each(function () {
339						if ($(this).is(':checked')) {
340							anyGroupChecked = true;
341						}
342					});
343					if (!anyGroupChecked)
344						$('#eds_multimode_error_' + self.options.moduleId).css({ 'display': "block" });
345					else
346						$('#eds_multimode_error_' + self.options.moduleId).css({ 'display': "none" });
347
348					if (!anyGroupChecked)
349						formValid = false;
350				}
351
352				if (!formValid)
353					return;
354
355				requestParams.action = subscribing ? 'subscribe' : 'unsubscribe';
356
357				self.requestInProgress = true;
358				self.$formWrapper.addClass(requestingClass);
359
360				var responseMessage = 'Unknown error.',
361					responseStatusClass = 'edForm__responseError';
362
363				$.ajax({
364					type: 'POST',
365					url: self.options.websiteRoot + 'DesktopModules/EasyDNNmailChimpPlus/Services/UserSubscription.ashx?portalid=' + self.options.portalId + (self.options.language.length>0?'&language='+self.options.language:''),
366					data: requestParams,
367					timeout: 150000,
368					success: function (response) {
369						if (!response || !response.status)
370							return;
371
372						responseMessage = response.message;
373
374						if (response.status == 'success') {
375							responseStatusClass = 'edForm__responseSuccess';
376
377							self.clearFormAfterResponse = response.clear;
378
379							if (subscribing && self.formOverlay) {
380								self.formOverlay.enableHide();
381
382								if (self.options.formOverlay.showOnlyOnce)
383									Cookies.set(self.options.formOverlay.showOnlyOnce.cookie, '1', { expires: self.options.formOverlay.showOnlyOnce.successCookieDuration });
384							}
385						}
386					},
387					complete: function () {
388						self.requestInProgress = false;
389						self.$formWrapper.removeClass(requestingClass);
390
391						$('.edForm__responseMessage', self.$formWrapper).html(responseMessage);
392						self.$formWrapper.addClass('edForm__showResponse ' + responseStatusClass);
393					}
394				});
395			})
396			.on('click', '.edForm__closeResponse', function () {
397				if (self.options.successfulSubscriptionRedirect) {
398					location.href = self.options.successfulSubscriptionRedirect;
399					return;
400				}
401
402				self.$formWrapper.removeClass('edForm__showResponse');
403
404				if (self.clearFormAfterResponse)
405					$('input', self.$formWrapper).not('[type="radio"], [type="checkbox"]').val('');
406
407				if (self.formOverlay)
408					self.formOverlay.hide();
409			});
410
411		$('#eds_mailchimp_' + self.options.moduleId + '_selectall', self.$formWrapper).on('change', function () {
412			$('.edmcp__checkBox input[type="checkbox"]', self.$formWrapper).prop('checked', this.checked);
413		});
414	}
415
416	function edForm(el, options) {
417		var self = this;
418
419		self.requestInProgress = false;
420		self.options = options;
421
422		if (options.formOverlay && options.formOverlay.content) {
423			options.formOverlay.onDomInit = function () {
424				self.$form = $('> form', this.$contentWrapper)
425				self.$formWrapper = $('#eds_mailchimp_' + options.moduleId + '_form', self.$form);
426
427				init.call(self);
428			};
429
430			options.formOverlay.onHide = function () {
431				self.validator.resetForm();
432			};
433
434			self.formOverlay = new edOverlay(options.formOverlay);
435			return;
436		}
437
438		self.$form = $(options.formSelector);
439		self.$formWrapper = $(el);
440
441		init.call(self);
442	}
443
444	edForm.prototype = {};
445
446	var instanceKey = 'edFormInstance';
447
448	$.fn.edForm = function (options) {
449		var apiReturn = undefined,
450			args = arguments;
451
452		this.each(function () {
453			var self = this,
454				instance = $.data(self, instanceKey);
455
456			if (!instance) {
457				instance = new edForm(self, $.extend(true, {}, defaultOptions, options));
458				$.data(self, instanceKey, instance);
459			}
460
461			if ($.isPlainObject(options))
462				return;
463
464			apiReturn = instance.api($.extend([], args));
465
466			if (apiReturn != undefined)
467				return false;
468		});
469
470		if (apiReturn == undefined)
471			return this;
472
473		return apiReturn;
474	};
475
476})(eds3_5_jq);

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.