1//------------------------------------------------------------------------------ 2// Prevent Immediate Page Jumps -- Calls a Scroll After 3//------------------------------------------------------------------------------ 4preventAnchorScroll(); 5 6function preventAnchorScroll() { 7 var scrollToTop = function () { 8 $(window).scrollTop(0); 9 }; 10 if (window.location.hash) { 11 // handler is executed at most once 12 $(window).one("scroll", scrollToTop); 13 } 14 15 // make sure to release scroll 1 second after document readiness 16 // to avoid negative UX 17 $(function () { 18 setTimeout(function () { 19 $(window).off("scroll", scrollToTop); 20 }, 1000); 21 }); 22} 23 24//------------------------------------------------------------------------------ 25// Jquery 26//------------------------------------------------------------------------------ 27$(document).ready(function () { 28 // ---------------------------------------------------------------- // 29 // ----- General Variables ----- // 30 const body = $("body"); 31 const html = $("html"); 32 const header = $("header"); 33 const mobileSize = 800; 34 35 // ---------------------------------------------------------------- // 36 // ----- Function to Check what is in Viewport in Scroll ----- // 37 $.fn.isOnScreen = function () { 38 var win = $(window); 39 40 var viewport = { 41 top: win.scrollTop(), 42 left: win.scrollLeft(), 43 }; 44 viewport.right = viewport.left + win.width(); 45 viewport.bottom = viewport.top + win.height(); 46 47 var bounds = this.offset(); 48 bounds.right = bounds.left + this.outerWidth(); 49 bounds.bottom = bounds.top + this.outerHeight(); 50 51 return !( 52 viewport.right < bounds.left || 53 viewport.left > bounds.right || 54 viewport.bottom < bounds.top || 55 viewport.top > bounds.bottom 56 ); 57 }; 58 59 // ---------------------------------------------------------------- // 60 // ----- Header ----- // 61 62 // Menu Toggle Function ///////////////////////////////////// 63 const mobileIcon = $("header .icon--mobile"); 64 const mobileOverlay = $("header[nav--mobile='overlay'] .nav--mobile"); 65 const mobileSidebar = $("header[nav--mobile='sidebar'] .nav--mobile"); 66 const mobileMenu = $("ul#menu-main-nav-1"); 67 68 function closeMobile() { 69 mobileIcon.addClass("closed"); 70 body.removeClass("nav--mobile-on"); 71 header.removeClass("mobile-active"); 72 73 header.find(".dropdown.open .sub-menu").css("display", "none"); 74 header.find(".open").removeClass("open"); 75 header.find(".menubutton[aria-expanded=true]").attr("aria-expanded", false); 76 77 // Overlay Mobile Nav // 78 mobileOverlay.fadeOut(100); 79 // Sidebar Mobile Nav // 80 mobileSidebar.removeClass("nav--mobile-sidebar-on"); 81 } 82 83 mobileIcon.click(function () { 84 if (!$(this).hasClass("closed")) { 85 closeMobile(); 86 $(this).text("Menu"); 87 } else { 88 $(this).removeClass("closed"); 89 $(this).text("Close"); 90 body.addClass("nav--mobile-on"); 91 header.addClass("mobile-active"); 92 93 // Overlay Mobile Nav // 94 mobileOverlay.fadeIn(100).css("display", "flex"); 95 // Sidebar Mobile Nav // 96 mobileSidebar.addClass("nav--mobile-sidebar-on"); 97 } 98 }); 99 $(window).resize(function () { 100 if ($(window).width() > mobileSize) { 101 closeMobile(); 102 } 103 }); 104 105 // Mobile Nav Height 106 // function header_adjust_mobile_nav_height() { 107 // var mobileNav = $('header .nav--mobile'); 108 // var headerItemsHeight = 0; 109 // if ($('.header--wrapper .nav--top-container').length) headerItemsHeight += $('.header--wrapper .nav--top-container').outerHeight(); 110 // if ($('.header--wrapper header .column--container').length) headerItemsHeight += $('.header--wrapper header .column--container').outerHeight(); 111 // mobileNav.css('height', 'calc(100vh - ' + headerItemsHeight + 'px)'); 112 // } 113 // header_adjust_mobile_nav_height(); 114 // $(window).resize(function () { 115 // if ($(window).width() <= mobileSize) { 116 // header_adjust_mobile_nav_height(); 117 // } 118 // }); 119 120 // Search Bar Header Toggle Function /////////////////////////////// 121 var searchButton = $("button.icon--search"); 122 var searchForm = $("#search--form.search--dropdown"); 123 if (searchButton && searchForm) { 124 searchButton.click(function () { 125 // Height of Search Padding 126 search_adjust_header_height(); 127 // Open Search 128 searchButton.toggleClass("active"); 129 searchForm.toggleClass("search--form-open"); 130 if (searchForm.hasClass("search--form-open")) { 131 searchForm.removeAttr("inert"); 132 } else { 133 searchForm.attr("inert", "true"); 134 } 135 body.toggleClass("search--dropdown-on"); 136 }); 137 } 138 // Adjust Header Search on Resize 139 // Hide Header Search in Mobile View 140 $(window).resize(function () { 141 search_adjust_header_height(); 142 if ($(window).width() <= mobileSize) { 143 searchButton.removeClass("active"); 144 searchForm.removeClass("search--form-open").attr("inert", "true"); 145 body.removeClass("search--dropdown-on"); 146 } 147 }); 148 function search_adjust_header_height() { 149 var headerItemsHeight = 0; 150 if ($(".header--wrapper #banner").length) 151 headerItemsHeight += $(".header--wrapper #banner").outerHeight(); 152 if ($(".header--wrapper .nav--top-container").length) 153 headerItemsHeight += $( 154 ".header--wrapper .nav--top-container" 155 ).outerHeight(); 156 if ($(".header--wrapper header").length) 157 headerItemsHeight += $(".header--wrapper header").outerHeight(); 158 searchForm.css("padding-top", headerItemsHeight + "px"); 159 } 160 161 // ---------------------------------------------------------------- // 162 // ----- Easter Egg Links ----- // 163 const easterEgg = $('.easter-eggs span'); 164 const easterEggCount = easterEgg.length ?? 0; 165 if( easterEggCount > 0 ) { 166 $(document).on("click", 'ul#menu-main-nav svg', function(e) { 167 var easterEggRandom = Math.floor(Math.random() * easterEggCount); 168 var easterEggRandomLink = easterEgg[easterEggRandom].getAttribute('link'); 169 // Leave to Link 170 // window.location.href = easterEggRandomLink; 171 var newWindow = window.open(easterEggRandomLink, '_blank'); 172 if (newWindow) { 173 // Browser has allowed it to be opened 174 newWindow.focus(); 175 } else { 176 // Browser has blocked it 177 alert('Please allow popups for this website'); 178 } 179 }); 180 } 181 182 // ---------------------------------------------------------------- // 183 // ----- General Page ----- // 184 185 // Hover/Click Block //////////////////////// 186 const hcBlock = $(".module--hover-click-block"); 187 // Hover Event -- Only in Desktop 188 hcBlock.find(".hc--label").mouseenter(function () { 189 const element = $(this); 190 if ( 191 element.parents(".module--hover-click-block").data("switch") === 192 "hover" && 193 $(window).width() > 576 194 ) { 195 hover_click_block(element); 196 } 197 }); 198 // Click Event -- Required in Mobile 199 hcBlock.find(".hc--label").click(function (e) { 200 const element = $(this); 201 if ( 202 element.parents(".module--hover-click-block").data("switch") === 203 "click" || 204 $(window).width() <= 576 205 ) { 206 e.preventDefault(); 207 hover_click_block(element); 208 } 209 }); 210 211 // Hover/Click Function 212 function hover_click_block(element) { 213 const parent = element.parents(".module--hover-click-block"); 214 const item = parent.find( 215 ".hc--item[data-item=" + element.data("item") + "]" 216 ); 217 if (parent.hasClass("live-color") && element.data("color")) { 218 parent.css("background-color", element.data("color")); 219 } else { 220 parent.css("background-color", ""); 221 } 222 223 if (!item.hasClass("active")) { 224 item.siblings(".active").removeClass("active").attr("aria-hidden", true); 225 item.addClass("active").attr("aria-hidden", false); 226 } 227 element.siblings(".active").removeClass("active"); 228 element.addClass("active"); 229 } 230 ////////////////////////////////////////////////// 231 232 // Accordion Block /////////////////////////////// 233 const accordionModules = $(".module--accordion-block"); 234 235 // Function: Calculate Accordion Height & Load In Transition when Finished 236 function accordion_calculate_height(accordionModules) { 237 // Each Module 238 accordionModules.each(function (e) { 239 const accordionItems = $(this).find(".accordion-item"); 240 const accordionItemContainer = accordionItems.parent(); 241 // Each Item 242 accordionItems 243 .each(function (e) { 244 const accordionContent = $(this).find(".content"); 245 const accordionHeight = accordionContent.outerHeight(); 246 accordionContent.css( 247 "height", 248 "calc(" + accordionHeight + "px + 2rem)" 249 ); 250 }) 251 .promise() 252 .done(function () { 253 accordionItemContainer.addClass("accordion--load-transition"); 254 }); 255 }); 256 } 257 258 // Calculate Height on Load & Resize 259 if (accordionModules.length) { 260 accordion_calculate_height(accordionModules); 261 } 262 // Resize 263 $(window).resize(function () { 264 // Reset Modules - Each 265 accordionModules.each(function (e) { 266 // var accordionItemContainer = $(this).find('.accordion-items'); 267 const accordionItems = $(this).find(".accordion-item"); 268 // accordionItemContainer.removeClass('accordion--load-transition'); 269 accordionItems.each(function (e) { 270 $(this).find(".content").css("height", ""); 271 $(this).removeClass("closed"); 272 }); 273 }); 274 accordion_calculate_height(accordionModules); 275 }); 276 277 // Accordion Click Toggle Function 278 $(".module--accordion-block .accordion-item .label").click(function () { 279 const item = $(this).closest(".accordion-item"); 280 const content = item.find(".content"); 281 const isInert = content.attr("inert") === "" ? true : false;
282 283 // Toggle active class 284 item.toggleClass("closed").find("svg").toggleClass("active"); 285 286 // Update aria values 287 $(this).attr("aria-expanded", $(this).attr("aria-expanded") === "false"); 288 isInert ? content.removeAttr("inert") : content.attr("inert", ""); 289 }); 290 291 // ------------------------------------------------ // 292 293 // Video Image Cover 294 $(".module--video .module--image-object, .module--video .play-icon").click( 295 function () { 296 if (!$(this).parent(".fancy--vid-wrapper").length) { 297 const videoWrapper = $(this).siblings( 298 ".module--video-object:not(.video-loop)" 299 ); 300 const video = videoWrapper.find("video"); 301 const embed = $(this).siblings(".embed-wrapper"); 302 if (video.length) { 303 video.trigger("play"); 304 } else if (embed.length) { 305 const iframe = embed.find("iframe"); 306 iframe.attr("src", iframe.attr("src") + "&autoplay=1&muted=1"); 307 } 308 $(this) 309 .add($(this).siblings().not([videoWrapper[0], embed[0]])) 310 .fadeOut(); 311 } 312 } 313 ); 314 315 // Hero Block Scroll Icon ////////////////////////////// 316 $(".scroll--icon").each(function () { 317 $(this).click(function () { 318 var target = $(this).closest("section").next("section"); 319 html.add(body).animate( 320 { 321 scrollTop: target.offset().top - 75, 322 }, 323 700 324 ); 325 }); 326 }); 327 328 // Parallax Scrolling Effect ///////////////////////////////////// 329 var parallaxItem = $(".image--parallax"); 330 if (parallaxItem.length) { 331 // On Page Load // 332 parallaxItem.each(function () { 333 if ($(this).isOnScreen()) { 334 parallax_image_trigger($(this)); 335 } 336 }); 337 // On Scroll // 338 $(window).scroll(function () { 339 parallaxItem.each(function () { 340 if ($(this).isOnScreen()) { 341 parallax_image_trigger($(this)); 342 } 343 }); 344 }); 345 } 346 function parallax_image_trigger(elem) { 347 // Define Variables // 348 var vpHeight = $(window).height(), 349 vpBottom = $(window).scrollTop() + vpHeight, 350 elemHeight = elem.outerHeight(), 351 elemTop = elem.offset().top; 352 // Distance Values & Percentage // 353 var scrollDistance = vpHeight + elemHeight, 354 scrollProgress = vpBottom - elemTop, 355 scrollPercentage = (scrollProgress / scrollDistance) * 100; 356 // Apply Movement // 357 elem 358 .find("img") 359 .css("transform", "translate(0, -" + scrollPercentage / 3 + "%)"); 360 } 361 362 // Scroll to Top Button Functionality /////////////////////////////////////// 363 var iconScroll = $("#icon--scroll"); 364 if (body.is("[animation--scroll-to-top]")) { 365 iconScroll.click(function () { 366 html.add(body).animate( 367 { 368 scrollTop: body.offset().top, 369 }, 370 700 371 ); 372 }); 373 $(window).scroll(function () { 374 if ( 375 document.body.scrollTop > 600 || 376 document.documentElement.scrollTop > 600 377 ) { 378 iconScroll.addClass("visible"); 379 } else { 380 iconScroll.removeClass("visible"); 381 } 382 }); 383 } 384 385 // ---------------------------------------------------------------- // 386 // ----- Truncate Text & Scroll on Hover ----- // 387 388 // - Apply Truncate Attribute to Relevant Items 389 // ** Automatically applied to projects categories 390 391 // Add Truncate to Certain Items 392 var truncatedItems = 393 "main#home #home-news.module--posts-display-block .module--content > .title--wrapper"; 394 const truncatedElements = $(truncatedItems); 395 truncatedElements.attr("truncate", ""); 396 397 // Find All Truncated Items & Apply 398 $('[truncate]').each(function (e) { 399 custom_apply_truncation( $(this) ); 400 }); 401 402 // Function -- Truncate Current Item 403 function custom_apply_truncation( currentItem ) { 404 currentItem 405 .on("mouseover", function (e) { 406 if ($(window).width() > mobileSize) { 407 elem = $(this); 408 var containerWidth = elem.outerWidth(); 409 var elemWidth = elem.find(">:first-child").outerWidth(); 410 if (containerWidth < elemWidth) { 411 var scrollLength = elemWidth - containerWidth; 412 var scrollSpeed = scrollLength * 10; 413 $(this).attr("truncate", "active"); 414 $(this) 415 .stop() 416 .animate({ scrollLeft: scrollLength }, scrollSpeed, "linear"); 417 } 418 } 419 }) 420 .on("mouseout", function (e) { 421 if ($(window).width() > mobileSize) { 422 elem = $(this); 423 var containerWidth = elem.outerWidth(); 424 var elemWidth = elem.find(">:first-child").outerWidth(); 425 if (containerWidth < elemWidth) { 426 var scrollLength = elemWidth - containerWidth; 427 $(this).attr("truncate", ""); 428 $(this).stop().animate({ scrollLeft: -scrollLength }, 0); 429 } 430 } 431 }); 432 } 433 434 // ---------------------------------------------------------------- // 435 // ----- Home Page Endless Scroll ----- // 436 const homePosts = $('.module--split .posts--container'); 437 if( homePosts.length > 0 ) { 438 const homePostsClone1 = homePosts.clone(); 439 const homePostsClone2 = homePosts.clone(); 440 homePostsClone1.addClass('clone').insertAfter(homePosts); 441 homePostsClone2.addClass('clone').insertAfter(homePostsClone1); 442 443 // On Load - Jump to Center Clone 444 if ($(window).width() > mobileSize) { 445 var headerWrapperHeight = $('.header--wrapper').outerHeight() ? $('.header--wrapper').outerHeight() : 0; 446 var limitTop = homePostsClone1.offset().top; 447 window.scrollTo(0, (limitTop - headerWrapperHeight - 15) ); 448 } 449 // On Scroll - check for positioning and jump to stay on Center Clone 450 $(window).scroll(function () { 451 if ($(window).width() > mobileSize) { 452 var headerWrapperHeight = $('.header--wrapper').outerHeight() ? $('.header--wrapper').outerHeight() : 0; 453 var limitTop = homePostsClone1.offset().top; 454 var limitBottom = homePostsClone2.offset().top; 455 var vpTop = $(window).scrollTop(); 456 var vpHeight = $(window).height(); 457 if( limitTop > (vpTop + vpHeight + 15) ) { 458 window.scrollTo(0, (limitBottom - vpHeight - 15) ); 459 } 460 if( limitBottom < (vpTop + headerWrapperHeight + 15) ) { 461 window.scrollTo(0, (limitTop - headerWrapperHeight - 15) ); 462 } 463 } 464 }); 465 // On Resize - Jump to top of Center Clone OR top of page 466 $(window).resize(function () { 467 if ($(window).width() > mobileSize) { 468 var headerWrapperHeight = $('.header--wrapper').outerHeight() ? $('.header--wrapper').outerHeight() : 0; 469 var limitTop = homePostsClone1.offset().top; 470 window.scrollTo(0, (limitTop - headerWrapperHeight - 15) ); 471 } 472 }); 473 } 474 475 // ---------------------------------------------------------------- // 476 // ----- Home Page -- Project Text Animation Trigger ----- // 477 var homeProjectSubtitle = $('.module--split .card[mediatype="name"] p.subtitle'); 478 $(window).scroll(function () { 479 homeProjectSubtitle.each(function (i) { 480 var thisProjectLabel = $(this); 481 if (thisProjectLabel.inCenterScreen()) { 482 thisProjectLabel.attr('animation-state', 'true'); 483 } 484 }); 485 }); 486 487 // -------------------------------------------------------------------------- // 488 // ----- LazyLoad Media (Images & Videos) on Project / Case Study pages ----- // 489 // if( $('main.projects--single').length > 0 ) { 490 // var mediaVideos = $('video, iframe'); 491 // mediaVideos.each(function() { 492 // $(this).attr('autoplay', ''); 493 // }); 494 495 // var mediaAll = $('img, video, iframe'); 496 497 // function mediaLoaded( mediaItem ) { 498 // mediaItem.addClass('easyload'); 499 // } 500 // mediaAll.each(function() { 501 // var mediaItem = $(this); 502 // // mediaItem.attr('async', 'true'); 503 // if( this.complete ) { 504 // mediaLoaded(mediaItem); 505 // } else { 506 // mediaItem.one('load', mediaLoaded(mediaItem)); 507 // } 508 // }); 509 // } 510 511 // ---------------------------------------------------------------- // 512 // ----- Smooth Scroll ----- // 513 514 // Scroll on Click a // 515 $(function () { 516 $('a[href*="#"]:not([href="#"])').click(function (e) { 517 if ( 518 location.pathname.replace(/^\//, "") == 519 this.pathname.replace(/^\//, "") && 520 location.hostname == this.hostname 521 ) { 522 var target = $(this.hash); 523 target = target.length 524 ? target 525 : $("[name=" + this.hash.slice(1) + "]"); 526 if (target.length) { 527 // Close mobile menu
528 if ($(this).closest(".nav--mobile-on").length !== 0) { 529 closeMobile(); 530 } 531 532 let offset = 75; 533 534 // Offset for sticky header 535 if ($(".header--wrapper").hasClass("header--sticky")) { 536 offset += $(".header--wrapper header").outerHeight(); 537 } 538 html.add(body).animate( 539 { 540 scrollTop: target.offset().top - offset, 541 }, 542 700 543 ); 544 return false; 545 } 546 } 547 }); 548 }); 549 // Scroll on Page Load with Hash in URL // 550 $(function () { 551 if (document.location.hash) { 552 var target = $(document.location.hash); 553 if (target.length) { 554 html.add(body).animate( 555 { 556 scrollTop: target.offset().top - 75, 557 }, 558 700 559 ); 560 } 561 } 562 }); 563 // Smooth Scroll on Search 564 $(document).on( 565 "click", 566 '.search--build .search--heading a[href*="#"]:not([href="#"])', 567 function (e) { 568 // Variables // 569 var search_body = html.add(body); 570 let offset = 50; 571 // Header Search Variables 572 search_header = $(this).closest("#search--form"); 573 if (search_header.length !== 0) { 574 search_body = search_header; 575 offset = 225; 576 } 577 // Mobile Variables 578 var search_mobile = $(this).closest(".nav--mobile"); 579 if (search_mobile.length !== 0) { 580 search_body = search_mobile.find(".nav-container"); 581 offset = 225; 582 } 583 584 // Target 585 var target = $(this.hash); 586 target = target.length ? target : $("[name=" + this.hash.slice(1) + "]"); 587 if (target.length) { 588 var win = $(window); 589 var viewport = { 590 top: win.scrollTop(), 591 left: win.scrollLeft(), 592 }; 593 var animate_target = target.offset().top - offset; 594 if (search_mobile !== 0) 595 animate_target = target.offset().top - viewport.top - offset; 596 597 search_body.animate( 598 { 599 scrollTop: animate_target, 600 }, 601 700 602 ); 603 return false; 604 } 605 } 606 ); 607 608 // ---------------------------------------------------------------- // 609 // ----- Splide ----- // 610 611 const $carousel = $(".splide"); 612 if ($carousel.length > 0) { 613 Splide.defaults = { 614 type: "loop", 615 speed: 2000, 616 type: "loop", 617 perMove: 1, 618 snap: true, 619 breakpoints: { 620 767: { 621 perPage: 1, 622 fixedWidth: false, 623 fixedHeight: false, 624 }, 625 }, 626 }; 627 $carousel.each(function () { 628 // --- Project Page Splide 629 if( $(this).closest('.projects--single').length > 0 && $(this).hasClass('module--gallery-block') ) { 630 Splide.defaults = { 631 type: "loop", 632 perMove: 1, 633 snap: true, 634 mediaQuery: 'min', 635 fixedWidth: '70%', 636 breakpoints: { 637 575: { 638 destroy: true, 639 } 640 } 641 }; 642 console.log(Splide.defaults); 643 } 644 // --- 645 const hasGalCaption = $carousel.find(".caption-gal").length; 646 const splide = new Splide(this, { 647 updateOnMove: hasGalCaption, 648 }); 649 let transitions = ""; 650 let extensions = {}; 651 if ($carousel.hasClass("has-numbers")) { 652 extensions.number = slideNumber; 653 } 654 if (hasGalCaption) { 655 extensions.caption = captionGal; 656 } 657 658 const bar = splide.root.querySelector(".progress-bar"); 659 if (bar) { 660 splide.on("mounted move", function () { 661 const end = splide.Components.Controller.getEnd() + 1; 662 const rate = Math.min((splide.index + 1) / end, 1); 663 bar.style.width = String(100 * rate) + "%"; 664 }); 665 } 666 // Carousel Pagination Color 667 splide.on("pagination:mounted", function () { 668 const slidePag = $(".splide__pagination"); 669 let pagColor = slidePag.attr("data-pag-color"); 670 slidePag.find(".splide__pagination__page").css("background", pagColor); 671 }); 672 673 splide.mount(extensions, transitions); 674 675 // Fancybox Remove Clones 676 if ($(this).hasClass("fancybox") && typeof Fancybox == "function") { 677 Fancybox.bind( 678 ".splide__slide:not(.splide__slide--clone) [data-fancybox]", 679 {} 680 ); 681 } 682 }); 683 } 684 685 function slideNumber(Splide, Components) { 686 function mount() { 687 update(); 688 Splide.on("move", update); 689 }
690 function update() { 691 $(Components.Elements.root) 692 .find(".slide-numbers span") 693 .text(`${Splide.index + 1} of ${Splide.length}`); 694 } 695 return { 696 mount, 697 }; 698 } 699 700 function captionGal(Splide, Components) { 701 function mount() { 702 caption(); 703 Splide.on("active", caption); 704 } 705 function caption() { 706 const root = $(Components.Elements.root); 707 const captionText = root.find(".item.is-active figcaption").html(); 708 root.find(".caption-gal").html(captionText ? captionText : ""); 709 } 710 return { 711 mount, 712 }; 713 } 714 715 // ---------------------------------------------------------------- // 716 // ----- Animations ----- // 717 718 $.fn.inCenterTopScreen = function () { 719 var win = $(window); 720 var viewport = { 721 top: win.scrollTop(), 722 left: win.scrollLeft(), 723 }; 724 viewport.right = viewport.left + win.width(); 725 viewport.bottom = viewport.top + win.height(); 726 727 var bounds = this.offset(); 728 bounds.right = bounds.left + this.outerWidth(); 729 bounds.bottom = bounds.top + this.outerHeight(); 730 731 var viewportCenterOffset = (viewport.bottom - viewport.top) * 0.25; 732 var viewportCenter = viewport.top + viewportCenterOffset; 733 734 var viewportTopSection = viewport.top + viewportCenterOffset; 735 var viewportBottomSection = viewport.top + viewportCenterOffset * 3; 736 737 return !( 738 viewportBottomSection < bounds.top || viewport.top > bounds.bottom 739 ); 740 }; 741 742 $.fn.inCenterScreen = function () { 743 var win = $(window); 744 var viewport = { 745 top: win.scrollTop(), 746 left: win.scrollLeft(), 747 }; 748 viewport.right = viewport.left + win.width(); 749 viewport.bottom = viewport.top + win.height(); 750 751 var bounds = this.offset(); 752 bounds.right = bounds.left + this.outerWidth(); 753 bounds.bottom = bounds.top + this.outerHeight(); 754 755 var viewportCenterOffset = (viewport.bottom - viewport.top) * 0.25; 756 var viewportCenter = viewport.top + viewportCenterOffset; 757 758 var viewportTopSection = viewport.top + viewportCenterOffset; 759 var viewportBottomSection = viewport.top + viewportCenterOffset * 3; 760 761 return !( 762 viewportBottomSection < bounds.top || viewportTopSection > bounds.bottom 763 ); 764 }; 765 766 // ----- Simple Fade In Animation Elements ----- // 767 // -- Add Animation Class -- // 768 var animationModules = body.find(".animation--modules").html(); 769 770 if (animationModules) { 771 var animationLocations = animationModules.replaceAll("<br>\n", ", "); 772 $(animationLocations).each(function () { 773 if (!$(this).hasClass("animation--off")) { 774 $(this).addClass("animation--true"); 775 } 776 }); 777 } 778 779 // -- Define Element (Module) & Apply Class Trigger on Scroll -- // 780 var inView = $("section.animation--true"); 781 782 // Load all in viewport // 783 setTimeout(function () { 784 inView.not(".animation--on").each(function (i) { 785 if ($(this).inCenterTopScreen()) { 786 $(this).addClass("animation--on"); 787 } 788 }); 789 }, 10); 790 791 // Loads in new stuff on scroll // 792 $(window).scroll(function () { 793 inView.each(function (i) { 794 if ($(this).inCenterScreen()) { 795 $(this).addClass("animation--on"); 796 } 797 }); 798 }); 799 800 // -- Specific Module (Posts Display & Gallery) & Apply Class Trigger on Scoll -- // 801 var inViewSpecial = $( 802 "section.animation--true.module--posts-display-block .item, section.animation--true.module--gallery-block .item" 803 ); 804 805 // Load all in viewport // 806 setTimeout(function () { 807 inViewSpecial.not(".animation--individual").each(function (i) { 808 if ($(this).isOnScreen()) { 809 $(this).addClass("animation--individual"); 810 } 811 }); 812 }, 10); 813 814 // Loads in new stuff on scroll // 815 $(window).scroll(function () { 816 inViewSpecial.each(function (i) { 817 if ($(this).isOnScreen()) { 818 $(this).addClass("animation--individual"); 819 } 820 }); 821 }); 822 823 // Loads in Splide Items on next 824 $(document).on("click", ".splide__arrow", function (e) { 825 var thisSplide = $(this).closest("section.splide").find(".splide__track"); 826 thisSplide.find(".splide__slide").each(function () { 827 if (!$(this).hasClass("animation--individual")) { 828 $(this).addClass("animation--individual"); 829 } 830 }); 831 }); 832 833 // ----- ADA ----- // 834 835 // Skip Links 836 $(".skip-links a").click(function () { 837 let landmark = $(this).attr("href"); 838 $(landmark).attr("tabindex", "-1").focus(); 839 }); 840 841 // Main Menu 842 $("li.dropdown").hover( 843 function () { 844 $(this).find("> ul.sub-menu.dropdown-menu").addClass("open"); 845 if ($(this).hasClass("has-btn")) { 846 $(this).find("> button").attr("aria-expanded", "true"); 847 } else { 848 $(this).find("> a").attr("aria-expanded", "true"); 849 } 850 }, 851 function () { 852 $(this).find("ul.sub-menu.dropdown-menu").removeClass("open"); 853 if ($(this).hasClass("has-btn")) { 854 $(this).find("> button").attr("aria-expanded", "false"); 855 } else { 856 $(this).find("> a").attr("aria-expanded", "false"); 857 } 858 } 859 ); 860 861 $("ul#menu-main-nav li .menubutton").click(function () { 862 var submenu = $(this).parent().find("> .sub-menu.dropdown-menu"); 863 let btnLabel = $(this).attr("aria-label"); 864 865 if (submenu.hasClass("open")) { 866 submenu.removeClass("open"); 867 $(this).attr("aria-expanded", "false"); 868 $(this).attr("aria-label", btnLabel.replace("hide", "show")); 869 } else { 870 submenu.addClass("open"); 871 $(this).attr("aria-expanded", "true"); 872 $(this).attr("aria-label", btnLabel.replace("show", "hide")); 873 } 874 if ($(this).attr("aria-expanded") == "true") { 875 submenu.parent().on("focusout", function () { 876 setTimeout(function () { 877 // need timeout because nothing has focus during 'focu
877sout' 878 if ($(":focus").closest(submenu).length <= 0) { 879 submenu.removeClass("open"); 880 submenu.siblings(".menubutton").attr("aria-expanded", "false"); 881 submenu 882 .siblings(".menubutton") 883 .attr("aria-label", btnLabel.replace("hide", "show")); 884 } 885 }, 0); 886 }); 887 } 888 }); 889 890 $("ul#menu-main-nav").on("keydown", function (e) { 891 let focusEl = $(this).find(":focus").parent(); 892 let nextEl = focusEl.next(); 893 let prevEl = focusEl.prev(); 894 let menuBtn = focusEl.find("> .menubutton"); 895 let submenu = focusEl.parent(".sub-menu.dropdown-menu"); 896 897 var keyCode = e.keyCode ? e.keyCode : e.which; 898 899 if (keyCode == 27 && submenu.length) { 900 // Esc 901 let menuBtn = submenu.siblings(".menubutton"); 902 var btnLabel = menuBtn.attr("aria-label"); 903 904 submenu.removeClass("open"); 905 if (menuBtn) { 906 $(this).siblings("button").attr("aria-expanded", "false"); 907 } else { 908 $(this).siblings("a").attr("aria-expanded", "false"); 909 } 910 menuBtn.focus().attr("aria-label", btnLabel.replace("hide", "show")); 911 } else if (keyCode == 39 || keyCode == 40) { 912 // Right || Down 913 e.preventDefault(); 914 if (menuBtn.is(":focus") && menuBtn.attr("aria-expanded") == "true") { 915 focusEl.find("> .sub-menu li:first a").focus().closest("li"); 916 } else if (menuBtn.is(":focus")) { 917 // Btn is focused 918 if (nextEl.find("> a").length) { 919 // Focus on next element's link 920 nextEl.find("> a").focus(); 921 } else { 922 // Next element has no link 923 // Focus on next element's btn 924 nextEl.find("button").focus(); 925 } 926 } else if (focusEl.hasClass("dropdown")) { 927 menuBtn.focus(); 928 } else { 929 nextEl.find("> a").focus(); 930 } 931 } else if (keyCode == 37 || keyCode == 38) { 932 // Left || Up 933 e.preventDefault(); 934 if (menuBtn.is(":focus")) { 935 // Btn is focused 936 if (focusEl.find("> a").length) { 937 // Focus on this element's link 938 focusEl.find("> a").focus(); 939 } else { 940 // This element has no link 941 // Focus on previous element's btn 942 prevEl.find("button").focus(); 943 } 944 } else if (prevEl.hasClass("dropdown")) { 945 prevEl.find(".menubutton").focus(); 946 } else { 947 prevEl.find("> a").focus(); 948 } 949 } else if (keyCode == 35) { 950 // End 951 e.preventDefault(); 952 if (submenu.length) { 953 let lastEl = submenu.find("> li").last(); 954 if (lastEl.find("> a").length) { 955 lastEl.find("> a").focus(); 956 } else { 957 lastEl.find("> button").focus(); 958 } 959 } else { 960 let lastEl = $(this).find("> li").last(); 961 if (lastEl.find("> a").length) { 962 lastEl.find("> a").focus(); 963 } else { 964 lastEl.find("> button").focus(); 965 } 966 } 967 } else if (keyCode == 36) { 968 // Home 969 e.preventDefault(); 970 if (submenu.length) { 971 let firstEl = submenu.find("> li").first(); 972 if (firstEl.find("> a").length) { 973 firstEl.find("> a").focus(); 974 } else { 975 firstEl.find("> button").focus(); 976 } 977 } else { 978 let firstEl = $(this).find("> li").first(); 979 if (firstEl.find("> a").length) { 980 firstEl.find("> a").focus(); 981 } else { 982 firstEl.find("> button").focus(); 983 } 984 } 985 } 986 }); 987 988 // Mobile Menu 989 mobileMenu.find("li .menubutton").click(function () { 990 const submenu = $(this).siblings(".sub-menu.dropdown-menu"); 991 $(this).parent().toggleClass("open"); 992 $(this).toggleClass("open"); 993 $(this).attr("aria-expanded", $(this).attr("aria-expanded") !== "true"); 994 submenu.slideToggle(); 995 }); 996 997 // Search input //const search = header.find('.nav--mobile .search--form-mobile'); 998 const headerLogo = header.find(".column--header .logo"); 999 const search = header.find(".nav--mobile .icon--search"); 1000 const social = header.find(".nav--mobile .nav--social"); 1001 const topNav = header.find(".nav--top-mobile"); 1002 body.on("keydown", "header.mobile-active", function (e) { 1003 var keyCode = e.keyCode ? e.keyCode : e.which; 1004 if ( 1005 keyCode == 27 && 1006 !$(e.target).parents(".sub-menu.dropdown-menu").length 1007 ) { 1008 closeMobile(); 1009 } else if (keyCode == 9 && e.shiftKey) { 1010 // First element shift tab 1011 if (headerLogo.is(":focus")) { 1012 e.preventDefault(); 1013 if (search.length) { 1014 search.focus(); 1015 } 1016 if (!search && social.length) { 1017 social.find("li:last-of-type a").focus(); 1018 } else if (!search && !social && topNav.length) { 1019 topNav.find("li:last-of-type a").focus(); 1020 } else { 1021 mobileMenu.find("> li:last-of-type a").focus(); 1022 } 1023 } 1024 // Mobile Icon shift tab 1025 else if (mobileIcon.is(":focus")) { 1026 e.preventDefault(); 1027 headerLogo.focus(); 1028 } 1029 } else if (keyCode == 9) { 1030 // Logo tab 1031 if (headerLogo.is(":focus")) { 1032 e.preventDefault(); 1033 mobileIcon.focus(); 1034 } 1035 // Last element tab 1036 // Search input // if (search.length && search.find('button').is(':focus')) { 1037 if (search.length && search.is(":focus")) { 1038 e.preventDefault(); 1039 headerLogo.focus(); 1040 } else if ( 1041 !search && 1042 social.length && 1043 social.find("li:last-of-type a").is(":focus") 1044 ) { 1045 e.preventDefault(); 1046 headerLogo.focus(); 1047 } else if ( 1048 !search && 1049 !social && 1050 topNav.length && 1051 topNav.find("li:last-of-type a").is(":focus") 1052 ) { 1053 e.preventDefault(); 1054 headerLogo.focus(); 1055 } else if (mobileMenu.find("li:last-of-type a").is(":focus")) { 1056 e.preventDefault(); 1057 headerLogo.focus(); 1058 } 1059 } 1060 }); 1061
1062 mobileMenu.on("keydown", function (e) { 1063 let focusEl = $(this).find(":focus").parent(); 1064 if (focusEl.parents(".sub-menu.dropdown-menu").length) { 1065 const submenu = focusEl.parent(".sub-menu.dropdown-menu"); 1066 const menuBtn = submenu.siblings(".menubutton"); 1067 } 1068 1069 const keyCode = e.keyCode ? e.keyCode : e.which; 1070 1071 if (keyCode == 27 && submenu && submenu.length) { 1072 // Esc 1073 submenu.removeClass("open"); 1074 submenu.parent().removeClass("open"); 1075 submenu.slideToggle(); 1076 menuBtn.attr("aria-expanded", "false"); 1077 } 1078 if (keyCode == 39 || keyCode == 40) { 1079 // Right || Down 1080 e.preventDefault(); 1081 menuBtn = focusEl.find(".menubutton"); 1082 if (menuBtn.is(":focus") && menuBtn.attr("aria-expanded") == "true") { 1083 focusEl.find("> ul > li:first > a").focus(); 1084 } else if (menuBtn.is(":focus")) { 1085 focusEl.next("li").find("> a, > .menubutton").focus(); 1086 } else if (focusEl.hasClass("dropdown")) { 1087 focusEl.find("> .menubutton").focus(); 1088 } else { 1089 focusEl.next().find("> a").focus(); 1090 } 1091 } else if (keyCode == 37 || keyCode == 38) { 1092 // Left || Up 1093 e.preventDefault(); 1094 if (focusEl.find(".menubutton").is(":focus")) { 1095 if (focusEl.find("> a").length) { 1096 focusEl.find("> a").focus(); 1097 } else { 1098 // if prev is span 1099 focusEl.prev().find(".menubutton").focus(); 1100 } 1101 } else if (focusEl.prev().hasClass("dropdown")) { 1102 focusEl.prev().find(".menubutton").focus(); 1103 } else { 1104 focusEl.prev().find("> a").focus(); 1105 } 1106 } else if (keyCode == 35) { 1107 // End 1108 e.preventDefault(); 1109 if (!submenu.length) { 1110 $(this).find("li").last().find("> a").focus(); 1111 } else { 1112 submenu.find("li").last().find("> a").focus(); 1113 } 1114 } else if (keyCode == 36) { 1115 // Home 1116 e.preventDefault(); 1117 if (!submenu.length) { 1118 $(this).find("li").first().find("> a").focus(); 1119 } else { 1120 submenu.find("li").first().find("> a").focus(); 1121 } 1122 } 1123 }); 1124 1125 // --------------------------------------------------------- // 1126 1127 // ----- Custom Select ----- // 1128 var x, i, j, l, ll, selElmnt, a, b, c; 1129 /* Look for any elements with the class "custom-select": */ 1130 x = document.getElementsByClassName("select--custom"); 1131 l = x.length; 1132 for (i = 0; i < l; i++) { 1133 selElmnt = x[i].getElementsByTagName("select")[0]; 1134 ll = selElmnt.length; 1135 elmntID = x[i].getAttribute("data-selectid"); 1136 1137 /* For each element, create a new DIV that will act as the selected item: */ 1138 a = document.createElement("BUTTON"); 1139 a.setAttribute("id", elmntID + "_selected"); 1140 a.setAttribute("class", "select-selected"); 1141 a.setAttribute("aria-controls", elmntID + "_options"); 1142 a.setAttribute("aria-haspopup", elmntID + "_options"); 1143 a.setAttribute("aria-expanded", "false"); 1144 a.setAttribute("aria-label", "filter displayed items"); 1145 a.setAttribute("role", "combobox"); 1146 1147 a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML; 1148 a.setAttribute("value", a.innerHTML); 1149 x[i].appendChild(a); 1150 a.innerHTML += '<i class="fa-regular fa-chevron-down"></i>'; 1151 /* For each element, create a new DIV that will contain the option list: */ 1152 b = document.createElement("UL"); 1153 b.setAttribute("class", "select-items select-hide"); 1154 b.setAttribute("id", elmntID + "_options"); 1155 b.setAttribute("role", "listbox"); 1156 1157 for (j = 1; j < ll; j++) { 1158 /* For each option in the original select element, 1159 create a new DIV that will act as an option item: */ 1160 c = document.createElement("LI"); 1161 c.setAttribute("role", "option"); 1162 c.setAttribute("tabindex", 0); 1163 c.innerHTML = selElmnt.options[j].innerHTML; 1164 c.addEventListener("click", function (e) { 1165 /* When an item is clicked, update the original select box, 1166 and the selected item: */ 1167 var y, i, k, s, h, sl, yl; 1168 s = this.parentNode.parentNode.getElementsByTagName("select")[0]; 1169 sl = s.length; 1170 h = this.parentNode.previousSibling; 1171 for (i = 0; i < sl; i++) { 1172 if (s.options[i].innerHTML == this.innerHTML) { 1173 s.selectedIndex = i; 1174 h.innerHTML = this.innerHTML; 1175 a.setAttribute("value", this.innerHTML); 1176 h.innerHTML += '<i class="fa-regular fa-chevron-down"></i>'; 1177 y = this.parentNode.getElementsByClassName("same-as-selected"); 1178 yl = y.length; 1179 for (k = 0; k < yl; k++) { 1180 y[k].removeAttribute("class"); 1181 } 1182 this.setAttribute("class", "same-as-selected"); 1183 break; 1184 } 1185 } 1186 h.click(); 1187 }); 1188 b.appendChild(c); 1189 } 1190 x[i].appendChild(b); 1191 a.addEventListener("click", function (e) { 1192 /* When the select box is clicked, close any other select boxes, 1193 and open/close the current select box: */ 1194 e.stopPropagation(); 1195 closeAllSelect(this); 1196 this.nextSibling.classList.toggle("select-hide"); 1197 this.classList.toggle("select-arrow-active"); 1198 this.setAttribute( 1199 "aria-expanded",
1200 this.getAttribute("aria-expanded") === "false" 1201 ); 1202 }); 1203 1204 a.addEventListener("keydown", function (e) { 1205 const keyCode = e.keyCode ? e.keyCode : e.which; 1206 const isOpen = $(this).attr("aria-expanded") === "true"; 1207 1208 if (isOpen) { 1209 if (keyCode == 40) { 1210 // Arrow down 1211 e.preventDefault(); 1212 // Skip the placeholder el and focus on the first dropdown el 1213 $(this).next().find("li:nth-of-type(2)").focus(); 1214 } else if (keyCode == 38) { 1215 // Arrow up 1216 e.preventDefault(); 1217 $(this).next().find("li:last").focus(); 1218 } else if (keyCode == 27) { 1219 // Esc 1220 e.preventDefault(); 1221 closeAllSelect($(this)); 1222 $(a).focus(); 1223 } 1224 } else { 1225 if (keyCode == 38 || keyCode == 40) { 1226 // Arrow up || Arrow down 1227 e.preventDefault(); 1228 this.nextSibling.classList.toggle("select-hide"); 1229 this.classList.toggle("select-arrow-active"); 1230 this.setAttribute( 1231 "aria-expanded", 1232 this.getAttribute("aria-expanded") === "false" 1233 ); 1234 } 1235 } 1236 let i = 1; 1237 }); 1238 b.addEventListener("keydown", function selListKeydown(e) { 1239 const keyCode = e.keyCode ? e.keyCode : e.which; 1240 const currentEl = $(this).find("li:focus"); 1241 if (keyCode == 27) { 1242 // Esc 1243 e.preventDefault(); 1244 closeAllSelect(); 1245 $(a).focus(); 1246 } else if (keyCode == 13) { 1247 // Enter 1248 e.preventDefault(); 1249 currentEl.trigger("click"); 1250 a.focus(); 1251 } else if (keyCode == 40) { 1252 // Arrow down 1253 e.preventDefault(); 1254 if (currentEl.is(":last-child")) { 1255 $(b).find("li:nth-of-type(2)").focus(); 1256 } else { 1257 currentEl.next().focus(); 1258 } 1259 } else if (keyCode == 38) { 1260 // Arrow up 1261 e.preventDefault(); 1262 if (currentEl.is(":nth-of-type(2)")) { 1263 $(b).find("li:last").focus(); 1264 } else { 1265 currentEl.prev().focus(); 1266 } 1267 } else if ( 1268 keyCode == 9 && 1269 e.shiftKey && 1270 currentEl.is(":nth-of-type(2):focus") 1271 ) { 1272 e.preventDefault(); 1273 $(b).find("li:last").focus(); 1274 } else if ( 1275 keyCode == 9 && 1276 !e.shiftKey && 1277 currentEl.is(":last-child:focus") 1278 ) { 1279 e.preventDefault(); 1280 $(b).find("li:nth-of-type(2)").focus(); 1281 } 1282 }); 1283 } 1284 function closeAllSelect(elmnt) { 1285 /* A function that will close all select boxes in the document, 1286 except the current select box: */ 1287 var x, 1288 y, 1289 i, 1290 xl, 1291 yl, 1292 arrNo = []; 1293 x = document.getElementsByClassName("select-items"); 1294 y = document.getElementsByClassName("select-selected"); 1295 xl = x.length; 1296 yl = y.length; 1297 for (i = 0; i < yl; i++) { 1298 if (elmnt == y[i]) { 1299 arrNo.push(i); 1300 } else { 1301 y[i].classList.remove("select-arrow-active"); 1302 y[i].setAttribute("aria-expanded", "false"); 1303 } 1304 } 1305 for (i = 0; i < xl; i++) { 1306 if (arrNo.indexOf(i)) { 1307 x[i].classList.add("select-hide"); 1308 } 1309 } 1310 } 1311 /* If the user clicks anywhere outside the select box, 1312 then close all select boxes: */ 1313 document.addEventListener("click", closeAllSelect); 1314 // --------------------------------------------------------- // 1315 1316 1317 1318 // ---------------------------------------------------------------- // 1319 // ----- Logo Animation ----- // 1320 1321 var svg = document.getElementById('eZiWE9m3CrV1'); 1322 var isHome = $('body.page--494'); 1323 var logo = $('header .logo'); 1324 1325 // Play On Load 1326 if( isHome.length > 0 ) { 1327 setTimeout(function () { 1328 playLogo(); 1329 }, 500); 1330 } else { 1331 playLogo(1100); 1332 } 1333 1334 // NOT Home Page 1335 if( isHome.length <= 0 ) { 1336 logo.addClass('scroll--top-triggered'); 1337 // On Scroll 1338 $(window).scroll(function () { 1339 if( $(window).scrollTop() <= 10 ) { 1340 if( !logo.hasClass('scroll--top-triggered') ) { 1341 logo.addClass('scroll--top-triggered'); 1342 playLogo(); 1343 } 1344 } else { 1345 if( logo.hasClass('scroll--top-triggered') ) { 1346 logo.removeClass('scroll--top-triggered'); 1347 reverseLogo(); 1348 } 1349 } 1350 }); 1351 // On Hover 1352 logo.mouseover(function () { 1353 if( $(window).scrollTop() > 10 ) { 1354 playLogo(); 1355 } 1356 }); 1357 logo.mouseleave(function () { 1358 if( $(window).scrollTop() > 10 ) { 1359 reverseLogo(); 1360 } 1361 }); 1362 } 1363 1364 function playLogo( speed = 2 ) { 1365 svg.svgatorPlayer.play().set('speed', speed); 1366 // logo.css('max-width', 180); 1367 } 1368 function reverseLogo() { 1369 setTimeout(function () { 1370 svg.svgatorPlayer.reverse().set('speed', 6); 1371 }, 0); 1372 // setTimeout(function () { 1373 // logo.css('max-width', 45); 1374 // }, 500); 1375 } 1376});
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.