PageSourceSearch

https://unitedwedream.org/wp-content/plugins/jet-popup/includes/el…/jet-popup-elementor-frontend.js?ver=2.2.2

js unitedwedream.org collected 2026-09-24 08:51:18 UTC 11,147 bytes, 372 lines download raw bytes

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