PageSourceSearch

https://middleby.co.uk/wp-content/themes/inspiro/assets/js/inspiro-misc.js?ver=2.2.4

js middleby.co.uk collected 2026-10-02 00:13:37 UTC 1,887 bytes, 83 lines download raw bytes

1/**
2 * Tiny script powering back-to-top + preloader.
3 *
4 * No dependencies. Loaded only when at least one feature is enabled.
5 *
6 * @package Inspiro
7 * @since   2.2.0
8 */
9( function () {
10	'use strict';
11
12	function initBackToTop() {
13		var btn = document.getElementById( 'inspiro-back-to-top' );
14		if ( ! btn ) {
15			return;
16		}
17
18		var threshold = 300;
19		var ticking = false;
20
21		function updateVisibility() {
22			if ( window.scrollY > threshold ) {
23				btn.classList.add( 'is-visible' );
24			} else {
25				btn.classList.remove( 'is-visible' );
26			}
27			ticking = false;
28		}
29
30		window.addEventListener( 'scroll', function () {
31			if ( ! ticking ) {
32				window.requestAnimationFrame( updateVisibility );
33				ticking = true;
34			}
35		}, { passive: true } );
36
37		btn.addEventListener( 'click', function ( e ) {
38			e.preventDefault();
39			var prefersReduced = window.matchMedia && window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches;
40			window.scrollTo( {
41				top: 0,
42				behavior: prefersReduced ? 'auto' : 'smooth'
43			} );
44		} );
45
46		updateVisibility();
47	}
48
49	function initPreloader() {
50		var preloader = document.getElementById( 'inspiro-preloader' );
51		if ( ! preloader ) {
52			return;
53		}
54
55		function hide() {
56			preloader.classList.add( 'is-hidden' );
57			window.setTimeout( function () {
58				if ( preloader.parentNode ) {
59					preloader.parentNode.removeChild( preloader );
60				}
61			}, 500 );
62		}
63
64		// Fallback in case 'load' fired before script ran.
65		if ( document.readyState === 'complete' ) {
66			hide();
67		} else {
68			window.addEventListener( 'load', hide );
69			// Safety net: never leave the preloader on top for more than 8s.
70			window.setTimeout( hide, 8000 );
71		}
72	}
73
74	if ( document.readyState === 'loading' ) {
75		document.addEventListener( 'DOMContentLoaded', function () {
76			initBackToTop();
77			initPreloader();
78		} );
79	} else {
80		initBackToTop();
81		initPreloader();
82	}
83}() );

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.