1 2/* 3*** Alert Modal Functionality 4*/ 5 6// Use to throttle firing of a function, prevents functions from potentially 7// firing hundreds or thousands of times in rapid succession 8var _ = {}; 9 10_.throttle = function(func, wait, options) { 11 var context, args, result; 12 var timeout = null; 13 var previous = 0; 14 if (!options) options = {}; 15 var later = function() { 16 previous = options.leading === false ? 0 : new Date().getTime(); 17 timeout = null; 18 result = func.apply(context, args); 19 if (!timeout) context = args = null; 20 }; 21 return function() { 22 var now = new Date().getTime(); 23 if (!previous && options.leading === false) previous = now; 24 var remaining = wait - (now - previous); 25 context = this; 26 args = arguments; 27 if (remaining <= 0 || remaining > wait) { 28 if (timeout) { 29 clearTimeout(timeout); 30 timeout = null; 31 } 32 previous = now; 33 result = func.apply(context, args); 34 if (!timeout) context = args = null; 35 } else if (!timeout && options.trailing !== false) { 36 timeout = setTimeout(later, remaining); 37 } 38 return result; 39 }; 40}; 41 42// 43var vDelay = 0; 44var vOffsetDesktop = 200; 45var vOffsetMobile = 100; 46 47document.addEventListener('invalid', function(e){ 48 $(e.target).addClass("invalid"); 49 $('html, body').animate({ 50 scrollTop: $($(".invalid")[0]).offset().top - ($(window).width() >= 992 ? vOffsetDesktop : vOffsetMobile) }, 51 vDelay 52 )}, true); 53document.addEventListener('change', function(e){ 54 $(e.target).removeClass("invalid") 55}, true); 56 57/* 58*** Detect if IE or IOS 59*/ 60$(document).ready(function() { 61 checkIfIos(); 62 /* Add class to html tag to show if IE or not */ 63 if ( isIE() ){ 64 $('html').addClass('is-ie'); 65 } else { 66 $('html').addClass('not-ie'); 67 } 68 isEdge(); 69 // $('.navbar-toggler').click(function () { 70 71 // var expanded = $('.navbar-toggler').attr('aria-expanded'); 72 73 // if (expanded == 'false') { 74 // $('html').addClass('main-menu-open'); 75 // $('html').removeClass('main-menu-closed'); 76 // } else { 77 // $('html').removeClass('main-menu-open'); 78 // $('html').addClass('main-menu-closed'); 79 // } 80 // }); 81}); 82 83function checkIfIos() { 84 //Add Modernizr test 85 Modernizr.addTest('isios', function() { 86 return navigator.userAgent.match(/(iPad|iPhone|iPod)/g); 87 }); 88 89 //usage 90 if (Modernizr.isios) { 91 // adds ios class to html 92 Modernizr.prefixed('ios'); 93 } else { 94 //adds notios class to html 95 Modernizr.prefixed('notios'); 96 } 97} 98 99/* Returns boolean if the browser is Internet Explorer*/ 100function isIE() { 101 ua = navigator.userAgent; 102 /* MSIE used to detect old browsers and Trident used to newer ones*/ 103 var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1; 104 105 return is_ie; 106} 107 108function isEdge() { 109 var htmlTag = document.getElementsByTagName("HTML")[0]; 110 if (/Edge\/\d./i.test(navigator.userAgent)){ 111 // is Microsoft Edge 112 htmlTag.classList.add("is-edge"); 113 } else { 114 htmlTag.classList.remove("is-edge"); 115 } 116} 117 118// Add Class to HTML for touch on mobile and mouse on desktop 119(function addPointerClasses() { 120 var is_touch_event = false; 121 122 function hasMouse() { 123 if(is_touch_event === false) { 124 document.documentElement.classList.add('mouse'); 125 document.body.removeEventListener('mousemove', hasMouse); 126 } 127 } 128 129 document.body.addEventListener('mousemove', hasMouse); 130 131 document.body.addEventListener('touchstart', function () { 132 is_touch_event = true; 133 }); 134 document.body.addEventListener('touchend', function () { 135 is_touch_event = false; 136 }); 137 document.body.addEventListener('click', function () { 138 if(is_touch_event) is_touch_event = false; 139 }); 140 141 function isTouchDevice() { 142 try { 143 document.createEvent('TouchEvent'); 144 return true; 145 } catch (e) { 146 return false; 147 } 148 } 149 150 if(isTouchDevice()) { 151 document.documentElement.classList.add('touch'); 152 } 153})(); 154 155 156// Custom Form Validation Bubble Replacement 157 158function replaceValidationUI( form ) { 159 // Suppress the default bubbles 160 form.addEventListener( "invalid", function( event ) { 161 event.preventDefault(); 162 }, true ); 163
164 // Support Safari, iOS Safari, and the Android browserââ¬âeach of which do not prevent 165 // form submissions by default 166 form.addEventListener( "submit", function( event ) { 167 if ( !this.checkValidity() ) { 168 event.preventDefault(); 169 } 170 }); 171 172 var submitButton = form.querySelector( "button:not([type=button]), input[type=submit]" ); 173 if (submitButton) { 174 submitButton.addEventListener( "click", function( event ) { 175 var invalidFields = form.querySelectorAll( ":invalid" ), 176 errorMessages = form.querySelectorAll( ".error-message" ), 177 parent; 178 179 // Remove any existing messages 180 for ( var i = 0; i < errorMessages.length; i++ ) { 181 errorMessages[ i ].parentNode.removeChild( errorMessages[ i ] ); 182 } 183 184 for ( var i = 0; i < invalidFields.length; i++ ) { 185 parent = invalidFields[ i ].parentNode; 186 parent.insertAdjacentHTML( "beforeend", "<div class='error-message' aria-label='Invalid Form Value Message'>" + 187 invalidFields[ i ].validationMessage + 188 "</div>" ); 189 } 190 191 // If there are errors, give focus to the first invalid field 192 if ( invalidFields.length > 0 ) { 193 invalidFields[ 0 ].focus(); 194 } 195 }); 196 } 197} 198 199// Replace the validation UI for all forms 200var forms = document.querySelectorAll( "form" ); 201for ( var i = 0; i < forms.length; i++ ) { 202 replaceValidationUI( forms[ i ] ); 203} 204 205 206// Cookies 207 208// Get and return the current DateTime 209function getTimeNow() { 210 var t = new Date(); 211 t.setTime(t.getTime); 212 return t; 213} 214 215// Search for cookie by name, if it exists, return value 216function getCookie(cname) { 217 var v = document.cookie.match('(^|;) ?' + cname + '=([^;]*)(;|$)'); 218 return v ? v[2] : null; 219} 220 221// Set/update a cookie by name, value, and hours to expiration 222function setCookie(cname, cvalue, hours) { 223 var d = new Date(); 224 d.setTime(d.getTime() + 60 * 60 * 1000 * hours); 225 document.cookie = cname + "=" + cvalue + ";path=/;expires=" + d.toUTCString(); 226 console.log(d.toUTCString()); 227} 228 229// Delete cookie by name 230function deleteCookie(cname) { 231 setCookie(cname, '', -1); 232} 233 234$(document).ready(function(){ 235 setCookie("last_page_load", getTimeNow(), 24); 236}) 237 238//deleteCookie("last_page_load"); 239 240//console.log(getCookie("last_page_load")); 241 242//console.log(document.cookie); 243//alert(document.cookie); 244//alert(document.cookie); 245 246/* 247*** MAIN MENU JS *** 248*/ 249 250// Microsite Accessible Megamenu 251$("#utility-mega-menu").accessibleMegaMenu({ 252 /* prefix for generated unique id attributes, which are required 253 to indicate aria-owns, aria-controls and aria-labelledby */ 254 uuidPrefix: "js-subnav", 255 256 /* css class used to define the megamenu styling */ 257 // menuClass: "js-nav--menu", 258 259 /* css class for a top-level navigation item in the megamenu */ 260 topNavItemClass: "js-nav--item", 261 262 /* css class for a megamenu panel */ 263 panelClass: "js-sub--nav", 264 265 /* css class for a group of items within a megamenu panel */ 266 // panelGroupClass: "js-sub-nav--group", 267 268 /* css class for the hover state */ 269 hoverClass: "hover", 270 271 /* css class for the focus state */ 272 focusClass: "focus", 273 274 /* css class for the open state */ 275 openClass: "open" 276 }); 277 278/** 279 * Show/Hide Menu On Scroll 280 */ 281 282 283function desktopMenuScrolling() { 284 var didScroll; 285 var lastScrollTop = 0; 286 var delta = 5; 287 var navbarHeight = $('.js-header-scrolling').outerHeight(); 288 var menuButton = document.getElementById('menu-toggle'); 289 var isMenuOpen = false; 290 291 // hijack content scrolling while menu is open 292 function scrollControl() { 293 if (isMenuOpen && $(window).width() <= 991) { 294 $('html, body').addClass('lock-scroll'); 295 $('#menu-outer').removeClass('collapsed'); 296 } else { 297 $('html, body').removeClass('lock-scroll'); 298 $('#menu-outer').addClass('collapsed'); 299 } 300 } 301 302 // Watch for opening/closing of menu 303 var watchMenu = new MutationObserver(function() { 304 isMenuOpen = !isMenuOpen; 305 scrollControl(); 306 }); 307 308 watchMenu.observe(menuButton, { 309 attributes: true, 310 attributeFilter: ['class'], 311 childList: false, 312 characterData: false 313 }); 314 315 $(window).on('load resize', function(){ 316 scrollControl(); 317 }); 318 319 $(window).scroll(function(event){ 320 didScroll = true; 321 }); 322 323 setInterval(function() { 324 if (didScroll) { 325 hasScrolled(); 326 didScroll = false;
327 } 328 }, 250); 329 330 function hasScrolled() { 331 var st = $(this).scrollTop(); 332 333 // Make sure they scroll more than delta 334 if(Math.abs(lastScrollTop - st) <= delta) 335 return; 336 337 // If they scrolled down and are past the navbar, add class .nav-isHidden. 338 // This is necessary so you never see what is "behind" the navbar. 339 if (st > lastScrollTop && st > navbarHeight){ 340 // Scroll Down 341 $('.js-header-scrolling').removeClass('nav-isVisible').addClass('nav-isHidden'); 342 } else { 343 // Scroll Up 344 if(st + $(window).height() < $(document).height()) { 345 $('.js-header-scrolling').removeClass('nav-isHidden').addClass('nav-isVisible'); 346 } 347 } 348 349 lastScrollTop = st; 350 } 351 352 var didScroll; 353 var lastScrollTop = 0; 354 var delta = 5; 355 var navbarHeight = $('.js-header-scrolling').outerHeight(); 356 357 $(window).scroll(function(event){ 358 didScroll = true; 359 }); 360 361 setInterval(function() { 362 if (didScroll) { 363 hasScrolled(); 364 didScroll = false; 365 } 366 }, 0); 367} 368 369function mobileMenuScrolling() { 370 /*var didScroll; 371 var lastScrollTop = 0; 372 var delta = 5; 373 var navbarHeight = $('.js-mobile-header').outerHeight(); 374 375 $(window).scroll(function(event){ 376 didScroll = true; 377 }); 378 379 setInterval(function() { 380 if (didScroll) { 381 hasScrolled(); 382 didScroll = false; 383 } 384 }, 250); 385 386 function hasScrolled() { 387 var st = $(this).scrollTop(); 388 389 // Make sure they scroll more than delta 390 if(Math.abs(lastScrollTop - st) <= delta) 391 return; 392 393 // If they scrolled down and are past the navbar, add class .nav-isHidden. 394 // This is necessary so you never see what is "behind" the navbar. 395 396 397 if (st > lastScrollTop && st > navbarHeight){ 398 // Scroll Down 399 $('.js-mobile-header').removeClass('mobile-nav-isVisible').addClass('mobile-nav-isHidden'); 400 } else { 401 // Scroll Up 402 if(st + $(window).height() < $(document).height()) { 403 $('.js-mobile-header').removeClass('mobile-nav-isHidden').addClass('mobile-nav-isVisible'); 404 } 405 } 406 407 lastScrollTop = st; 408 } 409 410 var didScroll; 411 var lastScrollTop = 0; 412 var delta = 5; 413 var navbarHeight = $('.js-mobile-header').outerHeight(); 414 415 $(window).scroll(function(event){ 416 didScroll = true; 417 }); 418 419 setInterval(function() { 420 if (didScroll) { 421 hasScrolled(); 422 didScroll = false; 423 } 424 }, 250); 425 426 function hasScrolled() { 427 var st = $(this).scrollTop(); 428 429 // Make sure they scroll more than delta 430 if(Math.abs(lastScrollTop - st) <= delta) 431 return; 432 433 // If they scrolled down and are past the navbar, add class .nav-isHidden. 434 // This is necessary so you never see what is "behind" the navbar. 435 if (st > lastScrollTop && st > navbarHeight){ 436 // Scroll Down 437 $('.js-mobile-header').removeClass('mobile-nav-isVisible').addClass('mobile-nav-isHidden'); 438 } else { 439 // Scroll Up 440 if(st + $(window).height() < $(document).height()) { 441 $('.js-mobile-header').removeClass('mobile-nav-isHidden').addClass('mobile-nav-isVisible'); 442 } 443 } 444 445 lastScrollTop = st; 446 }*/ 447} 448 449// Initialize 450desktopMenuScrolling(); 451 452// If Main Nav has more items than 6 change text transform from uppercase to normal to accomodate more nav items in the space 453 454function mainNavItemsMore() { 455 var mainNavUlChildren = $("#header #main-nav").children(); 456 if (mainNavUlChildren.length > 7) { 457 $("body").addClass("js-more-nav-items"); 458 } else { 459 $("body").removeClass("js-more-nav-items"); 460 } 461} 462 463mainNavItemsMore();
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.