PageSourceSearch

https://www.pascucci.it/wp-content/themes/hamilton/assets/js/global.js?ver=7.1.2

js pascucci.it collected 2026-10-02 21:26:36 UTC 5,299 bytes, 201 lines download raw bytes

1jQuery( document ).ready( function( $ ) {
2	
3	
4	// Add class to elements when they're in view
5	function isScrolledIntoView(elem) {
6		var docViewTop = $(window).scrollTop(),
7			docViewBottom = docViewTop + $(window).height();
8
9		var elemTop = $( elem ).offset().top,
10			elemBuffer = $( window ).width > 600 ? 200 : 50,
11			elemBottom = elemTop + elemBuffer;
12
13		return ( elemBottom <= docViewBottom );
14	}
15	
16	function fadeInSpotted() {
17		$( '.tracker' ).each( function () {
18			$( this ).addClass( 'will-spot' );
19			if ( $( this ).offset().top < $( window ).height() ) {
20				$( this ).addClass( 'spotted' );
21			}
22		} );
23	}
24	
25	if ( $( '.tracker' ).length ) {
26		$( window ).on( 'load', function () {
27			fadeInSpotted();
28		} );
29		$( window ).scroll( function () {
30			$( '.tracker' ).each( function () {
31				if ( isScrolledIntoView( this ) === true ) {
32					$( this ).addClass( 'spotted' );
33				}
34			} );
35		} );
36	}
37	
38	
39	//Masonry blocks
40	$container = $( '.posts' );
41	
42	$container.css({ 'opacity': 0 });
43	
44	function masonryInit(){
45		$container.masonry({
46			itemSelector: '.post-preview',
47			percentPosition: true,
48			transitionDuration: 0,
49		} );
50	}
51
52	$container.imagesLoaded().done( function(){
53		masonryInit();
54		fadeInSpotted();
55		$container.animate({ opacity: 1.0 }, 500 );
56	});
57	
58	$( document ).ready( function() { 
59		setTimeout( function() { masonryInit(); }, 500 ); 
60	} );
61
62	$( window ).resize( function () {
63		masonryInit();
64	} );
65	
66	
67	// Parallax effect on the fade blocks
68	var scroll = window.requestAnimationFrame ||
69				 window.webkitRequestAnimationFrame ||
70				 window.mozRequestAnimationFrame ||
71				 window.msRequestAnimationFrame ||
72				 window.oRequestAnimationFrame ||
73				 // IE Fallback, you can even fallback to onscroll
74				 function(callback){ window.setTimeout(callback, 1000/60) };
75				 
76	function loop(){
77	
78		var windowOffset = window.pageYOffset;
79		
80		if ( windowOffset < $( window ).outerHeight() ) {
81            $( '.fade-block' ).css({ 
82				'transform': 'translateY( ' + Math.ceil ( windowOffset * 0.25 ) + 'px)',
83				'opacity': 1 - ( windowOffset * 0.002 )
84			});
85        }
86	
87		scroll( loop )
88	
89	}
90	loop();
91
92
93	// Toggle navigation
94	$( '.nav-toggle' ).on( 'click', function(){	
95		$( this ).add( '.site-nav' ).toggleClass( 'active' );
96		$( 'body' ).toggleClass( 'lock-screen' );
97	} );
98	
99        			
100	// Resize videos after their container
101	var vidSelector = ".post iframe, .post object, .post video, .widget-content iframe, .widget-content object, .widget-content iframe";	
102	var resizeVideo = function(sSel) {
103		$( sSel ).each(function() {
104			var $video = $(this),
105				$container = $video.parent(),
106				iTargetWidth = $container.width();
107
108			if ( !$video.attr("data-origwidth") ) {
109				$video.attr("data-origwidth", $video.attr("width"));
110				$video.attr("data-origheight", $video.attr("height"));
111			}
112
113			var ratio = iTargetWidth / $video.attr("data-origwidth");
114
115			$video.css("width", iTargetWidth + "px");
116			$video.css("height", ( $video.attr("data-origheight") * ratio ) + "px");
117		});
118	};
119
120	resizeVideo( vidSelector );
121
122	$( window ).resize( function() {
123		resizeVideo( vidSelector );
124	} );
125	
126	
127	// Smooth scroll to anchor links
128	$('a[href*="#"]')
129	// Remove links that don't actually link to anything
130	.not('[href="#"]')
131	.not('[href="#0"]')
132	.not( '.skip-link' )
133	.click(function(event) {
134		// On-page links
135		if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) {
136			// Figure out element to scroll to
137			var target = $(this.hash);
138			target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
139			// Does a scroll target exist?
140			if (target.length) {
141				// Only prevent default if animation is actually gonna happen
142				event.preventDefault();
143					$('html, body').animate({
144					scrollTop: target.offset().top
145				}, 1000 );
146			}
147		}
148	})
149	
150	
151	// If the website has a custom logo, adjust the site-nav top
152	// padding to make sure it is consistent with image dimensions
153	if ( $( 'body').hasClass( 'wp-custom-logo' ) ) {
154
155		var headerHeight = $( '.site-header' ).outerHeight();
156		$( '.site-nav' ).css( 'padding-top', headerHeight + 'px' );
157
158		$( window ).resize( function() {
159			var headerHeight = $( '.site-header' ).outerHeight();
160			$( '.site-nav' ).css( 'padding-top', headerHeight + 'px' );
161		} );
162
163	}
164	
165	// Triggers re-layout on Jetpack infinite scroll
166    $( document.body ).on( 'post-load', function() {
167		
168		// Target the new items and hide them
169		var $selector = $( '.infinite-wrap' ).last(),
170        	$elements = $selector.find( '.post-preview' );
171			
172		$elements.hide();
173
174		// When images are loaded, show them again
175        $elements.imagesLoaded().done( function(){
176            $container.append( $elements );
177			$elements.show();
178			$container.masonry( 'appended', $elements );
179			
180			// Prepare for fade-in animation on scroll
181			$elements.each( function( index ) {
182				if ( $( this ).offset().top < ( $( window ).height() + $( window ).scrollTop() ) ) {
183					$( this ).addClass( 'jetpack-fade-in' );
184				} else {
185					$( this ).addClass( 'will-spot' ).removeClass( 'spotted' );
186				}
187				
188			} );
189			
190			setTimeout( function() { 
191				masonryInit();
192			}, 500 ); 
193			
194			// Show the load more button again
195			$( '#infinite-handle' ).fadeIn();
196			
197        });
198
199    });
200	
201});

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.