PageSourceSearch

https://www.automha.it/wp-content/plugins/jet-popup/includes/eleme…jet-popup-elementor-frontend.js?ver=2.0.2.1

js automha.it collected 2026-09-24 10:29:08 UTC 9,078 bytes, 327 lines download raw bytes

1( function( $, elementor ) {
2
3	'use strict';
4
5	window.JetPopupElementorFrontend = {
6
7		init: function() {
8
9			if ( ! elementor ) {
10				return false;
11			}
12
13			elementor.hooks.addAction( 'frontend/element_ready/widget', JetPopupElementorFrontend.elementorWidget );
14
15			const widgets = {
16				'jet-popup-action-button.default' : JetPopupElementorFrontend.widgetPopupActionButton,
17				'jet-popup-mailchimp.default' : JetPopupElementorFrontend.widgetPopupMailchimp
18			};
19
20			$.each( widgets, function( widget, callback ) {
21				elementor.hooks.addAction( 'frontend/element_ready/' + widget, callback );
22			} );
23		},
24
25		elementorWidget: function( $scope ) {
26			let widget_id     = $scope.data( 'id' ),
27				widgetType    = $scope.data( 'element_type' ),
28				popupSettings = $scope.data( 'jet-popup' ) || false;
29
30			if ( popupSettings ) {
31				let openEvent     = popupSettings[ 'trigger-type' ],
32					customSelector = popupSettings[ 'trigger-custom-selector' ],
33					popupData      = {
34						popupId: popupSettings[ 'attached-popup' ]
35					};
36
37				if ( $scope.hasClass( 'jet-popup-attach-event-inited' ) ) {
38					return false;
39				}
40
41				$scope.addClass( 'jet-popup-attach-event-inited' );
42
43				switch( openEvent ) {
44					case 'click-self':
45						$scope.addClass( 'jet-popup-cursor-pointer' );
46
47						$scope.on( 'click.JetPopup', function( event ) {
48							event.preventDefault();
49
50							var $target = $( this );
51
52							if ( elementor.hooks ) {
53								popupData = elementor.hooks.applyFilters(
54									'jet-popup/widget-extensions/popup-data',
55									popupData,
56									popupSettings,
57									$scope,
58									event
59								);
60							}
61
62							$( window ).trigger( {
63								type: 'jet-popup-open-trigger',
64								popupData: popupData,
65								triggeredBy: $scope,
66							} );
67
68							return false;
69						} );
70						break;
71					case 'click':
72						$scope.on( 'click.JetPopup', '.elementor-button, .jet-button__instance .jet-popup-action-button__instance', function( event ) {
73							event.preventDefault();
74
75							if ( elementor.hooks ) {
76								popupData = elementor.hooks.applyFilters(
77									'jet-popup/widget-extensions/popup-data',
78									popupData,
79									popupSettings,
80									$scope,
81									event
82								);
83							}
84
85							$( window ).trigger( {
86								type: 'jet-popup-open-trigger',
87								popupData: popupData,
88								triggeredBy: $( this ),
89							} );
90
91							return false;
92						} );
93						break;
94					case 'click-selector':
95
96						if ( '' !== customSelector ) {
97							$( customSelector ).addClass( 'jet-popup-cursor-pointer' );
98
99							$scope.on( 'click.JetPopup', customSelector, function( event ) {
100								event.preventDefault();
101
102								var $target = $( event.currentTarget );
103
104								$target.addClass( 'jet-popup-cursor-pointer' );
105
106								if ( elementor.hooks ) {
107									popupData = elementor.hooks.applyFilters(
108										'jet-popup/widget-extensions/popup-data',
109										popupData,
110										popupSettings,
111										$scope,
112										event
113									);
114								}
115
116								$( window ).trigger( {
117									type: 'jet-popup-open-trigger',
118									popupData: popupData,
119									triggeredBy: $target,
120								} );
121
122								return false;
123							} );
124						}
125						break;
126					case 'hover':
127						$scope.on( 'mouseenter.JetPopup', function( event ) {
128
129							if ( elementor.hooks ) {
130								popupData = elementor.hooks.applyFilters(
131									'jet-popup/widget-extensions/popup-data',
132									popupData,
133									popupSettings,
134									$scope,
135									event
136								);
137							}
138
139							$( window ).trigger( {
140								type: 'jet-popup-open-trigger',
141								popupData: popupData,
142								triggeredBy: $scope,
143							} );
144						} );
145						break;
146					case 'scroll-to':
147						elementor.waypoint( $scope, function( event ) {
148
149							if ( elementor.hooks ) {
150								popupData = elementor.hooks.applyFilters(
151									'jet-popup/widget-extensions/popup-data',
152									popupData,
153									popupSettings,
154									$scope,
155									event
156								);
157							}
158
159							$( window ).trigger( {
160								type: 'jet-popup-open-trigger',
161								popupData: popupData,
162								triggeredBy: $scope,
163							} );
164						}, {
165							offset: 'bottom-in-view'
166						} );
167						break;
168				}
169			}
170		},
171
172		widgetPopupActionButton: function( $scope ) {
173			var $button    = $( '.jet-popup-action-button__instance', $scope ),
174				settings   = $button.data( 'settings' ),
175				actionType = settings['action-type'];
176
177			window.JetPopupFrontend.actionButtonHandle( $button, actionType );
178		},
179
180		widgetPopupMailchimp: function( $scope ) {
181			var $target               = $scope.find( '.jet-popup-mailchimp' ),
182				scoreId               = $scope.data( 'id' ),
183				settings              = $target.data( 'settings' ),
184				$subscribeForm        = $( '.jet-popup-mailchimp__form', $target ),
185				$fields                = $( '.jet-popup-mailchimp__fields', $target ),
186				$mailField            = $( '.jet-popup-mailchimp__mail-field', $target ),
187				$inputData            = $mailField.data( 'instance-data' ),
188				$submitButton         = $( '.jet-popup-mailchimp__submit', $target ),
189				$subscribeFormMessage = $( '.jet-popup-mailchimp__message', $target ),
190				invalidMailMessage    = 'Please specify a valid email',
191				timeout               = null,
192				ajaxRequest           = null,
193				$currentPopup         = $target.closest( '.jet-popup' );
194
195			$mailField.on( 'focus', function() {
196				$mailField.removeClass( 'mail-invalid' );
197			} );
198
199			$( document ).keydown( function( event ) {
200
201				if ( 13 === event.keyCode && $mailField.is( ':focus' ) ) {
202					subscribeHandle();
203
204					return false;
205				}
206			} );
207
208			$submitButton.on( 'click', function() {
209				subscribeHandle();
210
211				return false;
212			} );
213
214			self.subscribeHandle = function() {
215				var inputValue     = $mailField.val(),
216					sendData       = {
217						'email': inputValue,
218						'target_list_id': settings['target_list_id'] || '',
219						'data': $inputData
220					},
221					serializeArray = $subscribeForm.serializeArray(),
222					additionalFields = {};
223
224				if ( validateEmail( inputValue ) ) {
225
226					$.each( serializeArray, function( key, fieldData ) {
227						if ( 'email' === fieldData.name ) {
228							sendData[ fieldData.name ] = fieldData.value;
229						} else {
230							additionalFields[ fieldData.name ] = fieldData.value;
231						}
232					} );
233
234					sendData['additional'] = additionalFields;
235
236					ajaxRequest = jQuery.ajax( {
237						type: 'POST',
238						url: window.jetPopupData.ajax_url,
239						data: {
240							'action': 'jet_popup_mailchimp_ajax',
241							'data': sendData
242						},
243						beforeSend: function( jqXHR, ajaxSettings ) {
244							if ( null !== ajaxRequest ) {
245								ajaxRequest.abort();
246							}
247						},
248						error: function( jqXHR, ajaxSettings ) {
249
250						},
251						success: function( data, textStatus, jqXHR ) {
252							var successType   = data.type,
253								message       = data.message || '',
254								responceClass = 'jet-popup-mailchimp--response-' + successType;
255
256							$submitButton.removeClass( 'loading' );
257
258							$target.removeClass( 'jet-popup-mailchimp--response-error' );
259							$target.addClass( responceClass );
260
261							$( 'span', $subscribeFormMessage ).html( message );
262							$subscribeFormMessage.css( { 'visibility': 'visible' } );
263
264							timeout = setTimeout( function() {
265								$subscribeFormMessage.css( { 'visibility': 'hidden' } );
266								$target.removeClass( responceClass );
267							}, 10000 );
268
269							if ( settings['redirect'] ) {
270								window.location.href = settings['redirect_url'];
271							}
272
273							$( window ).trigger( {
274								type: 'jet-popup/mailchimp',
275								elementId: scoreId,
276								successType: successType,
277								inputData: $inputData
278							} );
279
280							if ( true === settings['close_popup_when_success'] && $currentPopup[0] && 'success' === successType ) {
281								var popupId = $currentPopup.attr( 'id' );
282
283								timeout = setTimeout( function() {
284									$( window ).trigger( {
285										type: 'jet-popup-close-trigger',
286										popupData: {
287											popupId: popupId,
288											constantly: false
289										}
290									} );
291								}, 3000 );
292
293							}
294						}
295					} );
296
297
298					$submitButton.addClass( 'loading' );
299				} else {
300					$mailField.addClass( 'mail-invalid' );
301
302					$target.addClass( 'jet-popup-mailchimp--response-error' );
303					$( 'span', $subscribeFormMessage ).html( invalidMailMessage );
304					$subscribeFormMessage.css( { 'visibility': 'visible' } );
305
306					timeout = setTimeout( function() {
307						$target.removeClass( 'jet-popup-mailchimp--response-error' );
308						$subscribeFormMessage.css( { 'visibility': 'hidden' } );
309						$mailField.removeClass( 'mail-invalid' );
310					}, 10000 );
311				}
312			}
313
314			function validateEmail( email ) {
315				var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
316
317				return re.test( email );
318			}
319		},
320	};
321
322	// Elementor front init
323	$( window ).on( 'elementor/frontend/init', () => {
324		window.JetPopupElementorFrontend.init();
325	} );
326
327}( jQuery, window.elementorFrontend ) );

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.