PageSourceSearch

https://marktbergel.de/wp-content/plugins/dethemekit-for-elementor/assets/js/de-sticky-frontend.js?ver=2.1.10

js marktbergel.de collected 2026-10-02 22:15:58 UTC 10,415 bytes, 383 lines download raw bytes

1( function( $, elementor ) {
2
3	'use strict';
4
5	var DeSticky = {
6
7		init: function() {
8			elementor.hooks.addAction( 'frontend/element_ready/column', DeSticky.elementorColumn );
9
10			elementorFrontend.hooks.addAction( 'frontend/element_ready/section', DeSticky.setStickySection );
11
12			// $( document ).on( 'ready', DeSticky.stickySection );
13			$( DeSticky.stickySection );
14		},
15
16		elementorColumn: function( $scope ) {
17			var $target  = $scope,
18				$window  = $( window ),
19				columnId = $target.data( 'id' ),
20				editMode = Boolean( elementor.isEditMode() ),
21				settings = {},
22				stickyInstance = null,
23				stickyInstanceOptions = {
24					topSpacing: 50,
25					bottomSpacing: 50,
26					containerSelector: '.elementor-section',
27					innerWrapperSelector: '.elementor-widget-wrap'
28				};
29
30			if ( ! editMode ) {
31				settings = $target.data( 'de-sticky-column-settings' );
32
33				if ( $target.hasClass( 'de-sticky-column-sticky' ) ) {
34
35					if ( -1 !== settings['stickyOn'].indexOf( elementorFrontend.getCurrentDeviceMode() ) ) {
36
37						stickyInstanceOptions.topSpacing = settings['topSpacing'];
38						stickyInstanceOptions.bottomSpacing = settings['bottomSpacing'];
39
40						$target.data( 'stickyColumnInit', true );
41						stickyInstance = new StickySidebar( $target[0], stickyInstanceOptions );
42
43						$window.on( 'resize.DeStickyColumnSticky orientationchange.DeStickyColumnSticky', DeStickyTools.debounce( 50, resizeDebounce ) );
44					}
45				}
46			} else {
47				settings = DeSticky.columnEditorSettings( columnId );
48
49				if ( 'true' === settings['sticky'] ) {
50					$target.addClass( 'de-sticky-column-sticky' );
51
52					if ( -1 !== settings['stickyOn'].indexOf( elementorFrontend.getCurrentDeviceMode() ) ) {
53						stickyInstanceOptions.topSpacing = settings['topSpacing'];
54						stickyInstanceOptions.bottomSpacing = settings['bottomSpacing'];
55
56						$target.data( 'stickyColumnInit', true );
57						stickyInstance = new StickySidebar( $target[0], stickyInstanceOptions );
58
59						$window.on( 'resize.DeStickyColumnSticky orientationchange.DeStickyColumnSticky', DeStickyTools.debounce( 50, resizeDebounce ) );
60					}
61				}
62			}
63			
64
65			function resizeDebounce() {
66				var currentDeviceMode = elementorFrontend.getCurrentDeviceMode(),
67					availableDevices  = settings['stickyOn'] || [],
68					isInit            = $target.data( 'stickyColumnInit' );
69
70				if ( -1 !== availableDevices.indexOf( currentDeviceMode ) ) {
71
72					if ( ! isInit ) {
73						$target.data( 'stickyColumnInit', true );
74						stickyInstance = new StickySidebar( $target[0], stickyInstanceOptions );
75						stickyInstance.updateSticky();
76					}
77				} else {
78					$target.data( 'stickyColumnInit', false );
79					stickyInstance.destroy();
80				}
81			}
82			
83
84		},
85
86		columnEditorSettings: function( columnId ) {
87			var editorElements = null,
88				columnData     = {};
89
90			if ( ! window.elementor.hasOwnProperty( 'elements' ) ) {
91				return false;
92			}
93
94			editorElements = window.elementor.elements;
95
96			if ( ! editorElements.models ) {
97				return false;
98			}
99
100			$.each( editorElements.models, function( index, obj ) {
101
102				$.each( obj.attributes.elements.models, function( index, obj ) {
103					if ( columnId == obj.id ) {
104						columnData = obj.attributes.settings.attributes;
105					}
106				} );
107
108			} );
109
110			return {
111				// 'active': columnData['dethemekit_carousel_active_column'] || false,
112				'sticky': columnData['de_sticky_column_sticky_enable'] || false,
113				'topSpacing': columnData['de_sticky_column_sticky_top_spacing'] || 50,
114				'bottomSpacing': columnData['de_sticky_column_sticky_bottom_spacing'] || 50,
115				'stickyOn': columnData['de_sticky_column_sticky_enable_on'] || [ 'desktop', 'tablet', 'mobile']
116			}
117		},
118
119		getStickySectionsDesktop: [],
120		getStickySectionsTablet:  [],
121		getStickySectionsMobile:  [],
122
123		setStickySection: function( $scope ) {
124			var setStickySection = {
125
126				target: $scope,
127				
128				isEditMode: Boolean( elementorFrontend.isEditMode() ),
129
130				init: function() {
131					if ( this.isEditMode ) {
132						return;
133					}
134
135					if (  'yes' === this.getSectionSetting( 'de_sticky_section_sticky' ) ) {
136						var availableDevices = this.getSectionSetting( 'de_sticky_section_sticky_visibility' ) || [];
137
138						if ( ! availableDevices[0] ) {
139							return;
140						}
141
142						if ( -1 !== availableDevices.indexOf( 'desktop' ) ) {
143							DeSticky.getStickySectionsDesktop.push( $scope );
144						}
145
146						if ( -1 !== availableDevices.indexOf( 'tablet' ) ) {
147							DeSticky.getStickySectionsTablet.push( $scope );
148						}
149
150						if ( -1 !== availableDevices.indexOf( 'mobile' ) ) {
151							DeSticky.getStickySectionsMobile.push( $scope );
152						}
153					}
154				},
155
156				getSectionSetting: function( setting ){
157					var settings = {},
158						editMode = Boolean( elementorFrontend.isEditMode() );
159
160					if ( editMode ) {
161						if ( ! elementorFrontend.hasOwnProperty( 'config' ) ) {
162							return;
163						}
164
165						if ( ! elementorFrontend.config.hasOwnProperty( 'elements' ) ) {
166							return;
167						}
168
169						if ( ! elementorFrontend.config.elements.hasOwnProperty( 'data' ) ) {
170							return;
171						}
172
173						var modelCID = this.target.data( 'model-cid' ),
174							editorSectionData = elementorFrontend.config.elements.data[ modelCID ];
175
176						if ( ! editorSectionData ) {
177							return;
178						}
179
180						if ( ! editorSectionData.hasOwnProperty( 'attributes' ) ) {
181							return;
182						}
183
184						settings = editorSectionData.attributes || {};
185					} else {
186						settings = this.target.data( 'settings' ) || {};
187					}
188
189					if ( ! settings[ setting ] ) {
190						return;
191					}
192
193					return settings[ setting ];
194				},
195
196				
197			};
198
199			setStickySection.init();
200		},
201
202		stickySection: function() {
203			var stickySection = {
204
205				isEditMode: Boolean( elementorFrontend.isEditMode() ),
206
207				correctionSelector: $( '#wpadminbar' ),
208
209				initDesktop: false,
210				initTablet:  false,
211				initMobile:  false,
212
213				init: function() {
214					if ( this.isEditMode ) {
215						return;
216					}
217
218					this.run();
219					$( window ).on( 'resize.DeStickySectionSticky orientationchange.DeStickySectionSticky', this.run.bind( this ) );
220				},
221
222				getOffset: function(){
223					var offset = 0;
224
225					if ( this.correctionSelector[0] && 'fixed' === this.correctionSelector.css( 'position' ) ) {
226						offset = this.correctionSelector.outerHeight( true );
227					}
228
229					return offset;
230				},
231
232				run: function() {
233					var currentDeviceMode = elementorFrontend.getCurrentDeviceMode(),
234						transitionIn  = 'de-sticky-transition-in',
235						transitionOut = 'de-sticky-transition-out',
236						options = {
237							stickyClass: 'de-sticky-section-sticky--stuck',
238							topSpacing: this.getOffset()
239						};
240
241					function initSticky ( section, options ) {
242						section.deStickySection( options )
243							.on( 'deStickySection:stick', function( event ) {
244								$( event.target ).addClass( transitionIn );
245								setTimeout( function() {
246									$( event.target ).removeClass( transitionIn );
247								}, 3000 );
248							} )
249							.on( 'deStickySection:unstick', function( event ) {
250								$( event.target ).addClass( transitionOut );
251								setTimeout( function() {
252									$( event.target ).removeClass( transitionOut );
253								}, 3000 );
254							} );
255						section.trigger( 'deStickySection:activated' );
256					}
257
258					if ( 'desktop' === currentDeviceMode && ! this.initDesktop ) {
259						if ( this.initTablet ) {
260							DeSticky.getStickySectionsTablet.forEach( function( section, i ) {
261								section.trigger( 'deStickySection:detach' );
262							});
263
264							this.initTablet = false;
265						}
266
267						if ( this.initMobile ) {
268							DeSticky.getStickySectionsMobile.forEach( function( section, i ) {
269								section.trigger( 'deStickySection:detach' );
270							});
271
272							this.initMobile = false;
273						}
274
275						if ( DeSticky.getStickySectionsDesktop[0] ) {
276							DeSticky.getStickySectionsDesktop.forEach( function( section, i ) {
277
278								if ( DeSticky.getStickySectionsDesktop[i+1] ) {
279									options.stopper = DeSticky.getStickySectionsDesktop[i+1];
280								} else {
281									options.stopper = '';
282								}
283
284								initSticky( section, options );
285							});
286
287							this.initDesktop = true;
288						}
289					}
290
291					if ( 'tablet' === currentDeviceMode && ! this.initTablet ) {
292						if ( this.initDesktop ) {
293							DeSticky.getStickySectionsDesktop.forEach( function( section, i ) {
294								section.trigger( 'deStickySection:detach' );
295							});
296
297							this.initDesktop = false;
298						}
299
300						if ( this.initMobile ) {
301							DeSticky.getStickySectionsMobile.forEach( function( section, i ) {
302								section.trigger( 'deStickySection:detach' );
303							});
304
305							this.initMobile = false;
306						}
307
308						if ( DeSticky.getStickySectionsTablet[0] ) {
309							DeSticky.getStickySectionsTablet.forEach( function( section, i ) {
310								if ( DeSticky.getStickySectionsTablet[i+1] ) {
311									options.stopper = DeSticky.getStickySectionsTablet[i+1];
312								} else {
313									options.stopper = '';
314								}
315
316								initSticky( section, options );
317							});
318
319							this.initTablet = true;
320						}
321					}
322
323					if ( 'mobile' === currentDeviceMode && ! this.initMobile ) {
324						if ( this.initDesktop ) {
325							DeSticky.getStickySectionsDesktop.forEach( function( section, i ) {
326								section.trigger( 'deStickySection:detach' );
327							});
328
329							this.initDesktop = false;
330						}
331
332						if ( this.initTablet ) {
333							DeSticky.getStickySectionsTablet.forEach( function( section, i ) {
334								section.trigger( 'deStickySection:detach' );
335							});
336
337							this.initTablet = false;
338						}
339
340						if ( DeSticky.getStickySectionsMobile[0] ) {
341							DeSticky.getStickySectionsMobile.forEach( function( section, i ) {
342
343								if ( DeSticky.getStickySectionsMobile[i+1] ) {
344									options.stopper = DeSticky.getStickySectionsMobile[i+1];
345								} else {
346									options.stopper = '';
347								}
348
349								initSticky( section, options );
350							});
351
352							this.initMobile = true;
353						}
354					}
355				}
356			};
357
358			stickySection.init();
359		}
360	};
361
362	$( window ).on( 'elementor/frontend/init', DeSticky.init );
363
364	var DeStickyTools = {
365		debounce: function( threshold, callback ) {
366			var timeout;
367
368			return function debounced( $event ) {
369				function delayed() {
370					callback.call( this, $event );
371					timeout = null;
372				}
373
374				if ( timeout ) {
375					clearTimeout( timeout );
376				}
377
378				timeout = setTimeout( delayed, threshold );
379			};
380		}
381	}
382
383}( 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.