PageSourceSearch

https://www.onpointcu.com/wp-content/themes/onpointcu-theme/js/lib/stickyNav.js?ver=1759959686

js onpointcu.com collected 2026-09-24 09:14:06 UTC 4,574 bytes, 167 lines download raw bytes

1(function($) {
2	$(document).ready(function() {
3		//
4		// Sticky Nav Logic
5		//
6		stickyNav = {
7			$nav: $('#js-sticky_nav'),
8			$more: $('#js-sticky_nav_more'),
9			$moreText: $('#js-sticky_nav_more_text'),
10			$links: $('.js-sticky_nav_link'),
11			$moreStyle: $(),
12			stickyWaypoint: false,
13			curWaypoints: [],
14			setCur: function(el) {
15				var that = this;
16				that.$links.removeClass('current');
17				$(el).addClass('current');
18			},
19			unsetCur: function() {
20				var that = this;
21				that.$links.removeClass('current');
22			},
23			initCurrentIndicator: function() {
24				var that = this,
25					linksLength = that.$links.length;
26				for ( var i = 0; i < linksLength; i++ ) {
27					var $curLink = $(that.$links[i]),
28							$curSection = $(DOMPurify.sanitize($curLink.attr('href')));
29					if ( $curSection.length > 0 ) {
30						$curSection.data('sectionindex', i);
31						(function(link, section) {
32							// Waypoint for scroll down (entering section)
33							that.curWaypoints.push(new Waypoint({
34								element: section[0],
35								offset: '100px', 
36								handler: function(direction) {
37									if (direction === 'down') {
38										that.setCur(link);
39										//console.log('setting current link (down)', link);
40									}
41								}
42							}));
43							
44							// Waypoint for scroll up (exiting section)
45							that.curWaypoints.push(new Waypoint({
46								element: section[0],
47								offset: '0px', 
48								handler: function(direction) {
49									if (direction === 'up') {
50										that.setCur(link);
51										//console.log('unsetting current link (up)');
52									}
53								}
54							}));
55						})($curLink, $curSection);
56					}
57				}
58			},
59			setMoreDisplay: function() {
60				var that = this,
61						linksLength = that.$links.length,
62						totalLinkWidth = 0,
63						moreCss = '';
64				for ( var i = 0; i < linksLength; i++ ) {
65					totalLinkWidth += $(that.$links[i]).outerWidth();
66				}
67				totalLinkWidth += 60; // add the site padding
68				that.$moreStyle = pixStyle.create(that.$moreStyle, 'js-sticky_nav_more_style');
69				that.$moreStyle.text(moreCss);
70			},
71			initSticky: function() {
72				var that = this,
73						$parentRow = that.$nav.parents('.co-flex_row'),
74						el = that.$nav[0];
75				if ( $parentRow ) {
76					el = $parentRow[0];
77				}
78				that.stickyWaypoint = new Waypoint.Sticky({
79					element: el
80				});
81			},
82			toggle: function() {
83				var that = this;
84				if ( that.$nav.hasClass('closed') ) {
85					that.open();
86				} else {
87					that.close();
88				}
89			},
90			open: function() {
91				var that = this;
92				that.$nav.slideDown(300, function() {
93					that.$nav.removeClass('closed');
94				});
95				that.$moreText.html('Page Menu <span class="co-sticky_nav--more_text_icon">–</span>');
96			},
97			close: function() {
98				var that = this;
99				that.$nav.slideUp(300, function() {
100					that.$nav.addClass('closed');
101				});
102				that.$moreText.html('Page Menu <span class="co-sticky_nav--more_text_icon">+</span>');
103			},
104			init: function() {
105				var that = this;
106				if ( that.$nav.length > 0 ) {
107					that.$more.click(function() {
108						that.toggle();
109					});
110					that.initCurrentIndicator();
111					that.initSticky();
112					that.setMoreDisplay();
113					setTimeout(function() {
114						// super hacky, but we need to run this
115						// again once the fonts have loaded.
116						that.setMoreDisplay();
117					}, 5000);
118
119					// that.$links.click(function() {
120					// 	setTimeout(function() {
121					// 		$('.co-sticky_nav--link').removeClass('current');
122					// 	}, 500);
123					// });
124					
125					// Open the sticky nav only in mobile
126					if (layoutView == 'small'){
127						that.open();
128						that.$nav.addClass('open-mob-init');
129						
130						// Close the sticky nav when scrolling past the nav element
131						var $stickyWrapper = $('.sticky-wrapper');
132						if ($stickyWrapper.length > 0) {
133							var sticky_nav_position = $stickyWrapper.offset().top;
134							var close_flag = true;
135							
136							$(window).on('scroll', function() {
137								if (close_flag) {
138									var y_scroll_pos = window.pageYOffset;
139									if (y_scroll_pos > sticky_nav_position) {
140										close_flag = false;
141										that.close();
142									}
143								}
144							});
145						}
146					}
147					// $( window ).resize(function() {	
148					// 	if ($( window ).width() < 768 ){
149					// 		that.open();
150					// 	}else{
151					// 		that.close();
152					// 	}
153					// });
154				}
155				var $nav_link = $(".co-sticky_nav--link");
156				if ($nav_link.length > 0 ){
157					this.$nav.click(function(){
158						if ($( window ).width() < 1100){
159							that.toggle();
160						}
161					})
162				}
163			}
164		};
165		stickyNav.init();
166	});
167})(jQuery);

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.