PageSourceSearch

https://www.corbinpatten.com/wp-content/plugins/extensions-for-ele…/js/atomic-form-mask-init.js?ver=2.7.9

js corbinpatten.com collected 2026-10-04 11:57:18 UTC 3,655 bytes, 133 lines download raw bytes

1/**
2 * Input masks for Elementor atomic form (e-form-input), mirroring assets/js/inputmask/new-input-mask.js.
3 */
4(function ($) {
5	'use strict';
6
7	function prepareMaskInputs($root) {
8		$root.find('input.fme-mask-input').each(function () {
9			if (window.CFKEF && typeof CFKEF.prepareMaskInputAttributes === 'function') {
10				CFKEF.prepareMaskInputAttributes(this);
11			}
12		});
13	}
14
15	function getAtomicMaskErrorElement($input, errorClass) {
16		if ($input.hasClass('hide-fme-mask-input')) {
17			return $();
18		}
19		var $wrap = $input.closest('.ccfef-mask-wrapper');
20		if ($wrap.length) {
21			var $err = $wrap.find('.' + errorClass);
22			if (!$err.length) {
23				$err = $input.siblings('.' + errorClass);
24			}
25			if (!$err.length) {
26				$err = $input.next('.mask-error');
27			}
28			return $err;
29		}
30		return $input.closest('.elementor-field-group').find('.' + errorClass);
31	}
32
33	function isAtomicMaskField($input) {
34		return $input.closest('[data-e-type].e-form-base').length > 0;
35	}
36
37	function getAtomicFmeErrorMessages() {
38		if (typeof window.fmeData !== 'undefined' && window.fmeData.errorMessages) {
39			return window.fmeData.errorMessages;
40		}
41		return {};
42	}
43
44	function atomicMaskOpts() {
45		return {
46			errorMessages: getAtomicFmeErrorMessages(),
47			shouldHandle: isAtomicMaskField,
48			shouldValidate: function ($inp) {
49				return !$inp.closest('.cfef-atomic-field-group').hasClass('cfef-hidden');
50			},
51			resolveErrorElement: getAtomicMaskErrorElement,
52		};
53	}
54
55	function bindAtomicFormMaskSubmitGuard() {
56		CFKEF.bindMaskAllowOnceSubmitGuard($, Object.assign({}, atomicMaskOpts(), {
57			formMatch: function ($form) {
58				return $form.closest('[data-e-type].e-form-base').length > 0;
59			},
60			clickSelector: '[data-e-type].e-form-base button[type="submit"]',
61			validate: function ($form) {
62				return CFKEF.maskValidationBlocksSubmit($, $form, atomicMaskOpts());
63			},
64		}));
65	}
66
67	var atomicMaskValidationBound = false;
68
69	function bindAtomicMaskValidation() {
70		if (atomicMaskValidationBound) {
71			return;
72		}
73		atomicMaskValidationBound = true;
74		CFKEF.bindAllMaskValidations($, atomicMaskOpts());
75	}
76
77	function applyMasksInRoot($root) {
78		$root.find('input[data-mask]').each(function () {
79			const $input = $(this);
80			if ($input.data('cflAtomicMaskUi')) {
81				return;
82			}
83			if (typeof CFKEF !== 'undefined' && typeof CFKEF.applyMaskUi === 'function') {
84				CFKEF.applyMaskUi($input);
85			}
86			$input.data('cflAtomicMaskUi', 1);
87		});
88	}
89
90	function initAtomicMasks($scope) {
91		if (!$scope || !$scope.length) {
92			return;
93		}
94		prepareMaskInputs($scope);
95		applyMasksInRoot($scope);
96	}
97
98	function init() {
99		window.addEventListener('elementor/element/render', function (event) {
100			const element = event.detail && event.detail.element;
101			if (!element) {
102				return;
103			}
104			const $el = $(element);
105
106			if ($el.hasClass('e-form-input-base') || $el.hasClass('ccfef-mask-wrapper') || $el.has('.elementor-field-group.mask-enabled')) {
107				const $form = $el.closest('form');
108
109				initAtomicMasks($form.length ? $form : $el);
110			}
111		});
112
113		document.addEventListener('DOMContentLoaded', function () {
114			document.querySelectorAll('[data-e-type].e-form-base').forEach(function (el) {
115				initAtomicMasks($(el));
116			});
117		});
118
119		bindAtomicMaskValidation();
120		bindAtomicFormMaskSubmitGuard();
121	}
122
123	if (typeof elementorFrontend !== 'undefined' && elementorFrontend.hooks) {
124		$(window).on('elementor/frontend/init', function () {
125			elementorFrontend.hooks.addAction('frontend/element_ready/e-form-input.default', function ($element) {
126				const $form = $element.closest('form');
127				initAtomicMasks($form.length ? $form : $element);
128			});
129		});
130	}
131
132	init();
133})(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.