PageSourceSearch

https://www.campco.com/scripts/usn_studio/application.js

js campco.com collected 2026-10-08 08:52:26 UTC 14,318 bytes, 423 lines download raw bytes

1	
2	// DETECT DEVICE
3	$(window).bind('load resize', function() {
4
5	    // BROWSER CLASS
6		if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
7			$("body").addClass("browser-safari");
8		}
9	    if (navigator.userAgent.match(/iP(hone|od|ad)/i)) {
10			$("body").removeClass("browser-safari");
11	        jQuery('body').addClass('browser-ios');
12		}
13	    // ADD PADDING TO TOP NAV IF CTA PRESENT ON LARGE SCREENS
14	    var ctaWidth = $('nav.cta-links').outerWidth();
15	    $('nav.secondary').css('padding-right', ctaWidth + 30);
16	    var ctaWidth = $('html[dir="rtl"] nav.cta-links').outerWidth();
17	    $('nav.secondary').css('padding-left', ctaWidth + 0);
18
19	});
20
21	// FIX PARALLAX 
22	// IE 11 background-attachment:fixed will jitter on scroll if this is missing
23	jQuery(function() {
24	    if (navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) {
25	        $('body').on("mousewheel", function() {
26	            event.preventDefault();
27	            var wd = event.wheelDelta;
28	            var csp = window.pageYOffset;
29	            window.scrollTo(0, csp - wd);
30	        });
31	    }
32	});
33
34	// ADD CLASS TO HTML ELEMENT WHEN THE MOBILE/BURGER NAVIGATION IS PRESENT
35	(function($) {
36	    var $window = $(window),
37	        $html = $('html');
38
39	    function resize() {
40	        if ($window.width() < 992) {
41	            return $html.addClass('mobile-width');
42	        }
43	        $html.removeClass('mobile-width');
44	    }
45	    $window
46	        .resize(resize)
47	        .trigger('load resize');
48	})(jQuery);
49
50	// IMPROVE SCROLL PERFORMANCE FOR
51	// ANIMATION &
52	// HEADER HIDE/REVEAL
53	function debounce(func, wait, immediate) {
54	    var timeout;
55	    return function() {
56	        var context = this,
57	            args = arguments;
58	        var later = function() {
59	            timeout = null;
60	            if (!immediate) func.apply(context, args);
61	        };
62	        var callNow = immediate && !timeout;
63	        clearTimeout(timeout);
64	        timeout = setTimeout(later, wait);
65	        if (callNow) func.apply(context, args);
66	    };
67	};
68	var myEfficientScroll = debounce(function() {
69	    // TRIGGER ANIMATIONS
70	    // http://www.oxygenna.com/tutorials/scroll-animations-using-waypoints-js-animate-css
71	    function onScrollInit(items, trigger) {
72
73	        items.each(function() {
74	            var osElement = $(this),
75	                osAnimationClass = osElement.attr('data-os-animation'),
76	                osAnimationDelay = osElement.attr('data-os-animation-delay');
77
78	            osElement.css({
79	                '-webkit-animation-delay': osAnimationDelay,
80	                '-moz-animation-delay': osAnimationDelay,
81	                '-ms-animation-delay': osAnimationDelay,
82	                'animation-delay': osAnimationDelay
83	            });
84
85	            var osTrigger = (trigger) ? trigger : osElement;
86
87	            osTrigger.waypoint(function() {
88					osElement.addClass('animated').addClass(osAnimationClass);
89	            }, {
90	                //triggerOnce: true,
91	                offset: '95%'
92	            });
93	        });
94
95	    }
96	    onScrollInit($('.os-animation'));
97
98	}, 250);
99	window.addEventListener('load', myEfficientScroll);
100
101	$(document).ready(function() {
102
103	    cookiePolicy();
104
105	    $(".umbraco-ajax-form form").preventDoubleSubmission();
106
107	    // LAZYSIZES PRELOAD
108	    $('img.lazyload').addClass('lazypreload');
109
110	    // Main Navigation
111	    // $(".navigation nav.main ul li.active").addClass("mobile-open-child");
112	    $(".navigation nav.main ul li span").click(function() {
113	        if ($(".navigation nav.main ul li span").length) {
114	            $(this).parent().toggleClass("open-child");
115	            $(this).parent().siblings().removeClass("open-child");
116	            $(this).parent().toggleClass("open-child_mobile");
117	            $(this).parent().siblings().removeClass("open-child_mobile");
118	        } else {
119	            $(this).parent().toggleClass("open-child");
120	            $(this).parent().toggleClass("open-child_mobile");
121	        }
122		});
123		$(".navigation nav.main ul li.has-child.active").addClass("open-child_mobile");
124	    $("html").click(function() {
125	        $(".navigation nav.main ul li.open-child").removeClass("open-child");
126	    });
127	    $(".navigation nav.main ul li span, header a.expand").click(function(e) {
128	        e.stopPropagation();
129	    });
130
131	    // EXPAND MOBILE NAVIVAGTION  
132	    $("header#site-header a.expand").click(function() {
133	        if ($(".navigation .reveal").length) {
134	            $("header#site-header a.expand").toggleClass('active');
135	            $("html").toggleClass('reveal-out');
136	        } else {
137	            $("header#site-header a.expand").toggleClass('active');
138	            $("html").toggleClass('reveal-out');
139	        }
140	    });
141
142	    // EXPAND Anchor Mobile Navigation  
143	    $(".anchors-component .expand").click(function() {
144	        if ($(".anchors-component nav").length) {
145	            $(".anchors-component .expand").toggleClass('anchor-active');
146	            $(".anchors-component nav").toggleClass('open-mobile');
147	        } else {
148	            $(".anchors-component .expand").toggleClass('anchor-active');
149	            $(".anchors-component nav").toggleClass('open-mobile');
150	        }
151	    });
152
153	    // EXPAND HEADER SEARCH 
154	    $("header#site-header .site-search a.expand-search").click(function() {
155	        if ($("header#site-header .site-search").length) {
156	            $("header#site-header .site-search").toggleClass('open-search');
157	            $("header#site-header .site-search .form-control").focus();
158	        } else {
159	            $("header#site-header .site-search").toggleClass('open-search');
160	        }
161	    });
162	    $("html").click(function() {
163	        $("header#site-header .site-search").removeClass("open-search");
164	    });
165	    $("header#site-header .site-search").click(function(e) {
166	        e.stopPropagation();
167	    });
168
169		//RTL for Slick
170		function rtl_slick(){
171			if(jQuery("html").is('[dir="rtl"]')) {
172			   return true;
173			} else {
174			   return false;
175		}}
176
177	    // BANNER
178	    // PLAYS VIDEO IN BANNER
179	    $('.banner-component .slides').on('init', function(ev, el) {
180	        $('video').each(function() {
181	            this.play();
182	        });
183	    });
184		// ALL CAROUSELS
185	    $(".component:not(.banner-component) .slides, footer#site-footer .slides").slick({
186			rtl: rtl_slick(),
187	        infinite: true,
188	        speed: 600,
189			adaptiveHeight: true,
190	        prevArrow: '<div class="slick-prev"><i class="icon usn_ion-ios-arrow-back"></i>',
191	        nextArrow: '<div class="slick-next"><i class="icon usn_ion-ios-arrow-forward"></i>'
192	    });
193	    $(".banner-component .slides, .swp .slides").slick({
194			rtl: rtl_slick(),
195	        infinite: true,
196	        speed: 600,
197	        fade: true,
198			adaptiveHeight: true,
199	        prevArrow: '<div class="slick-prev"><i class="icon usn_ion-ios-arrow-back"></i>',
200	        nextArrow: '<div class="slick-next"><i class="icon usn_ion-ios-arrow-forward"></i>'
201		});
202
203	    // SCROLL PROMPT
204	    // 3 DIFFERENT VERSIONS
205	    // ACCOUNTS FOR DIFFERENT OFFSETS DEPENDING:
206	    // SCREEN WIDTH &/OR HEADER SHOWN
207	    $('html:not(.mobile-width) body:not(.no-header) .scroll-prompt').click(function() {
208	        var target;
209	        $("section").next().each(function(i, element) {
210	            target = ($(element).offset().top + 1);
211	            if (target - 10 > $(document).scrollTop()) {
212	                return false; // break
213	            }
214	        });
215	        $("html, body").animate({
216	            scrollTop: target
217	        }, 600);
218	    });
219	    $('html.mobile-width body:not(.no-header) .scroll-prompt').click(function() {
220	        var target;
221	        $("section").next().each(function(i, element) {
222	            target = ($(element).offset().top - 59);
223	            if (target - 10 > $(document).scrollTop()) {
224	                return false; // break
225	            }
226	        });
227	        $("html, body").animate({
228	            scrollTop: target
229	        }, 600);
230	    });
231	    $('html body.no-header .scroll-prompt').click(function() {
232	        var target;
233	        $("section").next().each(function(i, element) {
234	            target = ($(element).offset().top - 0);
235	            if (target - 10 > $(document).scrollTop()) {
236	                return false; // break
237	            }
238	        });
239	        $("html, body").animate({
240	            scrollTop: target
241	        }, 600);
242		});
243
244		// Anchor Navigation
245		// NEED TO FIX OFFSET FOR HEADER
246		var sections = $('section'), 
247		nav = $('.anchors-component'), 
248		anchor_nav_height = $('.anchors-component').outerHeight()
249		nav_height = $('header#site-header').outerHeight();
250		nav_heightShort = $('header#site-header').outerHeight() / 2;
251		$(window).on('scroll', function () {
252			var cur_pos = $(this).scrollTop();
253			sections.each(function() {
254
255			var top = $(this).offset().top - anchor_nav_height,
256				bottom = top + $(this).outerHeight();
257
258			if (cur_pos >= top && cur_pos <= bottom) {
259				nav.find('a').removeClass('active');
260				sections.removeClass('active');
261				
262				$(this).addClass('active');
263					nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active');
264				}
265			});
266		});
267		nav.find('a').on('click', function () {
268			var $el = $(this), 
269			href = $(this).attr('href');
270			$(".anchors-component .expand").removeClass('anchor-active');
271			$(".anchors-component nav").removeClass('open-mobile');
272				$('html, body').animate({
273					scrollTop: $(href).offset().top - anchor_nav_height
274				}, 500);
275			return false;
276		});
277
278	});
279
280	// LIGHTBOX
281	$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
282	    event.preventDefault();
283	    $(this).ekkoLightbox();
284	});
285
286	// HEADER SCROLLING
287	var didScroll;
288	var lastScrollTop = 0;
289	var delta = 60;
290	var navbarHeight = $('header').outerHeight();
291
292	// FIXED HEADER
293	$(window).scroll(function(event) {
294	    didScroll = true;
295	    var scroll = $(window).scrollTop();
296	    if (scroll >= 60) {
297	        $("html").removeClass("reached-top");
298	    } else {
299	        $("html").addClass("reached-top").removeClass("nav-down").removeClass("nav-up");
300	    }
301	});
302	setInterval(function() {
303	    if (didScroll) {
304	        hasScrolled();
305	        didScroll = false;
306	    }
307	}, 5);
308
309	function hasScrolled() {
310	    var st = $(this).scrollTop();
311	    // Make sure they scroll more than delta
312	    if (Math.abs(lastScrollTop - st) <= delta)
313	        return;
314	    if (st > lastScrollTop && st > navbarHeight) {
315	        // Scroll Down
316	        $('html').removeClass('nav-down').addClass('nav-up');
317	    } else {
318	        // Scroll Up
319	        $('html').addClass('nav-down').removeClass('nav-up');
320	    }
321	    lastScrollTop = st;
322	}
323
324	// COOKIE NOTICE FUNCTION
325	function cookiePolicy() {
326        var cookiePanel = $('.usn-notification'),
327	        cookieName = "cookieNotice";
328
329	    checkCookie();
330
331	    $('.accept-cookies').on('click', function(e) {
332	        e.preventDefault();
333	        setCookie();
334	    });
335
336	    // Get cookie
337	    function getCookie(c_name) {
338
339	        var i, x, y, ARRcookies = document.cookie.split(";");
340	        for (i = 0; i < ARRcookies.length; i++) {
341	            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
342	            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
343	            x = x.replace(/^\s+|\s+$/g, "");
344	            if (x == c_name) {
345	                return unescape(y);
346	            }
347	        }
348
349	    }
350
351	    // Set cookie
352	    function setCookie() {
353
354	        var exdate = new Date();
355	        exdate.setDate(exdate.getDate() + exdays);
356	        var c_value = "accepted" + ((exdays == null) ? "" : "; path=/; expires=" + exdate.toUTCString());
357	        document.cookie = cookieName + " =" + c_value;
358	        cookiePanel.addClass("closed");
359	        cookiePanel.removeClass("open");
360	    }
361
362	    // Check cookie
363	    function checkCookie() {
364
365	        var username = getCookie(cookieName);
366	        if (username != null && username != "") {
367	            cookiePanel.addClass("closed");
368	            cookiePanel.removeClass("open");
369	        } else {
370	            cookiePanel.addClass("open");
371	            cookiePanel.removeClass("closed");
372	        }
373
374	    }
375
376	};
377
378	// jQuery plugin to prevent double submission of forms
379	jQuery.fn.preventDoubleSubmission = function() {
380
381	    $(this).on('submit', function(e) {
382
383	        e.preventDefault();
384
385	        var $form = $(this);
386
387	        if ($form.data('submitted') === true) {
388	            // Previously submitted - don't submit again
389	        } else {
390	            if ($form.valid()) {
391	                // Mark it so that the next submit can be ignored
392	                $form.data('submitted', true);
393
394	                /*show loader*/
395	                $form.find(".ajax-loading").show();
396
397	                // Make ajax call form submission
398	                $.ajax({
399	                    url: $form.attr('action'),
400	                    type: 'POST',
401	                    cache: false,
402	                    data: $form.serialize(),
403	                    success: function(result) {
404
405	                        var thankYouMessage = $form.find('input[name="umbraco_submit_message"]').val();
406
407	                        $form.find('.form-container').html("<div class='umbraco-forms-submitmessage alert alert-success' role='alert'>" + thankYouMessage + "</div>");
408	                        $form.find(".ajax-loading").hide();
409	                    },
410	                    error: function() {
411	                        /*hide loader*/
412	                        $form.find(".ajax-loading").hide();
413	                        $form.find('.UmbracoFormMessage').html("<div class='alert alert-danger alert-dismissible text-center'>An error occured. Please try again.</div>");
414	                    }
415	                });
416	            }
417	        }
418
419	    });
420
421	    // Keep chainability
422	    return this;
423	};

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.