PageSourceSearch

https://mqg.org.il/wp-content/plugins/jet-popup/assets/js/jet-popup-frontend.js?ver=2.1.0

js mqg.org.il collected 2026-10-02 12:44:48 UTC 39,670 bytes, 1,590 lines download raw bytes

1( function( $ ) {
2
3	'use strict';
4
5	window.JetPopupFrontend = {
6
7		addedScripts: {},
8
9		addedStyles: {},
10
11		addedAssetsPromises: [],
12
13		getLoopItemData: function( $trigger ) {
14
15			let $loopItem = $();
16
17			if ( ! $trigger || ! $trigger.length ) {
18				return {};
19			}
20
21			$loopItem = $trigger.closest( '[data-elementor-type="loop-item"], .e-loop-item' );
22
23			if ( ! $loopItem.length ) {
24				$loopItem = $trigger.find( '[data-elementor-type="loop-item"], .e-loop-item' ).first();
25			}
26
27			if ( ! $loopItem.length ) {
28				return {};
29			}
30
31			let postId    = $loopItem.data( 'post-id' ) || false,
32				className = $loopItem.attr( 'class' ) || '',
33				matches   = [
34					className.match( /\be-loop-item-(\d+)\b/ ),
35					className.match( /\bpost-(\d+)\b/ ),
36					className.match( /\bpage-id-(\d+)\b/ ),
37					className.match( /\battachment-(\d+)\b/ ),
38				];
39
40			if ( ! postId ) {
41				for ( let match of matches ) {
42					if ( match && match[1] ) {
43						postId = match[1];
44						break;
45					}
46				}
47			}
48
49			if ( ! postId ) {
50				return {};
51			}
52
53			return {
54				postId: +postId,
55			};
56		},
57
58		maybeExtendPopupData: function( popupData, $trigger ) {
59			popupData = popupData || {};
60
61			if ( ! popupData.loopDynamicPopup || popupData.postId || ! $trigger || ! $trigger.length ) {
62				return popupData;
63			}
64
65			return jQuery.extend( {}, popupData, JetPopupFrontend.getLoopItemData( $trigger ) );
66		},
67
68		init: function() {
69			let $popup_list = $( '.jet-popup.jet-popup--front-mode' );
70
71			$popup_list.each( function( index ) {
72				let $target  = $( this ),
73					instance = null,
74					settings = $target.data( 'settings' );
75
76				instance = new window.jetPopup( $target, settings );
77				instance.init();
78			} );
79
80			JetPopupFrontend.initAttachedPopups();
81
82			JetPopupFrontend.initBlocks();
83
84			$( window ).on( 'jet-popup/ajax/frontend-init', ( event, payload ) => {
85
86				switch ( payload.contentType ) {
87					case 'elementor':
88						JetPopupFrontend.maybeElementorFrontendInit( payload.$container );
89						break;
90					case 'default':
91						JetPopupFrontend.maybeDefaultFrontendInit( payload );
92						break
93				}
94			} );
95		},
96
97		initAttachedPopups: function ( $scope ) {
98			$scope = $scope || $( 'body' );
99
100			$scope.find( '[data-popup-instance]' ).each( ( index, el ) => {
101				let $this = $( el ),
102					popupId = $this.data( 'popup-instance' ) || 'none',
103					triggerType = $this.data( 'popup-trigger-type' ) || 'none',
104					clickedCustomClass = $this.data( 'popup-custom-selector' ) || '',
105					popupData = {
106						popupId: `jet-popup-${ popupId }`,
107					};
108
109				if ( $this.hasClass( 'jet-popup-attach-event-inited' ) ) {
110					return;
111				}
112
113				$this.addClass( 'jet-popup-attach-event-inited' );
114
115				switch( triggerType ) {
116					case 'click-self':
117						$this.addClass( 'jet-popup-cursor-pointer' );
118
119						$this.on( 'click.JetPopup', function( event ) {
120							event.preventDefault();
121
122							$( window ).trigger( {
123								type: 'jet-popup-open-trigger',
124								popupData: popupData,
125								triggeredBy: $this,
126							} );
127
128							return false;
129						} );
130						break;
131					case 'click-selector':
132
133						if ( '' !== clickedCustomClass ) {
134							$this.find( clickedCustomClass ).addClass( 'jet-popup-cursor-pointer' );
135
136							$this.on( 'click.JetPopup', clickedCustomClass, function( event ) {
137								event.preventDefault();
138
139								$( window ).trigger( {
140									type: 'jet-popup-open-trigger',
141									popupData: popupData,
142									triggeredBy: $this,
143								} );
144
145								return false;
146							} );
147						}
148						break;
149					case 'hover':
150						$this.on( 'mouseenter.JetPopup', function( event ) {
151
152							$( window ).trigger( {
153								type: 'jet-popup-open-trigger',
154								popupData: popupData,
155								triggeredBy: $this,
156							} );
157						} );
158						break;
159					case 'scroll-to':
160						const observer = new IntersectionObserver(( entries ) => {
161							entries.forEach(( entry ) => {
162
163								if ( entry.isIntersecting ) {
164
165									$( window ).trigger( {
166										type: 'jet-popup-open-trigger',
167										popupData: popupData,
168										triggeredBy: $this,
169									} );
170								}			
171							})
172						},
173						{ 
174							threshold: 0.5
175						});
176
177						for ( let i = 0; i < $( $this ).length; i++ ) {
178							const elements = $( $this )[i];
179							observer.observe( elements );
180						} 
181
182						break;
183				}
184			} );
185		},
186
187		initBlocks: function( $scope ) {
188			$scope = $scope || $( 'body' );
189
190			window.JetPlugins.init( $scope, [
191				{
192					block: 'jet-popup/action-button',
193					callback: ( $scope ) => {
194						let $button    = $( '.jet-popup-action-button__instance', $scope ),
195							actionType = $scope.data( 'action-type' );
196
197						JetPopupFrontend.actionButtonHandle( $button, actionType );
198					}
199				}
200			] );
201		},
202
203		actionButtonBlock: function( $scope ) {
204			var $button    = $( '.jet-popup-action-button__instance', $scope ),
205				actionType = $scope.data( 'action-type' );
206
207			JetPopupFrontend.actionButtonHandle( $button, actionType );
208		},
209
210		actionButtonHandle: function ( $button, actionType = 'link' ) {
211
212			switch ( actionType ) {
213
214				case 'link':
215
216					$button.on( 'click.JetPopup', function( event ) {
217						event.preventDefault();
218
219						var $currentPopup = $button.closest( '.jet-popup' ),
220							link          = $( this ).attr( 'href' ),
221							target        = $( this ).attr( 'target' ),
222							popupId       = $currentPopup.attr( 'id' );
223
224						$( window ).trigger( {
225							type: 'jet-popup-close-trigger',
226							popupData: {
227								popupId: popupId,
228								constantly: false
229							}
230						} );
231
232						if ( '_blank' === target  ) {
233							window.open( link, '_blank' );
234						} else {
235							window.open( link, '_self' );
236						}
237
238						return false;
239					} );
240					break;
241
242				case 'leave':
243					$button.on( 'click.JetPopup', function( event ) {
244						event.preventDefault();
245
246						window.history.back();
247					} );
248					break;
249
250				case 'close-popup':
251					$button.on( 'click.JetPopup', function( event ) {
252						event.preventDefault();
253
254						var $currentPopup = $button.closest( '.jet-popup' ),
255							popupId = $currentPopup.attr( 'id' );
256
257						$( window ).trigger( {
258							type: 'jet-popup-close-trigger',
259							popupData: {
260								popupId: popupId,
261								constantly: false
262							}
263						} );
264					} );
265					break;
266
267				case 'close-all-popups':
268					$button.on( 'click.JetPopup', function( event ) {
269						event.preventDefault();
270
271						var $popups = $( '.jet-popup' );
272
273						if ( $popups[0] ) {
274							$popups.each( function( index ) {
275								var $popup  = $( this ),
276									popupId = $popup.attr( 'id' );
277
278								$( window ).trigger( {
279									type: 'jet-popup-close-trigger',
280									popupData: {
281										popupId: popupId,
282										constantly: false
283									}
284								} );
285							} );
286						}
287					} );
288					break;
289
290				case 'close-constantly':
291					$button.on( 'click.JetPopup', function( event ) {
292						event.preventDefault();
293
294						var $currentPopup = $button.closest( '.jet-popup' ),
295							popupId = $currentPopup.attr( 'id' );
296
297						$( window ).trigger( {
298							type: 'jet-popup-close-trigger',
299							popupData: {
300								popupId: popupId,
301								constantly: true
302							}
303						} );
304					} );
305					break;
306
307				case 'close-all-constantly':
308					$button.on( 'click.JetPopup', function( event ) {
309						event.preventDefault();
310
311						var $popups = $( '.jet-popup' );
312
313						if ( $popups[0] ) {
314							$popups.each( function( index ) {
315								var $popup  = $( this ),
316									popupId = $popup.attr( 'id' );
317
318								$( window ).trigger( {
319									type: 'jet-popup-close-trigger',
320									popupData: {
321										popupId: popupId,
322										constantly: true
323									}
324								} );
325							} );
326						}
327					} );
328					break;
329			}
330		},
331
332		loadScriptAsync: function( script, uri ) {
333
334			if ( JetPopupFrontend.addedScripts.hasOwnProperty( script ) ) {
335				return script;
336			}
337
338			JetPopupFrontend.addedScripts[ script ] = uri;
339
340			const asset = document.getElementById( script + '-js' );
341
342			if ( asset ) {
343				return script;
344			}
345
346			return new Promise( function( resolve, reject ) {
347				var tag = document.createElement( 'script' );
348
349				tag.src    = uri;
350				tag.async  = false;
351				tag.onload = function() {
352					resolve( script );
353				};
354
355				document.head.appendChild( tag );
356			} );
357		},
358
359		loadStyle: function( style, uri ) {
360
361			if ( JetPopupFrontend.addedStyles.hasOwnProperty( style ) && JetPopupFrontend.addedStyles[ style ] ===  uri) {
362				return style;
363			}
364
365			JetPopupFrontend.addedStyles[ style ] = uri;
366
367			return new Promise( function( resolve, reject ) {
368				var tag = document.createElement( 'link' );
369
370				tag.id      = style;
371				tag.rel     = 'stylesheet';
372				tag.href    = uri;
373				tag.type    = 'text/css';
374				tag.media   = 'all';
375				tag.onload  = function() {
376					resolve( style );
377				};
378
379				document.head.appendChild( tag );
380			});
381		},
382
383		assetsLoaderPromise: function() {
384			return Promise.all( JetPopupFrontend.addedAssetsPromises );
385		},
386
387		maybeElementorFrontendInit: function( $popupContainer ) {
388			$popupContainer.find( 'div[data-element_type]' ).each( function() {
389				var $this       = $( this ),
390				    elementType = $this.data( 'element_type' );
391
392				if ( ! elementType ) {
393					return;
394				}
395
396				try {
397					if ( 'widget' === elementType ) {
398						elementType = $this.data( 'widget_type' );
399
400						if ( window.elementorFrontend && window.elementorFrontend.hooks ) {
401							window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ );
402						}
403					}
404
405					if ( window.elementorFrontend && window.elementorFrontend.hooks ) {
406						window.elementorFrontend.hooks.doAction( 'frontend/element_ready/global', $this, $ );
407						window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ );
408					}
409
410				} catch ( err ) {
411					console.log(err);
412					$this.remove();
413
414					return false;
415				}
416			} );
417		},
418
419		maybeDefaultFrontendInit: function ( payload ) {
420			const contentElements = payload.contentElements || [],
421				$container = payload.$container;
422
423			$container.find( '[data-is-block*="/"]' ).each( ( index, el ) => {
424				window.JetPlugins.hooks.doAction( window.JetPlugins.hookNameFromBlock( el.dataset.isBlock ), jQuery( el ) );
425			} );
426		}
427	};
428
429	/**
430	 * [jetPopup description]
431	 * @param  {[type]} $popup   [description]
432	 * @param  {[type]} settings [description]
433	 * @return {[type]}          [description]
434	 */
435	window.jetPopup = function( $popup, settings ) {
436		var self                   = this,
437			$window                = $( window ),
438			$document              = $( document ),
439			popupSettings          = settings,
440			id                     = popupSettings['id'],
441			popupId                = popupSettings['jet-popup-id'],
442			popupsLocalStorageData = {},
443			//editMode               = Boolean( window.elementorFrontend.isEditMode() ),
444			isAnimation            = false,
445			isOpen                 = false,
446			ajaxGetContentHanler   = null,
447			ajaxContentLoaded      = false;
448
449		self.init = function() {
450			var popupAvailable = self.popupAvailableCheck();
451
452			if ( ! popupAvailable ) {
453				return false;
454			}
455
456			self.setLocalStorageData( popupId, 'enable' );
457
458			self.initCompatibilityHandler();
459
460			self.initOpenEvent();
461
462			self.initCloseEvent();
463
464			$window.trigger( 'jet-popup/init/after', {
465				self: self,
466				settings: popupSettings
467			} );
468		};
469
470		/**
471		 * [popupAvailableCheck description]
472		 * @return {[type]} [description]
473		 */
474		self.popupAvailableCheck = function() {
475			var storageData = self.getLocalStorageData() || {};
476
477			if ( ! storageData.hasOwnProperty( popupId ) ) {
478				return true;
479			}
480
481			var popupData     = storageData[ popupId ],
482				status        = 'enable',
483				showAgainDate = 'none';
484
485			if ( 'disable' === popupData ) {
486				return false;
487			}
488
489			if ( 'enable' === popupData ) {
490				return true;
491			}
492
493			if ( popupData.hasOwnProperty( 'status' ) ) {
494				status = popupData['status'];
495			}
496
497			if ( 'enable' === status ) {
498				return true;
499			}
500
501			if ( popupData.hasOwnProperty( 'show-again-date' ) ) {
502				showAgainDate = popupData['show-again-date'];
503			}
504
505			if ( 'none' === showAgainDate && 'disable' === status ) {
506				return false;
507			}
508
509			if ( showAgainDate < Date.now() ) {
510				return true;
511			} else {
512				return false;
513			}
514		};
515
516		/**
517		 * [initOpenEvent description]
518		 * @return {[type]} [description]
519		 */
520		self.initOpenEvent = function() {
521
522			$window.trigger( 'jet-popup/init-events/before', {
523				self: self,
524				settings: popupSettings
525			} );
526
527			switch ( popupSettings['open-trigger'] ) {
528				case 'page-load':
529					self.pageLoadEvent( popupSettings['page-load-delay'] );
530				break;
531
532				case 'user-inactive':
533					self.userInactiveEvent( popupSettings['user-inactivity-time'] );
534				break;
535
536				case 'scroll-trigger':
537					self.scrollPageEvent( popupSettings['scrolled-to'] );
538				break;
539
540				case 'try-exit-trigger':
541					self.tryExitEvent();
542				break;
543
544				case 'on-date':
545					self.onDateEvent( popupSettings['on-date'] );
546				break;
547
548				case 'on-time':
549					self.onTimeEvent( popupSettings['on-time-start'], popupSettings['on-time-end'] );
550				break;
551
552				case 'on-date-and-time':
553					self.onTimeAndDateEvent( popupSettings['start-date-and-time'], popupSettings['end-date-and-time'] );
554				break;
555
556				case 'weekly-schedule':
557					self.onWeekdaysAndTimeEvent(
558						popupSettings['on-weekdays'],
559						popupSettings['on-week-time-start'],
560						popupSettings['on-week-time-end']
561					);
562				break;
563
564				case 'custom-selector':
565					self.onCustomSelector( popupSettings['custom-selector'] );
566				break;$scope
567			}
568
569			$window.on('jet-popup-open-trigger', function( event ) {
570				var popupData   = event.popupData || {},
571					triggeredBy = event.triggeredBy || false,
572					popupUniqId = popupData.popupId || false,
573					constantly  = popupData.constantly;
574			
575				if ( popupUniqId == popupId ) {
576					if ( $popup.hasClass( 'jet-popup--hide-state' )) {
577						self.showPopup( popupData, triggeredBy );
578					} else {
579						self.hidePopup( {
580							constantly: constantly,
581							popupId: popupUniqId,
582						} );
583					}
584				}
585			});
586
587			$window.on( 'jet-popup-close-trigger', function( event ) {
588				var popupData   = event.popupData || {},
589					popupUniqId = popupData.popupId,
590					constantly  = popupData.constantly;
591
592				if ( popupUniqId == popupId ) {
593					self.hidePopup( {
594						popupId: popupUniqId,
595						constantly: constantly,
596					} );
597				}
598			});
599
600			$window.trigger( 'jet-popup/init-events/after', {
601				self: self,
602				settings: popupSettings
603			} );
604		};
605
606		/**
607		 * [initOnCloseEvent description]
608		 * @return {[type]} [description]
609		 */
610		self.initOnCloseEvent = function() {
611
612			var $htmlBody = $( 'html, body' );
613
614			if ( 'scroll-to-top' === popupSettings['close-event'] ) {
615				$htmlBody.animate( { scrollTop: 0 }, 'slow' );
616			}
617
618			if ( 'scroll-to-anchor' === popupSettings['close-event'] ) {
619				var anchor = $( '#' + popupSettings['сlose-event-anchor'] );
620
621				if ( anchor.length ) {
622					$htmlBody.animate( { scrollTop: anchor.offset().top }, 'slow' );
623				}
624			}
625		}
626
627		/**
628		 * [initCloseEvent description]
629		 * @return {[type]} [description]
630		 */
631		self.initCloseEvent = function() {
632
633			$popup.on( 'click', '.jet-popup__close-button', function( event ) {
634				var target = event.currentTarget;
635
636				self.hidePopup( {
637					constantly: popupSettings['show-once'],
638					popupId: popupSettings['jet-popup-id']
639				} );
640				self.initOnCloseEvent();
641			} );
642
643			if ( popupSettings['close-on-overlay-click'] ) {
644				$popup.on( 'click', '.jet-popup__overlay', function( event ) {
645					var target = event.currentTarget;
646
647					self.hidePopup( {
648						constantly: popupSettings['show-once'],
649						popupId: popupSettings['jet-popup-id']
650					} );
651					self.initOnCloseEvent();
652				} );
653			}
654
655			$document.on( 'keyup.jetPopup', function( event ) {
656				var key = event.keyCode;
657
658				if ( 27 === key && isOpen ) {
659					self.hidePopup( {
660						constantly: popupSettings['show-once'],
661						popupId: popupSettings['jet-popup-id']
662					} );
663				}
664			} );
665		};
666
667		/**
668		 * [initCompatibilityHandler description]
669		 * @return {[type]} [description]
670		 */
671		self.initCompatibilityHandler = function() {
672			var $elementorProFormWidget = $( '.elementor-widget-form', $popup );
673
674			if ( $elementorProFormWidget[0] ) {
675				$elementorProFormWidget.each( function() {
676					var $this = $( this ),
677						$form = $( '.elementor-form', $this );
678
679						$form.on( 'submit_success', function() {
680
681							if ( true !== popupSettings['close-after-form-submit'] ) {
682								return;
683							}
684
685							let delay = parseInt( popupSettings['close-after-form-delay'] || 0 );
686							delay = delay * 1000;
687						
688							setTimeout( function() {
689								$window.trigger( {
690									type: 'jet-popup-close-trigger',
691									popupData: {
692										popupId: popupId,
693										constantly: false
694									}
695								} );
696							}, delay );
697						
698						});
699				} );
700			}
701
702			$( document ).on( 'jet-form-builder/ajax/on-success', function( event ) {
703	
704				if ( true !== popupSettings['close-after-form-submit'] ) {
705					return;
706				}
707			
708				let delay = parseInt( popupSettings['close-after-form-delay'] || 0 );
709				delay = delay * 1000;
710			
711				setTimeout( function() {
712					$window.trigger({
713						type: 'jet-popup-close-trigger',
714						popupData: {
715							popupId: popupId,
716							constantly: false
717						}
718					});
719				}, delay );
720			
721			});
722		};
723
724		/**
725		 * Handle popup opening on page load event.
726		 *
727		 * @param {number} openDelay Delay before opening the popup (in seconds).
728		 * @return {void}
729		 */
730		self.autoClosePopup = function() {
731
732			if ( ! popupSettings['automatically-close'] ) {
733				return;
734			}
735
736			let delay = parseInt( popupSettings['automatically-close'], 10 );
737		
738			if ( ! delay ) {
739				return;
740			}
741		
742			setTimeout( function() {
743		
744				if ( isOpen ) {
745					self.hidePopup( {
746						popupId: popupId,
747						constantly: false
748					} );
749				}
750		
751			}, delay * 1000 );
752		
753		};
754
755		/**
756		 * Page on load event
757		 *
758		 * @param  {int} openDelay Open delay time.
759		 * @return {void}
760		 */
761		self.pageLoadEvent = function( openDelay ) {
762			var delay = +openDelay || 0;
763
764			delay = delay * 1000;
765
766			$( function() {
767				setTimeout( function() {
768					self.showPopup();
769				}, delay );
770			} );
771		};
772
773		/**
774		 * User Inactivity event
775		 *
776		 * @param  {int} inactiveDelay [description]
777		 * @return {void}
778		 */
779		self.userInactiveEvent = function( inactiveDelay ) {
780			var delay      = +inactiveDelay || 0,
781				isInactive = true;
782
783			delay = delay * 1000;
784
785			setTimeout( function() {
786				if ( isInactive ) {
787					self.showPopup();
788				}
789			}, delay );
790
791			$( document ).on( 'click focus resize keyup scroll', function() {
792				isInactive = false;
793			} );
794		};
795
796		/**
797		 * Scrolling Page Event
798		 *
799		 * @param  {int} scrollingValue Scrolling porgress value
800		 * @return {void}
801		 */
802		self.scrollPageEvent = function( scrollingValue ) {
803			var scrolledValue  = +scrollingValue || 0;
804
805			$window.on( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent', function() {
806				var $window          = $( window ),
807					windowHeight     = $window.height(),
808					documentHeight   = $( document ).height(),
809					scrolledHeight   = documentHeight - windowHeight,
810					scrolledProgress = Math.max( 0, Math.min( 1, $window.scrollTop() / scrolledHeight ) ) * 100;
811
812				if ( scrolledProgress >= scrolledValue ) {
813					$window.off( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent' );
814					self.showPopup();
815				}
816			} ).trigger( 'scroll.cherryJetResizeEvent' );
817		};
818
819		/**
820		 * Viewport leave event
821		 *
822		 * @return {void}
823		 */
824		self.tryExitEvent = function() {
825			var pageY = 0;
826
827			$( document ).on( 'mouseleave', 'body', function( event ) {
828
829				pageY = event.pageY - $window.scrollTop();
830
831				if ( 0 > pageY && $popup.hasClass( 'jet-popup--hide-state' ) ) {
832					self.showPopup();
833				}
834			} );
835		};
836
837		/**
838		 * onDateEvent Event
839		 *
840		 * @return {void}
841		 */
842		self.onDateEvent = function( date ) {
843			var nowDate   = Date.now(),
844				startDate = Date.parse( date );
845
846			if ( startDate < nowDate ) {
847
848				setTimeout( function() {
849					self.showPopup();
850				}, 500 );
851			}
852		}
853
854		self.onWeekdaysAndTimeEvent = function( days = [], startTime = '00:00', endTime = '23:59' ) {
855
856			if ( ! days || ! days.length ) {
857				return;
858			}
859		
860			var nowTimeStamp = Date.now(),
861				nowDate = new Date(),
862				currentDay = nowDate.toLocaleString('en-US', { weekday: 'short' }).toLowerCase();
863		
864
865			days = days.map( day => day.toLowerCase() );
866		
867			if ( ! days.includes( currentDay ) ) {
868				return;
869			}
870		
871			startTime = '' !== startTime ? startTime : '00:00';
872			endTime   = '' !== endTime ? endTime : '23:59';
873		
874			var dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ),
875				[ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp );
876		
877			var startDateTime = `${ month }. ${ day }, ${ year } ${ startTime }`,
878				endDateTime   = `${ month }. ${ day }, ${ year } ${ endTime }`;
879		
880			var startTimeStamp = Date.parse( startDateTime ),
881				endTimeStamp   = Date.parse( endDateTime );
882		
883			if ( startTimeStamp < nowTimeStamp && nowTimeStamp < endTimeStamp ) {
884				setTimeout( function() {
885					self.showPopup();
886				}, 500 );
887			}
888		};
889
890		self.onTimeEvent = function( startTime = '00:00', endTime = '23:59' ) {
891			var startTime = '' !== startTime ? startTime : '00:00',
892				endTime = '' !== endTime ? endTime : '23:59',
893				nowTimeStamp = Date.now(),
894				dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ),
895				[ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp ),
896				startTime = `${ month }. ${ day }, ${ year } ${ startTime }`,
897				endTime = `${ month }. ${ day }, ${ year } ${ endTime }`,
898				startTimeStamp = Date.parse( startTime ),
899				endTimeStamp = Date.parse( endTime );
900
901			if ( ( startTimeStamp < nowTimeStamp ) && ( nowTimeStamp < endTimeStamp ) ) {
902				setTimeout( function() {
903					self.showPopup();
904				}, 500 );
905			}
906		}
907
908
909		self.onTimeAndDateEvent = function( start, end ) {
910
911			var nowDateStamp   = Date.now(),
912			startDateStamp = Date.parse( start ),
913			endDateStamp = Date.parse( end );
914
915			if ( ( startDateStamp < nowDateStamp ) && ( nowDateStamp < endDateStamp ) ) {
916				setTimeout( function() {
917					self.showPopup();
918				}, 500 );
919			}
920			
921		}
922
923		/**
924		 * Check DOM Loaded Selector
925		 * @param  {[type]} selector [description]
926		 * @return {[type]}          [description]
927		 */
928
929		self.checkLoadedSelector = function( selector ) {
930
931			//Check Listing Grid Lazy Load
932			$( document ).on( 'jet-engine/listing-grid/after-lazy-load', function() {
933				self.onCustomSelector ( selector );
934			});
935
936			//Check Open Mobile Menu
937			$( '.jet-mobile-menu__toggle' ).closest( '.jet-mobile-menu__instance--slide-out-layout' ).on( 'click', function() {
938				self.onCustomSelector ( selector );
939			});
940
941        }
942
943		/**
944		 * [onCustomSelector description]
945		 * @param  {[type]} selector [description]
946		 * @return {[type]}          [description]
947		 */
948		self.onCustomSelector = function( selector ) {
949
950			let $selector = $( selector );
951
952			if ( $selector[0] ) {
953				$( 'body' ).off( 'click.jetPopup', selector ).on( 'click.jetPopup', selector, function( event ) {
954					event.preventDefault();
955			
956					let $this   = $( this );
957					let popupId = $this.data( 'popup' );
958					let $popup  = $( '#jet-popup-' + popupId );
959			
960					if ( $popup.length && $popup.hasClass( 'jet-popup--show-state' ) ) {
961						self.hidePopup( popupId, false );
962					} else {
963						self.showPopup( popupId, $this );
964					}
965				} );
966			} else {
967				self.checkLoadedSelector( selector );
968			}
969		}
970
971		/**
972		 * Show Popup
973		 *
974		 * @return {void}
975		 */
976		self.showPopup = function( data, $trigger ) {
977			var popupData              = data || {},
978				animeOverlay           = null,
979				animeContainer         = null,
980				animeOverlaySettings   = jQuery.extend(
981					{
982						targets: $( '.jet-popup__overlay', $popup )[0]
983					},
984					self.avaliableEffects[ 'fade' ][ 'show' ]
985				);
986
987			$trigger = $trigger || false;
988
989			if ( ! self.popupAvailableCheck() ) {
990				return false;
991			}
992
993			animeOverlay = anime( animeOverlaySettings );
994
995			$popup.toggleClass( 'jet-popup--hide-state jet-popup--show-state' );
996
997			if ( popupSettings['prevent-scrolling'] ) {
998				$( 'body' ).addClass( 'jet-popup-prevent-scroll' );
999			}
1000
1001			popupData = JetPopupFrontend.maybeExtendPopupData( popupData, $trigger );
1002			popupData = window.JetPlugins.hooks.applyFilters( 'jet-popup.show-popup.data', popupData, $popup, $trigger );
1003
1004			self.showContainer( popupData );
1005		};
1006
1007		/**
1008		 * [showContainer description]
1009		 * @return {[type]} [description]
1010		 */
1011		self.showContainer = function( data ) {
1012			var popupData        = data || {},
1013				popupDefaultData = {
1014					forceLoad: popupSettings['force-ajax'] || false, // Trigger Ajax Every Time
1015					customContent: '' // Show Popup with Custom Content
1016				},
1017				animeContainerInstance   = null,
1018				$popupContainer  = $( '.jet-popup__container', $popup ),
1019				$content         = $( '.jet-popup__container-content', $popup ),
1020				animeContainer   = jQuery.extend(
1021					{
1022						targets: $( '.jet-popup__container', $popup )[0],
1023						begin: function( anime ) {
1024							isAnimation = true;
1025
1026							$window.trigger( 'jet-popup/show-event/before-show', {
1027								self: self,
1028								data: popupData,
1029								anime: anime
1030							} );
1031						},
1032						complete: function( anime ) {
1033							isAnimation = false;
1034							isOpen      = true;
1035
1036							self.autoClosePopup();
1037
1038							$window.trigger( 'jet-popup/show-event/after-show', {
1039								self: self,
1040								data: popupData,
1041								anime: anime
1042							} );
1043						}
1044					},
1045					self.avaliableEffects[ popupSettings['animation'] ][ 'show' ]
1046
1047				);
1048
1049			popupData = jQuery.extend( popupDefaultData, popupData );
1050
1051			// init Custom popup content
1052			if ( '' !== popupData.customContent ) {
1053				$content.html( popupData.customContent );
1054				self.elementorFrontendInit();
1055
1056				// Show Popup Container
1057				animeContainerInstance = anime( animeContainer );
1058
1059				$window.trigger( 'jet-popup/render-content/render-custom-content', {
1060					self: self,
1061					popup_id: id,
1062					data: popupData,
1063				} );
1064
1065				return false;
1066			}
1067
1068			if ( ! popupSettings['use-ajax'] ) {
1069				// Show Popup Container
1070				animeContainerInstance = anime( animeContainer );
1071
1072				$window.trigger( 'jet-popup/render-content/render-custom-content', {
1073					self: self,
1074					popup_id: id,
1075					data: popupData,
1076				} );
1077
1078				return false;
1079			}
1080
1081			if ( popupData.forceLoad ) {
1082				ajaxContentLoaded = false;
1083			}
1084
1085			if ( ajaxContentLoaded ) {
1086				// Show Popup Container
1087				animeContainerInstance = anime( animeContainer );
1088
1089				$window.trigger( 'jet-popup/render-content/show-content', {
1090					self: self,
1091					popup_id: id,
1092					data: popupData,
1093				} );
1094
1095				return false;
1096			}
1097
1098			popupData = jQuery.extend( popupData, {
1099				'popup_id': id,
1100				'page_url': window.location.href
1101			} );
1102
1103			ajaxGetContentHanler = jQuery.ajax( {
1104				type: 'POST',
1105				url: window.jetPopupData.ajax_url,
1106				data: {
1107					'action': 'jet_popup_get_content',
1108					'data': popupData
1109				},
1110				beforeSend: function( jqXHR, ajaxSettings ) {
1111
1112					if ( null !== ajaxGetContentHanler ) {
1113						ajaxGetContentHanler.abort();
1114					}
1115
1116					// Before ajax send Trigger
1117					$window.trigger( 'jet-popup/render-content/ajax/before-send', {
1118						self: self,
1119						popup_id: id,
1120						data: popupData
1121					} );
1122
1123					$popup.addClass( 'jet-popup--loading-state' );
1124				},
1125				error: function( jqXHR, ajaxSettings ) {},
1126				success: function( data, textStatus, jqXHR ) {
1127					var successType = data.type,
1128						contentData = data.content || false,
1129						$popupContainer = $( '.jet-popup__container-content', $popup );
1130
1131					$popup.removeClass( 'jet-popup--loading-state' );
1132
1133					if ( 'error' === successType ) {
1134						var message = data.message;
1135
1136						$content.html( '<h3>' + message + '</h3>' );
1137
1138						// Show Popup Container
1139						animeContainerInstance = anime( animeContainer );
1140					}
1141
1142					if ( 'success' === successType ) {
1143						let popupContent         = contentData['content'],
1144							popupContentElements = contentData['contentElements'],
1145						    popupScripts         = contentData['scripts'],
1146						    popupStyles          = contentData['styles'],
1147							popupAfterScripts   = contentData['afterScripts'];
1148
1149						for ( let { handle: scriptHandler, src: scriptSrc } of popupScripts ) {
1150							JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadScriptAsync( scriptHandler, scriptSrc ) );
1151						}
1152
1153						if ( popupStyles && Object.keys( popupStyles ).length > 0 ) {
1154							for ( let styleHandler in popupStyles ) {
1155								JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadStyle( styleHandler, popupStyles[ styleHandler ] ) );
1156							}
1157						}
1158
1159						JetPopupFrontend.assetsLoaderPromise().then( async function( value ) {
1160							ajaxContentLoaded = true;
1161
1162							// Ajax Success Trigger
1163							$window.trigger( 'jet-popup/render-content/ajax/success', {
1164								self: self,
1165								popup_id: id,
1166								data: popupData,
1167								request: data
1168							} );
1169
1170							// Render content
1171							if ( popupContent ) {
1172								$popupContainer.html( popupContent );
1173							}
1174
1175							if ( popupAfterScripts.length ) {
1176								await Promise.all( popupAfterScripts.map(
1177									( { handle, src } ) => JetPopupFrontend.loadScriptAsync( handle, src )
1178								) );
1179							}
1180
1181							// Before ajax frontend init
1182							$( window ).trigger( 'jet-popup/ajax/frontend-init/before', {
1183								$container: $popupContainer,
1184								content: popupContent,
1185								contentElements: popupContentElements,
1186								contentType: popupSettings['content-type'],
1187							} );
1188
1189							// Frontend init
1190							$( window ).trigger( 'jet-popup/ajax/frontend-init', {
1191								$container: $popupContainer,
1192								content: popupContent,
1193								contentElements: popupContentElements,
1194								contentType: popupSettings['content-type'],
1195							} );
1196
1197							// after ajax frontend init
1198							$( window ).trigger( 'jet-popup/ajax/frontend-init/after', {
1199								$container: $popupContainer,
1200								content: popupContent,
1201								contentElements: popupContentElements,
1202								contentType: popupSettings['content-type'],
1203							} );
1204
1205							// Show Popup Container
1206							animeContainerInstance = anime( animeContainer );
1207
1208						}, function( reason ) {
1209							console.log( 'Assets Loaded Error' );
1210						} );
1211					}
1212				}
1213			} );
1214		};
1215
1216		/**
1217		 * Hide Popup
1218		 *
1219		 * @return {void}
1220		 */
1221		self.hidePopup = function ( data ) {
1222			var popupData              = data || {},
1223				$content               = $( '.jet-popup__container-content', $popup ),
1224				constantly             = popupData.constantly || false,
1225				animeOverlay           = null,
1226				animeContainer         = null,
1227				animeOverlaySettings   = jQuery.extend( { targets: $( '.jet-popup__overlay', $popup )[0] }, self.avaliableEffects[ 'fade' ][ 'hide' ] ),
1228				animeContainerSettings = jQuery.extend(
1229					{
1230						targets: $( '.jet-popup__container', $popup )[0],
1231						begin: function( anime ) {
1232							isAnimation = true;
1233
1234							$window.trigger( 'jet-popup/hide-event/before-hide', {
1235								self: self,
1236								data: popupData,
1237								anime: anime
1238							} );
1239						},
1240						complete: function( anime ) {
1241							isAnimation = false;
1242							isOpen = false;
1243							$popup.toggleClass( 'jet-popup--show-state jet-popup--hide-state' );
1244
1245							if ( popupSettings['use-ajax'] && popupSettings['force-ajax'] ) {
1246								$content.html( '' );
1247							}
1248
1249							if ( popupSettings['prevent-scrolling'] && !$( '.jet-popup--show-state' )[0] ) {
1250								$( 'body' ).removeClass( 'jet-popup-prevent-scroll' );
1251							}
1252							// After Popup Hide Action
1253							$window.trigger( 'jet-popup/hide-event/after-hide', {
1254								self: self,
1255								data: popupData,
1256								anime: anime
1257							} );
1258						}
1259					},
1260					self.avaliableEffects[ popupSettings['animation'] ][ 'hide' ]
1261				);
1262
1263			if ( constantly ) {
1264				self.setLocalStorageData( popupId, 'disable' );
1265			}
1266
1267			if ( isAnimation ){
1268				return false;
1269			}
1270
1271			if ( $popup.hasClass('jet-popup--show-state') ) {
1272				animeOverlay = anime( animeOverlaySettings );
1273				animeContainer = anime( animeContainerSettings );
1274			}
1275
1276			// On Hide Handler
1277			self.onHidePopupAction();
1278
1279			// Before Popup Hide Action
1280			$window.trigger( 'jet-popup/close-hide-event/before-hide', {
1281				self: self,
1282				data: popupData
1283			} );
1284		};
1285
1286		/**
1287		 * [elementorFrontendInit description]
1288		 * @return {[type]} [description]
1289		 */
1290		self.elementorFrontendInit = function() {
1291			var $content = $( '.jet-popup__container-content', $popup );
1292
1293			$content.find( 'div[data-element_type]' ).each( function() {
1294				var $this       = $( this ),
1295					elementType = $this.data( 'element_type' );
1296
1297				if (!elementType) {
1298					return;
1299				}
1300
1301				try {
1302					if( 'widget' === elementType ){
1303						elementType = $this.data( 'widget_type' );
1304						window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ );
1305					}
1306					window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ );
1307
1308				} catch( err ) {
1309					console.log(err);
1310
1311					$this.remove();
1312
1313					return false;
1314				}
1315
1316			});
1317
1318			// On Show Handler
1319			self.onShowPopupAction();
1320		}
1321
1322		/**
1323		 * [onShowPopupAction description]
1324		 * @return {[type]} [description]
1325		 */
1326		self.onShowPopupAction = function() {};
1327
1328		/**
1329		 * [onHidePopupAction description]
1330		 * @return {[type]} [description]
1331		 */
1332		self.onHidePopupAction = function() {};
1333
1334		/**
1335		 * Avaliable Effects
1336		 */
1337
1338		const useCustomDuration = popupSettings['animation_custom_duration'] === true;
1339
1340		let inDuration  = false;
1341		let outDuration = false;
1342		
1343		if ( useCustomDuration ) {
1344			inDuration  = popupSettings['animation_in_duration'];
1345			outDuration = popupSettings['animation_out_duration'];
1346		}
1347
1348		self.avaliableEffects = {
1349			'none': {
1350				'show': {
1351					duration: inDuration || 0,
1352					opacity: { value: [1, 1] }
1353				},
1354				'hide': {
1355					duration: outDuration || 0,
1356					opacity: { value: [1, 1] }
1357				}
1358			},
1359		
1360			'fade': {
1361				'show': {
1362					opacity: { value: [0, 1], duration: inDuration || 600, easing: 'easeOutQuart' }
1363				},
1364				'hide': {
1365					opacity: { value: [1, 0], duration: outDuration || 400, easing: 'easeOutQuart' }
1366				}
1367			},
1368		
1369			'zoom-in': {
1370				'show': {
1371					duration: inDuration || 500,
1372					easing: 'easeOutQuart',
1373					opacity: { value: [0, 1] },
1374					scale: { value: [0.75, 1] }
1375				},
1376				'hide': {
1377					duration: outDuration || 400,
1378					easing: 'easeOutQuart',
1379					opacity: { value: [1, 0] },
1380					scale: { value: [1, 0.75] }
1381				}
1382			},
1383		
1384			'zoom-out': {
1385				'show': {
1386					duration: inDuration || 500,
1387					easing: 'easeOutQuart',
1388					opacity: { value: [0, 1] },
1389					scale: { value: [1.25, 1] }
1390				},
1391				'hide': {
1392					duration: outDuration || 400,
1393					easing: 'easeOutQuart',
1394					opacity: { value: [1, 0] },
1395					scale: { value: [1, 1.25] }
1396				}
1397			},
1398		
1399			'rotate': {
1400				'show': {
1401					duration: inDuration || 500,
1402					easing: 'easeOutQuart',
1403					opacity: { value: [0, 1] },
1404					scale: { value: [0.75, 1] },
1405					rotate: { value: [-65, 0] }
1406				},
1407				'hide': {
1408					duration: outDuration || 400,
1409					easing: 'easeOutQuart',
1410					opacity: { value: [1, 0] },
1411					scale: { value: [1, 0.9] }
1412				}
1413			},
1414		
1415			'move-up': {
1416				'show': {
1417					duration: inDuration || 500,
1418					easing: 'easeOutExpo',
1419					opacity: { value: [0, 1] },
1420					translateY: { value: [50, 1] }
1421				},
1422				'hide': {
1423					duration: outDuration || 400,
1424					easing: 'easeOutQuart',
1425					opacity: { value: [1, 0] },
1426					translateY: { value: [1, 50] }
1427				}
1428			},
1429		
1430			'flip-x': {
1431				'show': {
1432					duration: inDuration || 500,
1433					easing: 'easeOutExpo',
1434					opacity: { value: [0, 1] },
1435					rotateX: { value: [65, 0] }
1436				},
1437				'hide': {
1438					duration: outDuration || 400,
1439					easing: 'easeOutQuart',
1440					opacity: { value: [1, 0] }
1441				}
1442			},
1443		
1444			'flip-y': {
1445				'show': {
1446					duration: inDuration || 500,
1447					easing: 'easeOutExpo',
1448					opacity: { value: [0, 1] },
1449					rotateY: { value: [65, 0] }
1450				},
1451				'hide': {
1452					duration: outDuration || 400,
1453					easing: 'easeOutQuart',
1454					opacity: { value: [1, 0] }
1455				}
1456			},
1457		
1458			'bounce-in': {
1459				'show': {
1460					opacity: { value: [0, 1], duration: inDuration || 500, easing: 'easeOutQuart' },
1461					scale: {
1462						value: [0.2, 1],
1463						duration: inDuration || 800,
1464						elasticity: function(el, i, l) { return (400 + i * 200); }
1465					}
1466				},
1467				'hide': {
1468					duration: outDuration || 400,
1469					easing: 'easeOutQuart',
1470					opacity: { value: [1, 0] },
1471					scale: { value: [1, 0.8] }
1472				}
1473			},
1474		
1475			'bounce-out': {
1476				'show': {
1477					opacity: { value: [0, 1], duration: inDuration || 500, easing: 'easeOutQuart' },
1478					scale: {
1479						value: [1.8, 1],
1480						duration: inDuration || 800,
1481						elasticity: function(el, i, l) { return (400 + i * 200); }
1482					}
1483				},
1484				'hide': {
1485					duration: outDuration || 400,
1486					easing: 'easeOutQuart',
1487					opacity: { value: [1, 0] },
1488					scale: { value: [1, 1.5] }
1489				}
1490			},
1491		
1492			'slide-in-up': {
1493				'show': {
1494					opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' },
1495					translateY: { value: ['100vh', 0], duration: inDuration || 750, easing: 'easeOutQuart' }
1496				},
1497				'hide': {
1498					duration: outDuration || 400,
1499					easing: 'easeInQuart',
1500					opacity: { value: [1, 0] },
1501					translateY: { value: [0, '100vh'] }
1502				}
1503			},
1504		
1505			'slide-in-right': {
1506				'show': {
1507					opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' },
1508					translateX: { value: ['100vw', 0], duration: inDuration || 750, easing: 'easeOutQuart' }
1509				},
1510				'hide': {
1511					duration: outDuration || 400,
1512					easing: 'easeInQuart',
1513					opacity: { value: [1, 0] },
1514					translateX: { value: [0, '100vw'] }
1515				}
1516			},
1517		
1518			'slide-in-down': {
1519				'show': {
1520					opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' },
1521					translateY: { value: ['-100vh', 0], duration: inDuration || 750, easing: 'easeOutQuart' }
1522				},
1523				'hide': {
1524					duration: outDuration || 400,
1525					easing: 'easeInQuart',
1526					opacity: { value: [1, 0] },
1527					translateY: { value: [0, '-100vh'] }
1528				}
1529			},
1530		
1531			'slide-in-left': {
1532				'show': {
1533					opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' },
1534					translateX: { value: ['-100vw', 0], duration: inDuration || 750, easing: 'easeOutQuart' }
1535				},
1536				'hide': {
1537					duration: outDuration || 400,
1538					easing: 'easeInQuart',
1539					opacity: { value: [1, 0] },
1540					translateX: { value: [0, '-100vw'] }
1541				}
1542			}
1543		};
1544		
1545		
1546		/**
1547		 * Get localStorage data.
1548		 *
1549		 * @return {object|boolean}
1550		 */
1551		self.getLocalStorageData = function() {
1552
1553			try {
1554				return JSON.parse( localStorage.getItem( 'jetPopupData' ) );
1555			} catch ( e ) {
1556				return false;
1557			}
1558		};
1559
1560		/**
1561		 * Set localStorage data.
1562		 *
1563		 * @return {object|boolean}
1564		 */
1565		self.setLocalStorageData = function( id, status ) {
1566
1567			var jetPopupData = self.getLocalStorageData() || {},
1568				newData      = {};
1569
1570			newData['status'] = status;
1571
1572			if ( 'disable' === status ) {
1573
1574				var nowDate             = Date.now(),
1575					showAgainDelay      = popupSettings['show-again-delay'],
1576					showAgainDate       = 'none' !== showAgainDelay ? ( nowDate + showAgainDelay ) : 'none';
1577
1578				newData['show-again-date'] = showAgainDate;
1579			}
1580
1581			jetPopupData[ id ] = newData;
1582
1583			localStorage.setItem( 'jetPopupData', JSON.stringify( jetPopupData ) );
1584		}
1585
1586	}
1587
1588	window.JetPopupFrontend.init();
1589
1590}( 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.