PageSourceSearch

https://mairiedevinca.fr/wp-content/plugins/jet-popup/includes/ele…/jet-popup-elementor-frontend.js?ver=2.0.6

js mairiedevinca.fr collected 2026-10-02 21:29:56 UTC 9,338 bytes, 337 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						const observer = new IntersectionObserver(( entries ) => {
148							entries.forEach(( entry ) => {
149
150								if ( entry.isIntersecting ) {
151
152									if ( elementor.hooks ) {
153										popupData = elementor.hooks.applyFilters(
154											'jet-popup/widget-extensions/popup-data',
155											popupData,
156											popupSettings,
157											$scope,
158										);
159									}
160
161									$( window ).trigger( {
162										type: 'jet-popup-open-trigger',
163										popupData: popupData,
164										triggeredBy: $scope,
165									} );
166								}			
167							})
168						},
169						{ 
170							threshold: 0.5
171						});
172
173						for ( let i = 0; i < $( $scope ).length; i++ ) {
174							const elements = $( $scope )[i];
175							observer.observe( elements );
176						} 
177						break;
178				}
179			}
180		},
181
182		widgetPopupActionButton: function( $scope ) {
183			var $button    = $( '.jet-popup-action-button__instance', $scope ),
184				settings   = $button.data( 'settings' ),
185				actionType = settings['action-type'];
186
187			window.JetPopupFrontend.actionButtonHandle( $button, actionType );
188		},
189
190		widgetPopupMailchimp: function( $scope ) {
191			var $target               = $scope.find( '.jet-popup-mailchimp' ),
192				scoreId               = $scope.data( 'id' ),
193				settings              = $target.data( 'settings' ),
194				$subscribeForm        = $( '.jet-popup-mailchimp__form', $target ),
195				$fields                = $( '.jet-popup-mailchimp__fields', $target ),
196				$mailField            = $( '.jet-popup-mailchimp__mail-field', $target ),
197				$inputData            = $mailField.data( 'instance-data' ),
198				$submitButton         = $( '.jet-popup-mailchimp__submit', $target ),
199				$subscribeFormMessage = $( '.jet-popup-mailchimp__message', $target ),
200				invalidMailMessage    = 'Please specify a valid email',
201				timeout               = null,
202				ajaxRequest           = null,
203				$currentPopup         = $target.closest( '.jet-popup' );
204
205			$mailField.on( 'focus', function() {
206				$mailField.removeClass( 'mail-invalid' );
207			} );
208
209			$( document ).keydown( function( event ) {
210
211				if ( 13 === event.keyCode && $mailField.is( ':focus' ) ) {
212					subscribeHandle();
213
214					return false;
215				}
216			} );
217
218			$submitButton.on( 'click', function() {
219				subscribeHandle();
220
221				return false;
222			} );
223
224			self.subscribeHandle = function() {
225				var inputValue     = $mailField.val(),
226					sendData       = {
227						'email': inputValue,
228						'target_list_id': settings['target_list_id'] || '',
229						'data': $inputData
230					},
231					serializeArray = $subscribeForm.serializeArray(),
232					additionalFields = {};
233
234				if ( validateEmail( inputValue ) ) {
235
236					$.each( serializeArray, function( key, fieldData ) {
237						if ( 'email' === fieldData.name ) {
238							sendData[ fieldData.name ] = fieldData.value;
239						} else {
240							additionalFields[ fieldData.name ] = fieldData.value;
241						}
242					} );
243
244					sendData['additional'] = additionalFields;
245
246					ajaxRequest = jQuery.ajax( {
247						type: 'POST',
248						url: window.jetPopupData.ajax_url,
249						data: {
250							'action': 'jet_popup_mailchimp_ajax',
251							'data': sendData
252						},
253						beforeSend: function( jqXHR, ajaxSettings ) {
254							if ( null !== ajaxRequest ) {
255								ajaxRequest.abort();
256							}
257						},
258						error: function( jqXHR, ajaxSettings ) {
259
260						},
261						success: function( data, textStatus, jqXHR ) {
262							var successType   = data.type,
263								message       = data.message || '',
264								responceClass = 'jet-popup-mailchimp--response-' + successType;
265
266							$submitButton.removeClass( 'loading' );
267
268							$target.removeClass( 'jet-popup-mailchimp--response-error' );
269							$target.addClass( responceClass );
270
271							$( 'span', $subscribeFormMessage ).html( message );
272							$subscribeFormMessage.css( { 'visibility': 'visible' } );
273
274							timeout = setTimeout( function() {
275								$subscribeFormMessage.css( { 'visibility': 'hidden' } );
276								$target.removeClass( responceClass );
277							}, 10000 );
278
279							if ( settings['redirect'] ) {
280								window.location.href = settings['redirect_url'];
281							}
282
283							$( window ).trigger( {
284								type: 'jet-popup/mailchimp',
285								elementId: scoreId,
286								successType: successType,
287								inputData: $inputData
288							} );
289
290							if ( true === settings['close_popup_when_success'] && $currentPopup[0] && 'success' === successType ) {
291								var popupId = $currentPopup.attr( 'id' );
292
293								timeout = setTimeout( function() {
294									$( window ).trigger( {
295										type: 'jet-popup-close-trigger',
296										popupData: {
297											popupId: popupId,
298											constantly: false
299										}
300									} );
301								}, 3000 );
302
303							}
304						}
305					} );
306
307
308					$submitButton.addClass( 'loading' );
309				} else {
310					$mailField.addClass( 'mail-invalid' );
311
312					$target.addClass( 'jet-popup-mailchimp--response-error' );
313					$( 'span', $subscribeFormMessage ).html( invalidMailMessage );
314					$subscribeFormMessage.css( { 'visibility': 'visible' } );
315
316					timeout = setTimeout( function() {
317						$target.removeClass( 'jet-popup-mailchimp--response-error' );
318						$subscribeFormMessage.css( { 'visibility': 'hidden' } );
319						$mailField.removeClass( 'mail-invalid' );
320					}, 10000 );
321				}
322			}
323
324			function validateEmail( email ) {
325				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,}))$/;
326
327				return re.test( email );
328			}
329		},
330	};
331
332	// Elementor front init
333	$( window ).on( 'elementor/frontend/init', () => {
334		window.JetPopupElementorFrontend.init();
335	} );
336
337}( 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.