PageSourceSearch

https://www.lesker.com/js/navbar-header.js?v=8

js lesker.com collected 2026-10-02 04:42:13 UTC 4,514 bytes, 152 lines download raw bytes

1// hc-offcanvas-nav and hide/show header on scroll scripts
2$(document).ready(function () {
3	var isNavOpen = false;
4	var $html = $('html');
5	var $headerNav = $('.header-main-wrapper');
6	var headerNavHeight = $headerNav.outerHeight();
7	var $headerMainSearch = $('#header-main-search');
8	var currentScrollPosition;
9	var previousScrollPosition;
10
11	var nav = $('#sidebar-nav').hcOffcanvasNav({
12		maxWidth: false,
13		customToggle: '#hamburger',
14		// pushContent: '.header-main-wrapper, #container > #container2, .footer-main-wrapper',
15		levelTitles: true,
16		closeOnClick: false,
17		levelSpacing: 0
18	}).on('closeNav', function () {
19		nav.close();
20	});
21
22	// Add isOpen function to data object so it is accessible by script in leskerwidgets.cfm
23	$('#sidebar-nav').data({isOpen: nav.isOpen});
24
25	// TODO Consider moving to lesker-utilities.js
26	function isIE() {
27		var ua = window.navigator.userAgent; // Check the userAgent property of the window.navigator object
28    	var msie = ua.indexOf('MSIE '); // IE 10 or older
29   		var trident = ua.indexOf('Trident/');
30
31    	return (msie > 0 || trident > 0);
32	}
33
34	nav.update({ navTitle: LOGIN_TEXT });
35
36	$.ajax({
37		url: "/modules/header-footer/sidebar-nav.txt?u=6.1",
38		type: "GET",
39		dataType: "html",
40		localCache: true,
41		cacheTTL: CACHE_TTL, //time in hours
42		cacheKey: "lesker_sidebar_nav",
43		success: function (response) {
44			$("#sidebar-navigation-items").replaceWith(response);
45			nav.update(true);
46			// Init hamburger menu search typeahead and add .nav-search handling in leskersitesearch.js
47			// Add .hc-nav-trigger and .nav-container function handlers in leskerwidgets.cfm
48			nav.trigger('navHasLoaded');
49		}
50	});
51
52	$('.js-toggle-header-mobile-search').on('click', function () {
53		if ($(this).attr('data-toggle') === 'closed') {
54			$(this).attr('data-toggle', 'open');
55			$headerMainSearch.css({
56				'height': '40px',
57				'border-bottom': '2px solid #039'
58			});
59			setTimeout(function () {
60				$headerMainSearch.css({
61					'overflow': 'visible'
62				});
63			}, 200);
64			$('.header-search').css('height', '40px');
65		} else {
66			$(this).attr('data-toggle', 'closed');
67			$headerMainSearch.css({
68				'height': '0px',
69				'overflow': 'hidden'
70			});
71			setTimeout(function () {
72				$headerMainSearch.css({
73					'border-bottom': '0'
74				});
75			}, 200);
76		}
77	});
78
79	$('.hc-nav-trigger').on('click', function () {
80		// Fires quicker than nav.isOpen(). Needed to prevent hide/show on scroll during menu open/close.
81		isNavOpen = true;
82
83		// Set transition for nav open which may have been set to none by hideShowNavOnScroll if scroll near top of page
84		$headerNav.css('transition', 'transform 400ms');
85
86		// Not needed if not pushing page content
87		// if ($html.css('overflow-x') !== 'hidden') {
88		// 	$html.css('overflow-x', 'hidden');
89		// }
90	});
91
92	// Hack needed to trigger hover event on iOS Safari for Vacuum Products drop down
93	$('.header-dropdown-container.vacuum-products').on('click', function() {});
94
95	// On nav close, set header to sticky
96	$('.nav-container').on('transitionend', function () {
97		if (!nav.isOpen()) {
98			isNavOpen = false;
99		}
100	});
101
102	function hideShowNavOnScroll() {
103		if (!isNavOpen) {
104			currentScrollPosition = window.pageYOffset;
105
106			// Scroll Up
107			if (currentScrollPosition <= headerNavHeight) {
108				if (previousScrollPosition > currentScrollPosition) {
109					$headerNav.css({
110						'transform': 'translateY(0)',
111						'transition': 'none'
112					});
113				} else {
114					$headerNav.css({
115						'transform': 'translateY(0)',
116						'transition': 'transform 400ms'
117					});
118				}
119			} else if (previousScrollPosition > currentScrollPosition) {
120				if ($headerNav.css('transition') === 'none 0s ease 0s') {
121					$headerNav.css({
122						'transform': 'translateY(0)',
123						'transition': 'transform 400ms'
124					});
125				} else {
126					$headerNav.css('transform', 'translateY(0)');
127				}
128			}
129			// Scroll down
130			else {
131				if ($headerNav.css('transition') === 'none 0s ease 0s') {
132					$headerNav.css({
133						'transform': 'translateY(0)',
134						'transition': 'transform 400ms'
135					});
136				} else {
137					$headerNav.css('transform', 'translateY(-' + headerNavHeight + 'px)');
138				}
139			}
140
141			previousScrollPosition = currentScrollPosition;
142		}
143	}
144
145	if (STICKY_TOP_NAV) {
146		// if (IS_RESPONSIVE) {
147		// 	$(window).on('scroll', hideShowNavOnScroll);
148		// }
149	} else {
150		$headerNav.css('position', 'absolute');
151	}
152});

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.