PageSourceSearch

https://www.rentayacht.com.au/wp-content/plugins/divi-modal-popup/…/ModalPopup/assets/script.min.js?ver=2.0.1

js rentayacht.com.au collected 2026-09-30 19:06:03 UTC 17,975 bytes, 448 lines download raw bytes

1( function( $ ) {
2	let windowWidth = $(window).width();
3	$.fn.DiviModalPopupRemoveClasses = function( orderClass ) {
4		let $this   = this,
5		$classes    = el_modal_popup_get_module_classes();
6
7		$classes.push(orderClass);
8		$this.removeClass( $classes.join(' ') );
9
10		$this.css( {
11			'animation-delay'           : '',
12			'animation-duration'        : '',
13			'animation-timing-function' : '',
14			'opacity'                   : '',
15			'transform'                 : '',
16			'filter'                    : '',
17		} );
18		return this;
19	};
20	
21	$.fn.DiviModalPopup = function( options ) {
22		let defaults = {
23			action: '',
24			href: '#',
25			delay: '0',
26		};
27		
28		let $modal   = this,
29			$timeOut = 0,
30			$options = $.extend({}, defaults, options);
31
32		if ( 'undefined' !== typeof( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration') ) ) {
33			$timeOut = parseFloat( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration') );
34			if ( windowWidth < 981 ) {
35				if ( 'undefined' !== typeof( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration-tablet') ) && '' !== $modal.find('.el_modal_popup_wrapper').data('animation-duration-tablet') ) {
36					$timeOut = parseFloat( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration-tablet') );
37				}
38			} else if ( windowWidth < 768 ) {
39				if ( 'undefined' !== typeof( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration-phone') ) && '' !== $modal.find('.el_modal_popup_wrapper').data('animation-duration-phone') ) {
40					$timeOut = parseFloat( $modal.find('.el_modal_popup_inner_wrap').data('animation-duration-phone') );
41				}
42			}
43		}
44
45		if ( 'open' === $options.action ) {
46			let delay = parseInt($options.delay);
47			setTimeout(function(){
48				$timeOut = $timeOut + 200;
49				$('body').find('.el_modal_popup').removeClass('el_modal_popup_active_modal');
50				$('body').addClass('el_modal_popup_active');
51				$modal.addClass('el_modal_popup_active_modal');
52				if ( 'off' === $modal.find('.el_modal_popup_wrapper').data('disable-website-scroll') ) {
53					$('body').addClass('el_modal_popup_enable_scroll');
54				}
55				setTimeout(function(){
56					$('body').find('.el_modal_popup').removeClass('el_modal_popup_opened');
57					$modal.addClass('el_modal_popup_opened');
58				}, $timeOut );
59				setTimeout(function(){
60					el_modal_popup_autoplay_video($modal);
61				}, ( 0.7 * $timeOut ) );
62	
63				if ( typeof et_animate_element === 'function' ) {
64					et_animate_element( $modal.find( '.el_modal_popup_inner_wrap' ) );
65				} else {
66					$modal.find( '.el_modal_popup_inner_wrap' ).removeClass( 'et_animated' );
67				}
68				$(document).trigger( 'diviModalPopupOpened' );
69			}, delay);
70		}
71 
72		if ( 'close' === $options.action ) {
73			let modalId     = $modal.prop('id'),
74				triggerType = $modal.find('.el_modal_popup_wrapper').data('trigger-type'),
75				reRender    = $modal.find('.el_modal_popup_wrapper').data('re-render');
76
77			if ( 0 !== $timeOut ) {
78				$modal.removeClass('el_modal_popup_active_modal');
79				// $modal.find('.el_modal_popup_animated').css('opacity', '1');
80				// $modal.find('.el_modal_popup_animated').css('transform', 'none');
81				setTimeout( function() {
82					// $modal.find('.el_modal_popup_animated').removeAttr('style');
83					$modal.addClass('el_modal_popup_animate_reverse');
84				}, 0 );
85
86				$modal.removeClass('el_modal_popup_opened');
87				$('body').removeClass('el_modal_popup_enable_scroll');
88				$('body').removeClass('el_modal_popup_active');
89				if ( $options.href && '#' !== $options.href ) {
90					window.location.href = $options.href;
91				}
92				setTimeout( function() {
93					$modal.removeClass('el_modal_popup_animate_reverse');
94				}, $timeOut );
95			} else {
96				$modal.removeClass('el_modal_popup_active_modal');
97				$modal.removeClass('el_modal_popup_opened');
98				$('body').removeClass('el_modal_popup_active');
99				$('body').removeClass('el_modal_popup_enable_scroll');
100				if ( $options.href && '#' !== $options.href ) {
101					window.location.href = $options.href;
102				}
103			}
104			
105			el_modal_popup_stop_video($modal);
106			if ( -1 !== $.inArray( triggerType, [ 'exit_intent', 'on_page_load', 'on_scroll', 'user_inactivity' ] ) ) {
107				let modalStorageKey = modalId + '_' + triggerType + '_hide';
108				if ( ( 'on_page_load' === triggerType && 'off' === reRender ) || ( 'exit_intent' === triggerType && 'off' === reRender ) || 
109					 ( 'on_scroll' === triggerType && 'off' === reRender ) || ( 'user_inactivity' === triggerType && 'off' === reRender ) ) {
110					sessionStorage.setItem( modalStorageKey, 'true' );
111				}
112				if ( ( 'exit_intent' === triggerType && 'on' === reRender ) || ( 'on_scroll' === triggerType && 'on' === reRender ) ) {
113					$modal.find('.el_modal_popup_wrapper').data('rendered', 'yes');
114				}
115			}
116			if ( $options.href && '#' !== $options.href ) {
117				window.location.href = $options.href;
118			}
119
120			$(document).trigger( 'diviModalPopupClosed' );
121		}
122		return this;
123	};
124
125	if ( $('body').find('.el_modal_popup').length > 0 ) {
126
127		let $user_inactivity_modals = {};
128		$('body').find('.el_modal_popup').each( function() {
129			let $this               = $(this),
130				$modalClass         = $this.prop('class'),
131				$orderClass         = $this.prop('class').match(/el_modal_popup_\d+/)[0],
132				$modalId            = $this.find('.el_modal_popup_wrapper').data('id'),
133				$modalStorageKey    = $modalId + '_' + $this.find('.el_modal_popup_wrapper').data('trigger-type') + '_hide',
134				$modal_container    = $('<div class="el_modal_popup_section entry-content et_pb_section et-l"></div>'),
135				$modal              = $('<div></div>');
136
137			$modal.prop( 'id', $modalId );
138			$modal.prop( 'class', $modalClass );
139			$modal.DiviModalPopupRemoveClasses($orderClass).addClass('el_modal_popup_module');
140			
141			if ( $this.hasClass( $orderClass + '_tb_header' ) ) {
142				$modal.addClass( $orderClass + '_tb_header_module' );
143			} else if ( $this.hasClass( $orderClass + '_tb_body' ) ) {
144				$modal.addClass( $orderClass + '_tb_body_module' );
145			} else if ( $this.hasClass( $orderClass + '_tb_footer' ) ) {
146				$modal.addClass( $orderClass + '_tb_footer_module' );
147			} else {
148				$modal.addClass( $orderClass + '_module' );
149			} 
150
151			$modal.html( $(this).find('.el_modal_popup_wrapper').detach() );
152			$modal_container.html($modal);
153
154			if ( $('body').find('#page-container').find('#et-boc').length > 0 ) {
155				$('body').find('#page-container').find('#et-boc').append( $modal_container );
156			} else if ( $('body').find('#page-container').length > 0 ) {
157				$('body').find('#page-container').append( $modal_container );
158			} else if ( $('body').find('#et_builder_outer_content').length > 0 ) {
159				$('body').find('#et_builder_outer_content').append( $modal_container );
160			} else if ( $('body').find('#et-boc').length > 0 ) {
161				$('body').find('#et-boc').append( $modal_container );
162			} else {
163				$('body').append( $modal_container );
164			}
165
166			if ( $('body').find('.el_modal_popup_body .el_modal_popup_close').length > 0 ) {
167				$('body').find('.el_modal_popup_body .el_modal_popup_close').each(function(){
168					if ( $(this).attr('href') ) {
169						$(this).attr('data-href', $(this).attr('href'));
170						$(this).attr('href', '#');
171					}
172				});
173			}
174
175			if ( 'none' === $this.css('display') ) {
176				return;
177			}
178			
179			if ( 'element' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ) {
180				if ( 'undefined' !== typeof( $modal.find('.el_modal_popup_wrapper').data('trigger-element-id') ) && '' !== $modal.find('.el_modal_popup_wrapper').data('trigger-element-id') ) {
181					/* Trigger modal on user defined element */
182					let $elem = '#' + $modal.find('.el_modal_popup_wrapper').data('trigger-element-id');
183					$('body').on('click', $elem, function(e){
184						e.preventDefault();
185						$modal.DiviModalPopup({
186							action: 'open',
187						});
188					});
189				} else if ( 'undefined' !== typeof( $modal.find('.el_modal_popup_wrapper').data('trigger-element-class') ) && '' !== $modal.find('.el_modal_popup_wrapper').data('trigger-element-class') ) {
190					/* Trigger modal on user defined element */
191					let $elem = '.' + $modal.find('.el_modal_popup_wrapper').data('trigger-element-class');
192					$('body').on('click', $elem, function(e){
193						e.preventDefault();
194						$modal.DiviModalPopup({
195							action: 'open',
196						});
197					});
198				} else if ( $this.find('.el_modal_popup_trigger_element').length > 0 ) {
199					/* Trigger modal on modal trigger element */
200					$this.find('.el_modal_popup_trigger_element').on('click', function(e){
201						e.preventDefault();
202						$modal.DiviModalPopup({
203							action: 'open',
204						});
205					});
206				}
207			} else if ( 'on_page_load' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ) {
208				/* Trigger modal on page load */
209				let delay       = parseFloat( $modal.find('.el_modal_popup_wrapper').data('trigger-delay') ),
210					reRender    = $modal.find('.el_modal_popup_wrapper').data('re-render');
211					if ( ( 'off' === reRender && 'true' !== sessionStorage.getItem( $modalStorageKey ) ) || 'on' === reRender ) {
212						$modal.DiviModalPopup({
213							action: 'open',
214							delay: delay,
215						});
216					}
217			} else if ( 'exit_intent' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ) {
218				/* Trigger modal on exit intent */
219				let reRender = $modal.find('.el_modal_popup_wrapper').data('re-render');
220				$(document).on('mouseout', function(e) {
221					if ( ! $modal.hasClass('el_modal_popup_opened') ) {
222						if ( 
223							( e.toElement == null && e.relatedTarget == null && ( 'off' === reRender && 'true' !== sessionStorage.getItem( $modalStorageKey ) ) ) ||
224							( e.toElement == null && e.relatedTarget == null && 'on' === reRender && 'yes' !== $modal.find('.el_modal_popup_wrapper').data('rendered') )
225						) {
226							$modal.DiviModalPopup({
227								action: 'open',
228							});
229						}
230					}
231				});
232			} else if ( 'on_scroll' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ) {
233				/* Trigger modal on scroll */
234				let docHeight = $('body').outerHeight(),
235					scrollPos = $modal.find('.el_modal_popup_wrapper').data('scroll-position'),
236					reRender  = $modal.find('.el_modal_popup_wrapper').data('re-render');
237					if ( scrollPos.includes('%') ) {
238						scrollPos = ( parseFloat( scrollPos )/100 ) * ( parseFloat( docHeight ) - $(window).outerHeight(true) );
239					}
240					scrollPos = parseFloat( scrollPos );
241				$(window).on('scroll', function(e) {
242					let scrollY = $(window).scrollTop();
243					if ( ! $modal.hasClass('el_modal_popup_opened') ) {
244						if ( 
245							( 'off' === reRender && 'true' !== sessionStorage.getItem( $modalStorageKey ) && scrollY >= scrollPos ) ||
246							( 'on' === reRender && 'yes' !== $modal.find('.el_modal_popup_wrapper').data('rendered') && scrollY >= scrollPos )
247						) {
248							$modal.DiviModalPopup({
249								action: 'open',
250							});
251						}
252					}
253				});
254			} else if ( 'user_inactivity' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ) {
255				// Get the timeout
256				let reRender             = $modal.find('.el_modal_popup_wrapper').data('re-render'),
257					user_inactivity_time = parseInt( $modal.find('.el_modal_popup_wrapper').data('user-inactivity-time') );
258
259				// Add to the timer
260				$user_inactivity_modals[$orderClass] = { 'modal_obj': $modal, 'modalstoragekey': $modalStorageKey, 'timer': '' };
261				if ( ! $modal.hasClass('el_modal_popup_opened') ) {
262					if ( ( 'off' === reRender && 'true' !== sessionStorage.getItem( $modalStorageKey ) ) || 'on' === reRender ) {
263						$user_inactivity_modals[$orderClass]['timer'] = setTimeout( function() {
264							$modal.DiviModalPopup( {
265								action: 'open',
266							} );
267						}, (user_inactivity_time * 1000) );
268					}
269				}
270			}
271		} );
272
273		// Reset user models, on user does activity.
274		const events = [ 'load', 'mousemove', 'mousedown', 'touchstart', 'touchmove', 'click', 'keydown', 'scroll' ];
275		events.forEach( s => window.addEventListener( s, user_inactivity_time_reset, true ) );
276		function user_inactivity_time_reset() {
277			$.each( $user_inactivity_modals, function( key, um ) {
278				// Reset timer if already saved.
279				if ( um.timer && '' !== um.timer ) {
280					clearTimeout( um.timer );
281				}
282
283				// Check the models.
284				const $modal = ( um.modal_obj ) ? um.modal_obj : '';
285				if ( $modal ) {
286					// Get the timeout.
287					let reRender             = $modal.find('.el_modal_popup_wrapper').data('re-render'),
288						user_inactivity_time = parseInt( $modal.find('.el_modal_popup_wrapper').data('user-inactivity-time') ),
289						$modalStorageKey     = ( um.modalstoragekey ) ? um.modalstoragekey : '';
290
291					if ( ! $modal.hasClass('el_modal_popup_opened') ) {
292						if ( ( 'off' === reRender && 'true' !== sessionStorage.getItem( $modalStorageKey ) ) || 'on' === reRender ) {
293							$user_inactivity_modals[key]['timer'] = setTimeout( function() {
294								$modal.DiviModalPopup( {
295									action: 'open',
296								} );
297							}, (user_inactivity_time * 1000) );
298						}
299					}
300				}
301			} );
302		}
303
304		/* Prevent modal closing before it's fully rendered */
305		$('body').on( 'click', '.el_modal_popup_close', function(e){
306			e.preventDefault();
307		} );
308
309		/* Close modal on outside click */
310		$('body').on('click', '.el_modal_popup_opened .el_modal_popup_close_on_background_click', function(e){
311			if ( $(e.target).is( $(this) ) ) {
312				let $modal = $(this).parents('.el_modal_popup');
313				$modal.DiviModalPopup({
314					action: 'close',
315				});
316			}
317		});
318		
319		/* Close modal on close icon click after its fully rendered */
320		$('body').on('click', '.el_modal_popup_opened .el_modal_popup_close', function(e){
321			e.preventDefault();
322			let $modal = $(this).parents('.el_modal_popup'),
323				$href  = $(this).attr('href');
324			$modal.DiviModalPopup({
325				action: 'close',
326				href: $href,
327			});
328		});
329
330		/* Close modal on esc key after its fully rendered */
331		$(document).on('keyup', function(e){
332			if ( e.keyCode === 27 ) {
333				if ( 
334					$('body').hasClass('el_modal_popup_active') &&
335					$('body').find('.el_modal_popup_opened .el_modal_popup_wrapper').hasClass('el_modal_popup_close_on_esc') &&
336					$('body').find('.el_modal_popup_opened .el_modal_popup_wrapper').length > 0
337				) {
338					let $modal = $('body').find('.el_modal_popup_opened');
339					$modal.DiviModalPopup({
340						action: 'close',
341					});
342				}
343			}
344		});
345
346		if ( document.onfullscreenchange === null ) {
347			document.onfullscreenchange = el_modal_popup_on_full_screen_change;
348		} else if ( document.onmsfullscreenchange === null ) {
349			document.onmsfullscreenchange = el_modal_popup_on_full_screen_change;
350		} else if ( document.onmozfullscreenchange === null ) {
351			document.onmozfullscreenchange = el_modal_popup_on_full_screen_change;
352		} else if ( document.onwebkitfullscreenchange === null ) {
353			document.onwebkitfullscreenchange = el_modal_popup_on_full_screen_change;
354		}
355	}
356
357	function el_modal_popup_stop_video($modal) {
358		if ( typeof($modal) === 'undefined' || '' === $modal ) {
359			return false;
360		}
361
362		if ( $modal.find('iframe').length > 0 ) {
363			let src = $modal.find('iframe').attr('src').replace('?autoplay=1&amp;', '?').replace('?autoplay=1&', '?').replace('?autoplay=1', '').replace('&amp;autoplay=1', '').replace('&autoplay=1', '').replace('&mute=1&muted=1', '');
364			$modal.find('iframe').attr('src', src );
365		} else if ( $modal.find('video').length > 0 ) {
366			$modal.find('video').get(0).pause();
367			$modal.find('video').get(0).currentTime = 0;
368		}
369	}
370
371	function el_modal_popup_autoplay_video($modal) {
372		if ( typeof($modal) === 'undefined' || '' === $modal ) {
373			return false;
374		}
375
376		if ( 'on' === $modal.find('.el_modal_popup_wrapper').data('autoplay-video') ) {
377			if ( $modal.find('iframe').length > 0 ) {
378				let mute = 'on_page_load' === $modal.find('.el_modal_popup_wrapper').data('trigger-type') ? true : false;
379				let src = el_modal_popup_add_autoplay_to_url( $modal.find('iframe').attr('src'), mute );
380				$modal.find('iframe').attr('src', src );
381			} else if ( $modal.find('video').length > 0 ) {
382				let promise = $modal.find('video').get(0).play();
383				if ( promise !== undefined ) {
384					promise.then(_ => {
385					}).catch(error => {
386						$modal.find('video').prop('muted', true);
387						$modal.find('video').get(0).play();
388					});
389				}
390			}
391		}
392	}
393
394	function el_modal_popup_add_autoplay_to_url(src, mute) {
395		let uri     = decodeURIComponent( src );
396		let atts    = uri.split('&');
397		if ( 1 === atts.length ) {
398			atts = uri.split('?');
399			if ( 1 !== atts.length ) {
400				uri = uri + '&autoplay=1';
401				if ( mute ) {
402					uri = uri + '&mute=1&muted=1';
403				}
404			} else {
405				uri = uri + '?autoplay=1';
406				if ( mute ) {
407					uri = uri + '&mute=1&muted=1';
408				}
409			}
410		} else {
411			uri = uri + '&autoplay=1';
412			if ( mute ) {
413				uri = uri + '&mute=1&muted=1';
414			}
415		}
416		return uri;
417	}
418
419	function el_modal_popup_get_module_classes() {
420		return [
421			'et_pb_sticky_module', 'et_pb_sticky',
422			'et_pb_sticky--top', 'et_pb_sticky--bottom', 'et_pb_sticky--top_bottom',
423			'et_animated', 'infinite', 'et-waypoint', 'et_had_animation',
424			'fade', 'fadeTop', 'fadeRight', 'fadeBottom', 'fadeLeft',
425			'slide', 'slideTop', 'slideRight', 'slideBottom', 'slideLeft',
426			'bounce', 'bounceTop', 'bounceRight', 'bounceBottom', 'bounceLeft',
427			'zoom', 'zoomTop', 'zoomRight', 'zoomBottom', 'zoomLeft',
428			'flip', 'flipTop', 'flipRight', 'flipBottom', 'flipLeft',
429			'fold', 'foldTop', 'foldRight', 'foldBottom', 'foldLeft',
430			'roll', 'rollTop', 'rollRight', 'rollBottom', 'rollLeft', 'transformAnim',
431		];
432	}
433
434	function el_modal_popup_on_full_screen_change() {
435		let dmpFullScreenElement =
436			document.fullscreenElement ||
437			document.msFullscreenElement ||
438			document.mozFullScreenElement ||
439			document.webkitFullscreenElement;
440
441			if ( !! dmpFullScreenElement ) {
442				jQuery('body').find('.el_modal_popup_active_modal .el_modal_popup_inner_wrap').addClass('el_modal_popup_fullscreen');
443			} else {
444				jQuery('body').find('.el_modal_popup_module .el_modal_popup_inner_wrap').removeClass('el_modal_popup_fullscreen');
445			}
446	}
447 
448}( 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.