PageSourceSearch

https://zod.hr/wp-content/themes/zod/assets/js/sticky.js?ver=4.9.14

js zod.hr collected 2026-10-02 06:10:32 UTC 5,897 bytes, 193 lines download raw bytes

1jQuery( function( $ ) {
2	"use strict";
3
4	if ( $( '.header_is_sticky' ).length ) {
5
6		var body = $( document.body ),
7			inla = $( '.inner_layout' ),
8			abar = $( '.admin-bar' ).length ? 32 : 0;
9
10		/* Sticky */
11		setTimeout( function() {
12
13			$( '.header_is_sticky' ).each( function( n, x ) {
14
15				var header_sticky 	= $( x ),
16					header_5 		= $( '.header_5' ),
17					fixed_side 		= $( '.fixed_side_left' ).length ? 'right' : $( '.fixed_side_left' ).length ? 'left' : '',
18					lastScrollTop 	= 0, 
19					st, sticky_func,
20					h1h = 0,
21					h2h = 0,
22					h3h = 0,
23					scrollTop = header_sticky.offset().top,
24					h_offset = header_sticky.position(),
25					sidebar = $( '.cz_sticky .sidebar_primary > div, .cz_sticky .row > aside > div, .cz_sticky_col:not(.images) > div, .column-xtra-sticky > div' ),
26					smart_sticky = function( scroll ) {
27
28						if ( header_sticky.hasClass( 'smart_sticky' ) || ( $( '.cz_fixed_footer' ).length && $( '.page_content' ).length && ( $( '.page_content' ).offset().top + $( '.page_content' ).height() <= $( window ).scrollTop() + header_sticky.height() ) ) ) {
29
30							st = scroll.scrollTop();
31
32							var oHeight = header_sticky.outerHeight();
33
34							if ( st > ( h_offset.top + oHeight + 100 ) && st > lastScrollTop ) {
35
36								sidebar.css( 'margin-top', '-' + oHeight + 'px' );
37								header_sticky.css( 'transform', 'translateY(-' + ( oHeight + 20 ) + 'px)' );
38
39							} else if ( header_sticky.hasClass( 'header_5' ) && st < 200 ) {
40
41								header_sticky.css( 'transform', '' );
42
43							} else if ( st < lastScrollTop ) {
44
45								sidebar.css( 'margin-top', '' );
46								header_sticky.css( 'transform', 'none' );
47
48							}
49
50							lastScrollTop = st;
51
52						}
53						
54					};
55
56				if ( header_sticky.hasClass( 'header_5' ) ) {
57
58					header_5.addClass( 'onSticky' );
59
60					$( window ).on( 'scroll.sticky', function(e) {
61
62						var ph = header_5.height(),
63							il = inla.width();
64
65						// Fixed side compatible.
66						if ( fixed_side ) {
67							header_sticky.css( fixed_side, '0' );
68						}
69
70						if ( $( window ).scrollTop() >= ph ) {
71							header_5.css( 'transform', 'none' ).css( 'width', il + 'px' );
72						} else {
73							header_5.css( 'transform', 'translateY(-' + ( ph + 20 ) + 'px)' ).css( 'width', il + 'px' );
74						}
75
76						smart_sticky( $( this ) );
77
78					});
79
80				} else if ( header_sticky.length ) {
81
82					/* Add corpse */
83					if ( ! header_sticky.prev( '.Corpse_Sticky').length ) {
84						header_sticky.before( '<div class="Corpse_Sticky' + ( header_sticky.hasClass( 'header_4' ) ? ' cz_sticky_corpse_for_header_4' : '' ) + '" aria-hidden="true"></div>' );
85					}
86
87					var scroll_down,
88						scroll_top,
89						new_scrollTop,
90						cz_sticky_h12 = $( '.cz_sticky_h12' ).length,
91						cz_sticky_h13 = $( '.cz_sticky_h13' ).length,
92						cz_sticky_h23 = $( '.cz_sticky_h23' ).length,
93						cz_sticky_h123 = $( '.cz_sticky_h123' ).length;
94
95					sticky_func = function(e) {
96
97						if ( header_sticky.hasClass( 'header_4' ) && header_sticky.css( 'display' ) == 'none' ) {
98							return;
99						}
100
101						new_scrollTop = scrollTop;
102
103						if ( $( '.header_1' ).length ) {
104							h1h = $( '.header_1' ).outerHeight();
105						}
106						if ( $( '.header_2' ).length ) {
107							h2h = $( '.header_2' ).outerHeight();
108						}
109						if ( $( '.header_3' ).length ) {
110							h3h = $( '.header_3' ).outerHeight();
111						}
112
113						if ( cz_sticky_h12 && header_sticky.hasClass( 'header_2' ) ) {
114							new_scrollTop = scrollTop + 1 - h1h;
115						} else if ( cz_sticky_h13 && header_sticky.hasClass( 'header_3' ) ) {
116							new_scrollTop = scrollTop + 1 - h1h;
117						} else if ( cz_sticky_h23 && header_sticky.hasClass( 'header_3' ) ) {
118							new_scrollTop = scrollTop + 1 - h2h;
119						} else if ( cz_sticky_h123 ) {
120
121							if ( header_sticky.hasClass( 'header_2' ) ) {
122								new_scrollTop = scrollTop + 1 - h1h;
123							}
124
125							if ( header_sticky.hasClass( 'header_3' ) ) {
126								new_scrollTop = scrollTop + 1 - ( h1h + h2h );
127							}
128
129						}
130
131						abar = $( '.xtra-preview-header' ).is( ':visible' ) ? 54 : abar;
132
133						scroll_top = $( window ).scrollTop() + abar;
134
135						if ( scroll_top === abar && ( body.hasClass( 'admin-bar' ) || body.hasClass( 'compose-mode' ) ) ) {
136							scroll_top = -abar;
137						}
138
139						scroll_down = scroll_top > new_scrollTop;
140
141						// Fixed side compatible.
142						if ( fixed_side ) {
143							header_sticky.css( fixed_side, '0' );
144						}
145
146						// Sticky width.
147						var il = inla.width();
148
149						smart_sticky( $( this ) );
150						header_sticky.css( 'width', il + 'px' );
151
152						if ( scroll_down ) {
153							header_sticky.prev( '.Corpse_Sticky' ).css({
154								'height': header_sticky.outerHeight() + 'px'
155							});
156							header_sticky.delay( 100 ).addClass( 'onSticky' );
157						} else {
158
159							header_sticky.css( 'marginTop', '' ).removeClass( 'onSticky' ).prev( '.Corpse_Sticky').css({
160								'height': 'auto'
161							});
162
163							header_sticky.css( 'width', '' );
164
165						}
166
167						if ( scroll_down && cz_sticky_h12 && header_sticky.hasClass( 'header_2' ) ) {
168							$( '.header_2' ).css( 'marginTop', h1h );
169						} else if ( scroll_down && cz_sticky_h13 && header_sticky.hasClass( 'header_3' ) ) {
170							$( '.header_3' ).css( 'marginTop', h1h );
171						} else if ( scroll_down && cz_sticky_h23 && header_sticky.hasClass( 'header_3' ) ) {
172							$( '.header_3' ).css( 'marginTop', h2h );
173						} else if ( cz_sticky_h123 ) {
174							if ( scroll_down && header_sticky.hasClass( 'header_2' ) ) {
175								$( '.header_2' ).css( 'marginTop', h1h );
176							}
177							if ( scroll_down && header_sticky.hasClass( 'header_3' ) ) {
178								$( '.header_3' ).css( 'marginTop', ( h1h + h2h ) );
179							}
180						}
181					};
182
183					$( window ).off( 'scroll.cz_sticky_' + n ).on( 'scroll.cz_sticky_' + n, sticky_func );
184					$( window ).off( 'resize.cz_sticky_' + n ).on( 'resize.cz_sticky_' + n, sticky_func );
185				}
186
187			});
188
189		}, 750 );
190
191	}
192
193});

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.