PageSourceSearch

https://www.dirs21.de/wp-content/plugins/advanced-popups/public/js…anced-popups-public.js?ver=1.2.4.1790237686

js dirs21.de collected 2026-09-24 10:06:27 UTC 10,705 bytes, 429 lines download raw bytes

1"use strict";
2
3jQuery(document).ready(function($) {
4
5	var adpPopup = {};
6
7	( function() {
8		var $this;
9
10		adpPopup = {
11			sPrevious : window.scrollY,
12			sDirection: 'down',
13
14			/*
15			* Initialize
16			*/
17			init: function( e ) {
18				$this = adpPopup;
19
20				$this.popupInit( e );
21
22				// Init events.
23				$this.events( e );
24			},
25
26			/*
27			* Events
28			*/
29			events: function( e ) {
30				// Custom Events
31				$( document ).on( 'click', '.adp-popup-close', $this.closePopup );
32				$( document ).on( 'click', '.adp-popup-accept', $this.acceptPopup );
33				$( document ).on( 'click', '.adp-popup-accept', $this.closePopup );
34
35				// Checking this will cause popup to close when user presses key.
36				$( document ).keyup(function(e) {
37					// Press ESC to Close.
38					if ( e.key === 'Escape' ) {
39						$( '.adp-popup-open[data-esc-close="true"]' ).each(function(index, popup) {
40							$this.closePopup(popup);
41						});
42					}
43
44					// Press F4 to Close.
45					if ( e.key === 'F4' ) {
46						$( '.adp-popup-open[data-f4-close="true"]' ).each(function(index, popup) {
47							$this.closePopup(popup);
48						});
49					}
50				});
51
52				// Checking this will cause popup to close when user clicks on overlay.
53				$( document ).on( 'click', '.adp-popup-overlay', function( e ) {
54					$this.closePopup( $( this).prev() );
55				} );
56			},
57
58			/*
59			* Init popup elements
60			*/
61			popupInit: function( e ) {
62
63				// Set scroll direction.
64				$( document ).on( 'scroll', function() {
65
66					let scrollCurrent = window.scrollY;
67
68					// Set scroll temporary vars.
69					if ( scrollCurrent > $this.sPrevious ) {
70						$this.sDirection = 'down';
71					} else {
72						$this.sDirection = 'up';
73					}
74
75					$this.sPrevious = scrollCurrent;
76				});
77
78				// Open popup
79				$( '.adp-popup' ).each(function(index, popup) {
80					// Manual Launch.
81					if ( 'manual' === $( popup ).data( 'open-trigger' ) ) {
82
83						let selector = $( popup ).data( 'open-manual-selector' );
84
85						if ( selector ) {
86
87							$( document ).on( 'click', selector, function( e ) {
88								event.preventDefault();
89
90								$( popup ).removeClass( 'adp-popup-already-opened' );
91
92								$this.openPopup( popup );
93							} );
94						}
95					}
96
97					// Checks whether a popup should be displayed or not.
98					if ( ! $this.isAllowPopup( popup ) ) {
99						return;
100					}
101
102					$this.openTriggerPopup( popup );
103				});
104			},
105
106			/*
107			* Trigger open popup
108			*/
109			openTriggerPopup: function( e ) {
110				let popup = ( e.originalEvent ) ? this : e;
111
112				var trigger = $( popup ).data( 'open-trigger' );
113
114				// Page Viewed.
115				if ( 'viewed' === trigger ) {
116					$this.openPopup( popup );
117				}
118
119				// Time Delay.
120				if ( 'delay' === trigger ) {
121					setTimeout( function() {
122
123						$this.openPopup( popup );
124
125					}, $( popup ).data( 'open-delay-number' ) * 1000 );
126				}
127
128				// Exit Intent.
129				if ( 'exit' === trigger ) {
130					var showExit = true;
131					document.addEventListener( "mousemove", function( e ) {
132						// Get current scroll position
133						var scroll = window.pageYOffset || document.documentElement.scrollTop;
134						if ( ( e.pageY - scroll ) < 7 && showExit ) {
135							$this.openPopup( popup );
136							showExit = false;
137						}
138					} );
139				}
140
141				// Scroll Position.
142				if ( 'read' === trigger || 'scroll' === trigger ) {
143
144					var pointScrollType     = $( popup ).data( 'open-scroll-type' );
145					var pointScrollPosition = $( popup ).data( 'open-scroll-position' );
146
147					if ( 'read' === trigger ) {
148						pointScrollType     = '%';
149						pointScrollPosition = 100;
150					}
151
152					// Event scroll.
153					$( document ).on( 'scroll', function() {
154
155						// Type px.
156						if ( 'px' === pointScrollType ) {
157
158							if ( window.scrollY >= pointScrollPosition ) {
159								$this.openPopup( popup );
160							}
161						}
162
163						// Type %.
164						if ( '%' === pointScrollType ) {
165
166							if ( $this.getScrollPercent() >= pointScrollPosition ) {
167								$this.openPopup( popup );
168							}
169						}
170					} );
171				}
172
173				// Accept Agreement.
174				if ( 'accept' === trigger ) {
175					let accept = $this.getCookie( 'adp-popup-accept-' + $( popup ).data( 'id' ) || 0 );
176
177					if ( ! accept ) {
178						$this.openPopup( popup );
179					}
180				}
181			},
182
183			/*
184			* Trigger close popup
185			*/
186			closeTriggerPopup: function( e ) {
187				let popup = ( e.originalEvent ) ? this : e;
188
189				var trigger = $( popup ).data( 'close-trigger' );
190
191				// Time Delay.
192				if ( 'delay' === trigger ) {
193					setTimeout( function() {
194
195						$this.closePopup(popup);
196
197					}, $( popup ).data( 'close-delay-number' ) * 1000 );
198				}
199
200				// Scroll Position.
201				if ( 'scroll' === trigger ) {
202
203					var pointScrollType     = $( popup ).data( 'close-scroll-type' );
204					var pointScrollPosition = $( popup ).data( 'close-scroll-position' );
205					var initScrollPx        = $( popup ).data( 'init-scroll-px' );
206					var initScrollPercent   = $( popup ).data( 'init-scroll-percent' );
207
208					// Event scroll.
209					$( document ).on( 'scroll', function() {
210
211						// Type px.
212						if ( 'px' === pointScrollType ) {
213
214							if ( 'up' === $this.sDirection && window.scrollY < ( initScrollPx - pointScrollPosition ) ) {
215								$this.closePopup( popup );
216							}
217
218							if ( 'down' === $this.sDirection && window.scrollY >= ( initScrollPx + pointScrollPosition ) ) {
219								$this.closePopup( popup );
220							}
221						}
222
223						// Type %.
224						if ( '%' === pointScrollType ) {
225
226							if ( 'up' === $this.sDirection && $this.getScrollPercent() < ( initScrollPercent - pointScrollPosition ) ) {
227								$this.closePopup(popup);
228							}
229
230							if ( 'down' === $this.sDirection && $this.getScrollPercent() >= ( initScrollPercent + pointScrollPosition ) ) {
231								$this.closePopup(popup);
232							}
233						}
234					} );
235				}
236			},
237
238			/*
239			* Open popup
240			*/
241			openPopup: function( e ) {
242				let popup = ( e.originalEvent ) ? this : e;
243
244				if ( $( popup ).hasClass( 'adp-popup-open' ) ) {
245					return;
246				}
247
248				// Check already opened.
249				if ( $( popup ).hasClass( 'adp-popup-already-opened' ) ) {
250					return;
251				}
252
253				// Display popup.
254				$( popup ).addClass( 'adp-popup-open' );
255
256				// Set current scroll.
257				$( popup ).data( 'init-scroll-px', window.scrollY );
258				$( popup ).data( 'init-scroll-percent', $this.getScrollPercent() );
259
260				// Hide body scroll.
261				if ( $( popup ).is( '[data-body-scroll-disable="true"]' ) ) {
262					$( 'body' ).addClass( 'adp-popup-scroll-hidden' );
263				}
264
265				// Set Cookie of Limit display.
266				let limit = parseInt( $this.getCookie( 'adp-popup-' + $( popup ).data( 'id' ) ) || 0 ) + 1;
267
268				$this.setCookie( 'adp-popup-' + $( popup ).data( 'id' ), limit, {
269					expires: $( popup ).data( 'limit-lifetime' )
270				} );
271
272				// Open animation.
273				let animation = $( popup ).data( 'open-animation' );
274
275				$this.applyAnimation( popup, animation );
276
277				// Init close trigger.
278				$this.closeTriggerPopup( popup );
279			},
280
281			/*
282			* Accept popup
283			*/
284			acceptPopup: function( e ) {
285
286				let $el = ( e.originalEvent ) ? this : e;
287
288				// Get popup container.
289				let popup = $( $el ).closest( '.adp-popup' );
290
291				// Set Cookie of Accept.
292				$this.setCookie( 'adp-popup-accept-' + $( popup ).data( 'id' ), 1, {
293					expires: 360
294				} );
295			},
296
297			/*
298			* Close popup
299			*/
300			closePopup: function( e ) {
301
302				let $el = ( e.originalEvent ) ? this : e;
303
304				// Get popup container.
305				let popup = $( $el ).closest( '.adp-popup' );
306
307				// Close animation.
308				let animation = $( popup ).data( 'exit-animation' );
309
310				$this.applyAnimation( popup, animation, function() {
311					// Already opened.
312					$( popup ).addClass( 'adp-popup-already-opened' );
313
314					// Hide popup.
315					$( popup ).removeClass( 'adp-popup-open' );
316
317					// Remove classes from body.
318					$( 'body' ).removeClass( 'adp-popup-scroll-hidden' );
319				} );
320			},
321
322			/*
323			* Checks whether a popup should be displayed or not
324			*/
325			isAllowPopup: function( e ) {
326				let popup = ( e.originalEvent ) ? this : e;
327
328				// Has user seen this popup before?
329				let limitDisplay = parseInt( $( popup ).data( 'limit-display' ) || 0 );
330
331				let limitDisplayCookie = parseInt( $this.getCookie( 'adp-popup-' + $( popup ).data( 'id' ) ) );
332
333				if ( limitDisplay && limitDisplayCookie && limitDisplayCookie >= limitDisplay ) {
334					return;
335				}
336
337				return true;
338			},
339
340			/*
341			* Apply animation
342			*/
343			applyAnimation: function( el, name, callback ) {
344				var popup = $( el ).closest( '.adp-popup' );
345
346				if ( typeof callback === 'function' ) {
347					var overlayName = 'popupExitFade';
348				} else {
349					var overlayName = 'popupOpenFade';
350				}
351
352				// Overlay Animation.
353				$( popup ).next( '.adp-popup-overlay' ).addClass( 'adp-popup-animated ' + overlayName )
354					.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
355						$( this ).removeClass( 'adp-popup-animated ' + overlayName );
356					} );
357
358				// Wrap Animation.
359				$( popup ).find( '.adp-popup-wrap' ).addClass( 'adp-popup-animated ' + n
359ame )
360					.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
361						// remove the animation classes after animation ends
362						// required in order to apply new animation on close
363						$( this ).removeClass( 'adp-popup-animated ' + name );
364
365						if ( typeof callback === 'function' ) {
366							callback();
367						}
368					} );
369			},
370
371			/*
372			* Set cookie
373			*/
374			getCookie: function( name ) {
375				var matches = document.cookie.match( new RegExp(
376					"(?:^|; )" + name.replace( /([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1' ) + "=([^;]*)"
377				) );
378				return matches ? decodeURIComponent( matches[ 1 ] ) : undefined;
379			},
380
381			/*
382			* Set cookie
383			*/
384			setCookie: function( name, value, options ) {
385				options = options || {};
386
387				options.path = options.hasOwnProperty( 'path' ) ? options.path : '/';
388
389				options.expires = parseInt( options.expires );
390
391				if ( typeof options.expires == "number" && options.expires ) {
392
393					options.expires = new Date().setDate(new Date().getDate() + options.expires );
394
395					options.expires = new Date(options.expires).toUTCString();
396				}
397
398				value = encodeURIComponent( value );
399
400				var updatedCookie = name + "=" + value;
401
402				for ( var propName in options ) {
403					updatedCookie += "; " + propName;
404					var propValue = options[ propName ];
405					if ( propValue !== true ) {
406						updatedCookie += "=" + propValue;
407					}
408				}
409
410				document.cookie = updatedCookie;
411			},
412
413			/*
414			* Get scroll percent
415			*/
416			getScrollPercent: function() {
417				var h = document.documentElement,
418					b = document.body,
419					st = 'scrollTop',
420					sh = 'scrollHeight';
421				return (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100;
422			}
423		};
424
425	} )();
426
427	// Initialize.
428	adpPopup.init();
429});

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.