PageSourceSearch

https://www.castla.org/wp-content/themes/bistrocustom/assets/js/code.js?ver=33248636470

js castla.org collected 2026-09-24 19:51:35 UTC 47,085 bytes, 1,417 lines download raw bytes

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
63  // Welglot switcher 
64
65  $('.weglot-parent-menu-item.menu-item-has-children > a, .weglot-toggle > a').html('<i class="fa-regular fa-globe"></i><span class="sr-only">Translate</span>');
66
67  // Menu Toggle Function /////////////////////////////////////
68  const mobileIcon = $("header .icon--mobile");
69  const mobileOverlay = $("header[nav--mobile='overlay'] .nav--mobile");
70  const mobileSidebar = $("header[nav--mobile='sidebar'] .nav--mobile");
71  const mobileMenu = $("ul#menu-main-menu-1");
72
73  function closeMobile() {
74    mobileIcon.addClass("closed");
75    body.removeClass("nav--mobile-on");
76    header.removeClass("mobile-active");
77
78    header.find(".dropdown.open .sub-menu").css("display", "none");
79    header.find(".open").removeClass("open");
80    header.find(".menubutton[aria-expanded=true]").attr("aria-expanded", false);
81
82    // Overlay Mobile Nav //
83    mobileOverlay.fadeOut(100);
84    // Sidebar Mobile Nav //
85    mobileSidebar.removeClass("nav--mobile-sidebar-on");
86  }
87
88  mobileIcon.click(function () {
89    if (!$(this).hasClass("closed")) {
90      closeMobile();
91    } else {
92      $(this).removeClass("closed");
93      body.addClass("nav--mobile-on");
94      header.addClass("mobile-active");
95
96      // Overlay Mobile Nav //
97      mobileOverlay.fadeIn(100).css("display", "flex");
98      // Sidebar Mobile Nav //
99      mobileSidebar.addClass("nav--mobile-sidebar-on");
100    }
101  });
102  $(window).resize(function () {
103    if ($(window).width() > mobileSize) {
104      closeMobile();
105    }
106  });
107
108  // Mobile Nav Height
109  function header_adjust_mobile_nav_height() {
110    var mobileNav = $("header .nav--mobile");
111    var headerItemsHeight = 0;
112    if ($(".header--wrapper .nav--top-container").length)
113      headerItemsHeight += $(
114        ".header--wrapper .nav--top-container"
115      ).outerHeight();
116    if ($(".header--wrapper header .column--container").length)
117      headerItemsHeight += $(
118        ".header--wrapper header .column--container"
119      ).outerHeight();
120    mobileNav.css("height", "calc(100vh - " + headerItemsHeight + "px)");
121  }
122  header_adjust_mobile_nav_height();
123  $(window).resize(function () {
124    if ($(window).width() <= mobileSize) {
125      header_adjust_mobile_nav_height();
126    }
127  });
128
129  // Search Bar Header Toggle Function ///////////////////////////////
130  var searchButton = $("button.icon--search");
131  var searchForm = $("#search--form.search--dropdown");
132  if (searchButton && searchForm) {
133    searchButton.click(function () {
134      // Height of Search Padding
135      search_adjust_header_height();
136      // Open Search
137      searchButton.toggleClass("active");
138      searchForm.toggleClass("search--form-open");
139      if (searchForm.hasClass("search--form-open")) {
140        searchForm.removeAttr("inert");
141      } else {
142        searchForm.attr("inert", "true");
143      }
144      body.toggleClass("search--dropdown-on");
145    });
146  }
147  // Adjust Header Search on Resize
148  // Hide Header Search in Mobile View
149  $(window).resize(function () {
150    search_adjust_header_height();
151    if ($(window).width() <= mobileSize) {
152      searchButton.removeClass("active");
153      searchForm.removeClass("search--form-open").attr("inert", "true");
154      body.removeClass("search--dropdown-on");
155    }
156  });
157  function search_adjust_header_height() {
158    var headerItemsHeight = 0;
159    if ($(".header--wrapper #banner").length)
160      headerItemsHeight += $(".header--wrapper #banner").outerHeight();
161    if ($(".header--wrapper .nav--top-container").length)
162      headerItemsHeight += $(
163        ".header--wrapper .nav--top-container"
164      ).outerHeight();
165    if ($(".header--wrapper header").length)
166      headerItemsHeight += $(".header--wrapper header").outerHeight();
167    searchForm.css("padding-top", headerItemsHeight + "px");
168  }
169
170  // Banner - Home Page - Open & Close State on Scroll
171  var banner = $("#banner");
172  if (banner.length > 0) {
173    $(window).scroll(function () {
174      if ($(window).scrollTop() > 600) {
175        banner.addClass("close");
176      } else {
177        banner.removeClass("close");
178      }
179    });
180  }
181
182  // Resize - Remove Transition
183  function resizedw() {
184    banner.addClass("transition--on");
185  }
186  var doit;
187  window.onresize = function () {
188    banner.removeClass("transition--on");
189    clearTimeout(doit);
190    doit = setTimeout(resizedw, 300);
191  };
192
193  // ---------------------------------------------------------------- //
194  // ----- General Page ----- //
195
196  // Hover/Click Block ////////////////////////
197  const hcBlock = $(".module--hover-click-block");
198  // Hover Event -- Only in Desktop
199  hcBlock.find(".hc--label").mouseenter(function () {
200    const element = $(this);
201    if (
202      element.parents(".module--hover-click-block").data("switch") ===
203        "hover" &&
204      $(window).width() > 576
205    ) {
206      hover_click_block(element);
207    }
208  });
209  // Click Event -- Required in Mobile
210  hcBlock.find(".hc--label").click(function (e) {
211    const element = $(this);
212    if (
213      element.parents(".module--hover-click-block").data("switch") ===
214        "click" ||
215      $(window).width() <= 576
216    ) {
217      e.preventDefault();
218      hover_click_block(element);
219    }
220  });
221
222  // Hover/Click Function
223  function hover_click_block(element) {
224    const parent = element.parents(".module--hover-click-block");
225    const item = parent.find(
226      ".hc--item[data-item=" + element.data("item") + "]"
227    );
228    if (parent.hasClass("live-color") && element.data("color")) {
229      parent.css("background-color", element.data("color"));
230    } else {
231      parent.css("background-color", "");
232    }
233
234    if (!item.hasClass("active")) {
235      item.siblings(".active").removeClass("active").attr("aria-hidden", true);
236      item.addClass("active").attr("aria-hidden", false);
237    }
238    element.siblings(".active").removeClass("active");
239    element.addClass("active");
240  }
241  //////////////////////////////////////////////////
242
243  // Footer Arrows
244
245  $("footer .column--footer:nth-of-type(2) p").each(function () {
246    $(this)
247      .find("strong")
248      .append(
249        '<svg width="26" height="35" viewBox="0 0 26 35" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.6227 17.5696L0.00390625 0.5H13.6227L26.0039 17.5696L13.6227 34.5H0.00390625L13.6227 17.5696Z" fill="#F7F4F2"/></svg>'
250      );
251    $(this).find("strong>br").remove();
252  });
253
254  // Accordion Block ///////////////////////////////
255  const accordionModules = $(
256    ".module--accordion-block, .module--posts-display-block[data-pt='faq']"
257  );
258
259  // Function: Calculate Accordion Height & Load In Transition when Finished
260  function accordion_calculate_height(accordionModules) {
261    // Each Module
262    accordionModules.each(function (e) {
263      const accordionItems = $(this).find(".accordion-item");
264      const accordionItemContainer = $(this).find(".accordion-items");
265      // Each Item
266      accordionItems
267        .each(function (e) {
268          const accordionContent = $(this).find(".content");
269          let accordionHeight = 0;
270          accordionContent.children(":visible").each(function () {
271            accordionHeight += $(this).outerHeight(true);
272          });
273
274          accordionContent.css(
275            "height",
276            // "calc(" + accordionHeight + "px + 2rem)"
277            "calc(" + accordionHeight + "px + 0.5rem)"
278          );
279        })
280        .promise()
281        .done(function () {
282          accordionItemContainer.addClass("accordion--load-transition");
283        });
284    });
285  }
286
287  // Calculate Height on Load & Resize
288  if (accordionModules.length) {
289    accordion_calculate_height(accordionModules);
290  }
291  // Resize
292  $(window).resize(function () {
293    accordion_calculate_height(accordionModules);
294  });
295
296  // Accordion Click Toggle Function
297  $(accordionModules)
298    .find(".accordion-item .label")
299    .click(function () {
300      const item = $(this).closest(".accordion-item");
301      const content = item.find(".content");
302      const isInert = content.attr("inert") === "" ? true : false;
303
304      // Toggle active class
305      item.toggleClass("closed").find("svg").toggleClass("active");
306
307      // Update aria values
308      $(this).attr("aria-expanded", $(this).attr("aria-expanded") === "false");
309      isInert ? content.removeAttr("inert") : content.attr("inert", "");
310    });
311
312  $(".module--tab-block .tab--buttons button:first-of-type").addClass("active");
313
314  // Footer
315  $(".footer-nav-label > a[href='#']").attr({ tabindex: -1, role: "heading" });
316
317  // Social Share /////////////////////////////////////
318  const socialShare = $(".social--share");
319  if (socialShare.length) {
320    const ssType = socialShare.data("type");
321    const copyBtn = socialShare.find("#share-url");
322
323    if (ssType === "menu") {
324      const ssMenu = socialShare.find(".share-menu");
325      // socialShare.closest('section').css({ overflow: 'visible', 'z-index': '2' });
326
327      socialShare
328        .mouseenter(function () {
329          ssMenu.fadeIn();
330        })
331        .mouseleave(function () {
332          ssMenu.fadeOut();
333        })
334        .on("focusout", function () {
335          var $this = $(this);
336          setTimeout(function () {
337            if (!$this.find(":focus").length) {
338              ssMenu.fadeOut();
339            }
340          }, 0);
341        })
342        .click(function () {
343          ssMenu.fadeToggle();
344        });
345    }
346
347    // Click Function
348    copyBtn.click(function (e) {
349      e.preventDefault();
350      navigator.clipboard.writeText(window.location.href);
351      if (ssType !== "menu") {
352        const el = $("#copied-confirmation");
353        el.css("display", "inline-block");
354
355        setTimeout(function () {
356          el.css("display", "none");
357        }, 2000);
358      } else {
359        copyBtn.html(copyBtn.html().replace("Copy link", "Copied!"));
360
361        setTimeout(function () {
362          socialShare.find(".share-menu").fadeOut();
363        }, 1000);
364        setTimeout(function () {
365          copyBtn.html(copyBtn.html().replace("Copied!", "Copy link"));
366        }, 1500);
367      }
368      e.stopPropagation();
369    });
370  }
371  // ------------------------------------------------ //
372
373  //////////////////////////////////////////////////
374
375  // ---------------------------------------------------------------- //
376  // ----- Cast Edits ----- //
377
378  // - Module: Custom Tab Block ///////////////////////////////
379  $(".module--tab-block .tab--buttons button").on("click", function (e) {
380    e.preventDefault();
381    var thisTab = $(this).attr("tab");
382    var thisContent = $(this).closest(".tab--content");
383    thisContent.attr("tab", thisTab);
384    $(".module--tab-block .tab--buttons button").removeClass("active");
385    $(this).addClass("active");
386  });
387  // Truncate
388  $(".module--tab-block .tab--content .item").each(function (e) {
389    const thisItem = $(this);
390    const tabContent = thisItem.find(".block--content").text();
391    const wordsFirstCount = 30;
392    const wordsTotalCount = tabContent.split(" ").slice().length;
393
394    if (wordsTotalCount > wordsFirstCount + 10) {
395      thisItem.addClass("collapsed");
396
397      const wordsFirst = tabContent
398        .split(" ")
399        .slice(0, wordsFirstCount - 1)
400        .join(" ");
401      const wordsExpanded = tabContent
402        .split(" ")
403        .slice(wordsFirstCount - 1)
404        .join(" ");
405      // console.log(wordsFirstCount, wordsTotalCount);
406      // console.log(tabContent);
407      // console.log(wordsFirst);
408      // console.log(wordsExpanded);
409
410      thisItem
411        .find(".block--content")
412        .after(
413          '<div class="block--content-expanded">' + wordsFirst + "...</div>"
414        );
415    } else {
416      // console.log(wordsFirstCount, wordsTotalCount);
417      // console.log("No changes!");
418    }
419
420    // console.log('-------------------------');
421  });
422  $(".module--tab-block .tab--content .item .block--expand-btn").on(
423    "click",
424    function (e) {
425      $(this).toggleClass("active");
426      $(this).closest(".item").toggleClass("open");
427    }
428  );
429
430  // - Module: Text & Video Block - Autoplay Embed Video when scrolled to Video - Preset [video--card] ////////////////////////
431  var videoCardModules = $('.module--text-and-video[preset="video--card"]');
432  $(window).scroll(function () {
433    videoCardModules.each(function (i) {
434      if (
435        $(this).inCenterScreen() &&
436        !videoCardModules.hasClass("autoplay--on")
437      ) {
438        var newSrc =
439          videoCardModules.find("iframe").attr("src") + "&mute=1&autoplay=1";
440        videoCardModules.find("iframe").attr("src", newSrc);
441        videoCardModules.addClass("autoplay--on");
442      }
443    });
444  });
445
446  // - Tab Module & .expanding--read-more -- auto truncate and hide part of content to expand/contract with a "read more" button
447  const expandModules = $(
448    ".module.module--tab-block, .module.expanding--read-more"
449  );
450  expandModules.each(function (e) {});
451
452  // --- Pie Chart -- Programmatic Generation ----------------------- //
453  // - About Page: Who We Serve module - [card--slideshow]
454  var moduleWhoWeServe = $('#who-we-serve[preset="card--slideshow"]');
455  if (moduleWhoWeServe.length > 0) {
456    // Each Chart
457    moduleWhoWeServe.find(".container--mb .items .item").each(function (e) {
458      var pieItem = $(this);
459
460      // Loop Through to get Stats
461      var pieStats = [];
462      pieItem.find("table tr").each(function (e) {
463        var piePartPercentage = $(this)
464          .find("td")
465          .text()
466          .replace(/[^0-9]/g, "");
467        pieStats.push(piePartPercentage);
468      });
469      // Adjust Pie Chart if Values don't add up
470      const pieStatsTotal = pieStats.reduce(
471        (sum, x) => parseInt(sum) + parseInt(x)
472      );
473      if (pieStatsTotal < 100) {
474        const psSize = pieStats.length;
475        const psDifference = 100 - pieStatsTotal;
476        var psDistribution = Math.floor(psDifference / psSize);
477        if (psDistribution === 0) psDistribution = 1;
478        var psNewTotal = 0;
479        // Loop Through and Adjust values to add up to 100
480        for (var i = 0; i < psSize; i++) {
481          const prevVal = parseInt(pieStats[i]);
482          const newVal = prevVal + psDistribution;
483          if (i === psSize - 1) {
484            const lastVal = 100 - psNewTotal;
485            psNewTotal += lastVal;
486            pieStats[i] = lastVal;
487          } else {
488            psNewTotal += newVal;
489            pieStats[i] = newVal;
490          }
491        }
492      }
493      // Create Graph
494      var pieGraph = custom_pie_chart(pieStats);
495      // Append Graph
496      var pieModuleImageContainer = $(
497        '<div class="module--image-container"><div class="module--image-object"></div></div>'
498      );
499      pieModuleImageContainer.find(".module--image-object").append(pieGraph);
500      pieItem.append(pieModuleImageContainer);
501    });
502  }
503  // -- Function to Generate Pie Chart
504  function custom_pie_chart(stats = []) {
505    var pieGraph = $('<div class="module--graph" reversed></div>');
506    var piePercentTotal = 0;
507
508    stats.forEach(function (item, index) {
509      var piePartPercentage = item;
510      var piePartItem = $('<div class="graph--stat"></div>');
511      var pieStatItem = $('<div class="graph--stat-part"></div>');
512      // Pie Stat Variables
513      var piePartDegree = Math.ceil((piePartPercentage * 360) / 100);
514      var piePartsFull = Math.floor(piePartPercentage / 25);
515      piePartItem.attr("quarters", piePartsFull);
516      piePartItem.attr("percentage", piePartPercentage);
517
518      if (piePartsFull > 0) {
519        var pieStatItem2 = $(
520          '<div class="graph--stat-part part--second"></div>'
521        );
522        pieStatItem2.attr(
523          "style",
524          "transform: rotate(" + parseInt((piePartDegree % 90) + 45) + "deg)"
525        );
526      } else {
527        var pieStatItemParent = $(
528          '<div class="graph--stat-part-parent"></div>'
529        );
530        pieStatItem.attr(
531          "style",
532          "transform: rotate(" + parseInt(piePartDegree - 45) + "deg)"
533        );
534        var pieStatSmallItem = pieStatItemParent.append(pieStatItem);
535        pieStatItem = pieStatSmallItem;
536      }
537      // Calculate Stat Part Rotation
538      var pieRotate = 360 * (piePercentTotal / 100);
539      piePartItem.attr("style", "transform: rotate(" + pieRotate + "deg)");
540      // Add to Percentage Total
541      piePercentTotal += parseInt(piePartPercentage);
542      // Append Graph Part
543      piePartItem.append(pieStatItem);
544      if (pieStatItem2) piePartItem.append(pieStatItem2);
545      pieGraph.append(piePartItem);
546    });
547    return pieGraph;
548  }
549  // ---------------------------------------------------------------- //
550
551  // Ways to Give page Donor Advised Funds btn
552  if ($(".page--2184").length) {
553    $("#daf_link").remove();
554    const dafBtn = $("a[href='#daf--embed'");
555    dafBtn.replaceWith(
556      '<button id="daf_link" class="daf-button-link btn" onclick="dafModule.openModal(event);" aria-label="Opens popup to give from donor-advised-fund">Give Now</button>'
557    );
558  }
559
560  // ---------------------------------------------------------------- //
561
562  // Adding SVGs to BGs dynamically
563
564  if ($(".page--12").length) {
565    $("#hero-about").append(
566      '<div class="bg--wrapper"><div class="svg--wrapper"><svg width="400" height="412" viewBox="0 0 400 412" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M398.089 519.807C398.089 233.944 166.35 2.20508 -119.514 2.20508M398.089 519.807H-119.514M398.089 519.807C112.225 519.807 -119.514 288.069 -119.514 2.20508M-119.514 2.20508V519.807M-119.514 519.807C-119.514 328.071 -15.2609 160.685 139.652 71.2407M-119.514 519.807C72.2951 519.807 239.736 415.476 329.155 260.466" stroke="#E8FF37" stroke-width="3" stroke-miterlimit="10"/></svg></div><div class="svg--wrapper"><svg width="400" height="412" viewBox="0 0 400 412" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M398.089 519.807C398.089 233.944 166.35 2.20508 -119.514 2.20508M398.089 519.807H-119.514M398.089 519.807C112.225 519.807 -119.514 288.069 -119.514 2.20508M-119.514 2.20508V519.807M-119.514 519.807C-119.514 328.071 -15.2609 160.685 139.652 71.2407M-119.514 519.807C72.2951 519.807 239.736 415.476 329.155 260.466" stroke="#E8FF37" stroke-width="3" stroke-miterlimit="10"/></svg></div></div>'
567    );
568  }
569
570  // ------------------------------------------------ //
571
572  // Video Image Cover
573  $(".module--video .module--image-object, .module--video .play-icon").click(
574    function () {
575      if (!$(this).parent(".fancy--vid-wrapper").length) {
576        const videoWrapper = $(this).siblings(
577          ".module--video-object:not(.video-loop)"
578        );
579        const video = videoWrapper.find("video");
580        const embed = $(this).siblings(".embed-wrapper");
581        if (video.length) {
582          video.trigger("play");
583        } else if (embed.length) {
584          const iframe = embed.find("iframe");
585          iframe.attr("src", iframe.attr("src") + "&autoplay=1&muted=1");
586        }
587        $(this)
588          .add($(this).siblings().not([videoWrapper[0], embed[0]])
588)
589          .fadeOut();
590      }
591    }
592  );
593
594  // Hero Block Scroll Icon //////////////////////////////
595  $(".scroll--icon").each(function () {
596    $(this).click(function () {
597      var target = $(this).closest("section").next("section");
598      html.add(body).animate(
599        {
600          scrollTop: target.offset().top - 75,
601        },
602        700
603      );
604    });
605  });
606
607  // Parallax Scrolling Effect /////////////////////////////////////
608  var parallaxItem = $(".image--parallax");
609  if (parallaxItem.length) {
610    // On Page Load //
611    parallaxItem.each(function () {
612      if ($(this).isOnScreen()) {
613        parallax_image_trigger($(this));
614      }
615    });
616    // On Scroll //
617    $(window).scroll(function () {
618      parallaxItem.each(function () {
619        if ($(this).isOnScreen()) {
620          parallax_image_trigger($(this));
621        }
622      });
623    });
624  }
625  function parallax_image_trigger(elem) {
626    // Define Variables //
627    var vpHeight = $(window).height(),
628      vpBottom = $(window).scrollTop() + vpHeight,
629      elemHeight = elem.outerHeight(),
630      elemTop = elem.offset().top;
631    // Distance Values & Percentage //
632    var scrollDistance = vpHeight + elemHeight,
633      scrollProgress = vpBottom - elemTop,
634      scrollPercentage = (scrollProgress / scrollDistance) * 100;
635    // Apply Movement //
636    elem
637      .find("img")
638      .css("transform", "translate(0, -" + scrollPercentage / 3 + "%)");
639  }
640
641  // Scroll to Top Button Functionality ///////////////////////////////////////
642  var iconScroll = $("#icon--scroll");
643  if (body.is("[animation--scroll-to-top]")) {
644    iconScroll.click(function () {
645      html.add(body).animate(
646        {
647          scrollTop: body.offset().top,
648        },
649        700
650      );
651    });
652    $(window).scroll(function () {
653      if (
654        document.body.scrollTop > 600 ||
655        document.documentElement.scrollTop > 600
656      ) {
657        iconScroll.addClass("visible");
658      } else {
659        iconScroll.removeClass("visible");
660      }
661    });
662  }
663
664  // Smooth scroll function ///////////////////////////////
665  // Scroll on Click a //
666  $(function () {
667    $('a[href*="#"]:not([href="#"])').click(function (e) {
668      if (
669        location.pathname.replace(/^\//, "") ==
670          this.pathname.replace(/^\//, "") &&
671        location.hostname == this.hostname
672      ) {
673        var target = $(this.hash);
674        target = target.length
675          ? target
676          : $("[name=" + this.hash.slice(1) + "]");
677        if (target.length) {
678          // Close mobile menu
679          if ($(this).closest(".nav--mobile-on").length !== 0) {
680            closeMobile();
681          }
682
683          let offset = 75;
684
685          // Offset for sticky header
686          if ($(".header--wrapper").hasClass("header--sticky")) {
687            offset += $(".header--wrapper header").outerHeight();
688          }
689          html.add(body).animate(
690            {
691              scrollTop: target.offset().top - offset,
692            },
693            700
694          );
695          return false;
696        }
697      }
698    });
699  });
700  // Scroll on Page Load with Hash in URL //
701  $(function () {
702    if (document.location.hash) {
703      var target = $(document.location.hash);
704      if (target.length) {
705        html.add(body).animate(
706          {
707            scrollTop: target.offset().top - 75,
708          },
709          700
710        );
711      }
712    }
713  });
714  // Smooth Scroll on Search
715  $(document).on(
716    "click",
717    '.search--build .search--heading a[href*="#"]:not([href="#"])',
718    function (e) {
719      // Variables //
720      var search_body = html.add(body);
721      let offset = 50;
722      // Header Search Variables
723      search_header = $(this).closest("#search--form");
724      if (search_header.length !== 0) {
725        search_body = search_header;
726        offset = 225;
727      }
728      // Mobile Variables
729      var search_mobile = $(this).closest(".nav--mobile");
730      if (search_mobile.length !== 0) {
731        search_body = search_mobile.find(".nav-container");
732        offset = 225;
733      }
734
735      // Target
736      var target = $(this.hash);
737      target = target.length ? target : $("[name=" + this.hash.slice(1) + "]");
738      if (target.length) {
739        var win = $(window);
740        var viewport = {
741          top: win.scrollTop(),
742          left: win.scrollLeft(),
743        };
744        var animate_target = target.offset().top - offset;
745        if (search_mobile !== 0)
746          animate_target = target.offset().top - viewport.top - offset;
747
748        search_body.animate(
749          {
750            scrollTop: animate_target,
751          },
752          700
753        );
754        return false;
755      }
756    }
757  );
758
759  // Splide ///////////////////////////////
760  const $carousel = $(".splide");
761  if ($carousel.length > 0) {
762    Splide.defaults = {
763      type: "loop",
764      speed: 2000,
765      perPage: 1,
766      perMove: 1,
767      snap: true,
768      breakpoints: {
769        767: {
770          perPage: 1,
771          fixedWidth: false,
772          fixedHeight: false,
773        },
774      },
775    };
776    $carousel.each(function () {
777      const splide = new Splide(this);
778      let transitions = "";
779      let extensions = "";
780
781      if (window.splide && window.splide.Extensions) {
782        extensions = window.splide.Extensions;
783      }
784      if ($carousel.hasClass("has-numbers")) {
785        extensions = { slideNumber };
786      }
787      const bar = splide.root.querySelector(".progress-bar");
788      if (bar) {
789        splide.on("mounted move", function () {
790          const end = splide.Components.Controller.getEnd() + 1;
791          const rate = Math.min((splide.index + 1) / end, 1);
792          bar.style.width = String(100 * rate) + "%";
793        });
794      }
795      // Carousel Pagination Color
796      splide.on("pagination:mounted", function () {
797        const slidePag = $(".splide__pagination");
798        let pagColor = slidePag.attr("data-pag-color");
799        slidePag.find(".splide__pagination__page").css("background", pagColor);
800      });
801
802      splide.mount(extensions, transitions);
803
804      // Fancybox Remove Clones
805      if ($(this).hasClass("fancybox") && typeof Fancybox == "function") {
806        Fancybox.bind(
807          ".splide__slide:not(.splide__slide--clone) [data-fancybox]",
808          {}
809        );
810      }
811    });
812  }
813
814  function slideNumber(Splide, Components) {
815    function mount() {
816      update();
817      Splide.on("move", update);
818    }
819    function update() {
820      $(Components.Elements.root)
821        .find(".slide-numbers span")
822        .text(`${Splide.index + 1}/${Splide.length}`);
823    }
824    return {
825      mount,
826    };
827  }
828
829  // ---------------------------------------------------------------- //
830  // ----- Animations ----- //
831
832  $.fn.inCenterTopScreen = function () {
833    var win = $(window);
834    var viewport = {
835      top: win.scrollTop(),
836      left: win.scrollLeft(),
837    };
838    viewport.right = viewport.left + win.width();
839    viewport.bottom = viewport.top + win.height();
840
841    var bounds = this.offset();
842    bounds.right = bounds.left + this.outerWidth();
843    bounds.bottom = bounds.top + this.outerHeight();
844
845    var viewportCenterOffset = (viewport.bottom - viewport.top) * 0.25;
846    var viewportCenter = viewport.top + viewportCenterOffset;
847
848    var viewportTopSection = viewport.top + viewportCenterOffset;
849    var viewportBottomSection = viewport.top + viewportCenterOffset * 3;
850
851    return !(
852      viewportBottomSection < bounds.top || viewport.top > bounds.bottom
853    );
854  };
855
856  $.fn.inCenterScreen = function () {
857    var win = $(window);
858    var viewport = {
859      top: win.scrollTop(),
860      left: win.scrollLeft(),
861    };
862    viewport.right = viewport.left + win.width();
863    viewport.bottom = viewport.top + win.height();
864
865    var bounds = this.offset();
866    bounds.right = bounds.left + this.outerWidth();
867    bounds.bottom = bounds.top + this.outerHeight();
868
869    var viewportCenterOffset = (viewport.bottom - viewport.top) * 0.25;
870    var viewportCenter = viewport.top + viewportCenterOffset;
871
872    var viewportTopSection = viewport.top + viewportCenterOffset;
873    var viewportBottomSection = viewport.top + viewportCenterOffset * 3;
874
875    return !(
876      viewportBottomSection < bounds.top || viewportTopSection > bounds.bottom
877    );
878  };
879
880  // ----- Simple Fade In Animation Elements ----- //
881
882  // -- Define Element (Module) & Apply Class Trigger on Scroll -- //
883  var inView = $("section.animation--true");
884
885  // Load all in viewport //
886  setTimeout(function () {
887    inView.not(".animation--on").each(function (i) {
888      if ($(this).inCenterTopScreen()) {
889        $(this).addClass("animation--on");
890      }
891    });
892  }, 10);
893
894  // Loads in new stuff on scroll //
895  $(window).scroll(function () {
896    inView.each(function (i) {
897      if ($(this).inCenterScreen()) {
898        $(this).addClass("animation--on");
899      }
900    });
901  });
902
903  // -- Specific Module (Posts Display & Gallery) & Apply Class Trigger on Scoll -- //
904  var inViewSpecial = $(
905    "section.animation--true.module--posts-display-block .item, section.animation--true.module--gallery-block .item"
906  );
907
908  // Load all in viewport //
909  setTimeout(function () {
910    inViewSpecial.not(".animation--individual").each(function (i) {
911      if ($(this).isOnScreen()) {
912        $(this).addClass("animation--individual");
913      }
914    });
915  }, 10);
916
917  // Loads in new stuff on scroll //
918  $(window).scroll(function () {
919    inViewSpecial.each(function (i) {
920      if ($(this).isOnScreen()) {
921        $(this).addClass("animation--individual");
922      }
923    });
924  });
925
926  // Loads in Splide Items on next
927  $(document).on("click", ".splide__arrow", function (e) {
928    const thisSplide = $(this).closest("section.splide").find(".splide__track");
929    thisSplide.find(".splide__slide").each(function () {
930      if (!$(this).hasClass("animation--individual")) {
931        $(this).addClass("animation--individual");
932      }
933    });
934  });
935
936  // ----- ADA ----- //
937
938  // Skip Links
939  $(".skip-links a").click(function () {
940    let landmark = $(this).attr("href");
941    $(landmark).attr("tabindex", "-1").focus();
942  });
943
944  // Main Menu
945  $("li.dropdown").hover(
946    function () {
947      $(this).find("> ul.sub-menu.dropdown-menu").addClass("open");
948      if ($(this).hasClass("has-btn")) {
949        $(this).find("> button").attr("aria-expanded", "true");
950      } else {
951        $(this).find("> a").attr("aria-expanded", "true");
952      }
953    },
954    function () {
955      $(this).find("ul.sub-menu.dropdown-menu").removeClass("open");
956      if ($(this).hasClass("has-btn")) {
957        $(this).find("> button").attr("aria-expanded", "false");
958      } else {
959        $(this).find("> a").attr("aria-expanded", "false");
960      }
961    }
962  );
963
964  $("ul.menu li .menubutton").click(function () {
965    var submenu = $(this).parent().find("> .sub-menu.dropdown-menu");
966    let btnLabel = $(this).attr("aria-label");
967
968    if (submenu.hasClass("open")) {
969      submenu.removeClass("open");
970      $(this).attr("aria-expanded", "false");
971      $(this).attr("aria-label", btnLabel.replace("hide", "show"));
972    } else {
973      submenu.addClass("open");
974      $(this).attr("aria-expanded", "true");
975      $(this).attr("aria-label", btnLabel.replace("show", "hide"));
976    }
977    if ($(this).attr("aria-expanded") == "true") {
978      submenu.parent().on("focusout", function () {
979        setTimeout(function () {
980          // need timeout because nothing has focus during 'focu
980sout'
981          if ($(":focus").closest(submenu).length <= 0) {
982            submenu.removeClass("open");
983            submenu.siblings(".menubutton").attr("aria-expanded", "false");
984            submenu
985              .siblings(".menubutton")
986              .attr("aria-label", btnLabel.replace("hide", "show"));
987          }
988        }, 0);
989      });
990    }
991  });
992
993  $("ul.menu").on("keydown", function (e) {
994    let focusEl = $(this).find(":focus").parent();
995    let nextEl = focusEl.next();
996    let prevEl = focusEl.prev();
997    let menuBtn = focusEl.find("> .menubutton");
998    let submenu = focusEl.parent(".sub-menu.dropdown-menu");
999
1000    if (e.key === "Escape" && submenu.length) {
1001      let menuBtn = submenu.siblings(".menubutton");
1002      var btnLabel = menuBtn.attr("aria-label");
1003
1004      submenu.removeClass("open");
1005      if (menuBtn) {
1006        $(this).siblings("button").attr("aria-expanded", "false");
1007      } else {
1008        $(this).siblings("a").attr("aria-expanded", "false");
1009      }
1010      menuBtn.focus().attr("aria-label", btnLabel.replace("hide", "show"));
1011    } else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
1012      e.preventDefault();
1013      if (menuBtn.is(":focus") && menuBtn.attr("aria-expanded") == "true") {
1014        focusEl.find("> .sub-menu li:first a").focus().closest("li");
1015      } else if (menuBtn.is(":focus")) {
1016        // Btn is focused
1017        if (nextEl.find("> a").length) {
1018          // Focus on next element's link
1019          nextEl.find("> a").focus();
1020        } else {
1021          // Next element has no link
1022          // Focus on next element's btn
1023          nextEl.find("button").focus();
1024        }
1025      } else if (focusEl.hasClass("dropdown")) {
1026        menuBtn.focus();
1027      } else {
1028        nextEl.find("> a").focus();
1029      }
1030    } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
1031      // Left || Up
1032      e.preventDefault();
1033      if (menuBtn.is(":focus")) {
1034        // Btn is focused
1035        if (focusEl.find("> a").length) {
1036          // Focus on this element's link
1037          focusEl.find("> a").focus();
1038        } else {
1039          // This element has no link
1040          // Focus on previous element's btn
1041          prevEl.find("button").focus();
1042        }
1043      } else if (prevEl.hasClass("dropdown")) {
1044        prevEl.find(".menubutton").focus();
1045      } else {
1046        prevEl.find("> a").focus();
1047      }
1048    } else if (e.key === "End") {
1049      e.preventDefault();
1050      if (submenu.length) {
1051        let lastEl = submenu.find("> li").last();
1052        if (lastEl.find("> a").length) {
1053          lastEl.find("> a").focus();
1054        } else {
1055          lastEl.find("> button").focus();
1056        }
1057      } else {
1058        let lastEl = $(this).find("> li").last();
1059        if (lastEl.find("> a").length) {
1060          lastEl.find("> a").focus();
1061        } else {
1062          lastEl.find("> button").focus();
1063        }
1064      }
1065    } else if (e.key === "Home") {
1066      e.preventDefault();
1067      if (submenu.length) {
1068        let firstEl = submenu.find("> li").first();
1069        if (firstEl.find("> a").length) {
1070          firstEl.find("> a").focus();
1071        } else {
1072          firstEl.find("> button").focus();
1073        }
1074      } else {
1075        let firstEl = $(this).find("> li").first();
1076        if (firstEl.find("> a").length) {
1077          firstEl.find("> a").focus();
1078        } else {
1079          firstEl.find("> button").focus();
1080        }
1081      }
1082    }
1083  });
1084
1085  // Mobile Menu
1086  mobileMenu.find("li .menubutton").click(function () {
1087    const submenu = $(this).siblings(".sub-menu.dropdown-menu");
1088    $(this).parent().toggleClass("open");
1089    $(this).toggleClass("open");
1090    $(this).attr("aria-expanded", $(this).attr("aria-expanded") !== "true");
1091    submenu.slideToggle();
1092  });
1093
1094  // Search input //const search = header.find('.nav--mobile .search--form-mobile');
1095  const headerLogo = header.find(".column--header .logo");
1096  const search = header.find(".nav--mobile .icon--search");
1097  const social = header.find(".nav--mobile .nav--social");
1098  const topNav = header.find(".nav--top-mobile");
1099  body.on("keydown", "header.mobile-active", function (e) {
1100    if (
1101      e.key === "Escape" &&
1102      !$(e.target).parents(".sub-menu.dropdown-menu").length
1103    ) {
1104      closeMobile();
1105    } else if (e.key === "Tab" && e.shiftKey) {
1106      // First element shift tab
1107      if (headerLogo.is(":focus")) {
1108        e.preventDefault();
1109        if (search.length) {
1110          search.focus();
1111        }
1112        if (!search && social.length) {
1113          social.find("li:last-of-type a").focus();
1114        } else if (!search && !social && topNav.length) {
1115          topNav.find("li:last-of-type a").focus();
1116        } else {
1117          mobileMenu.find("> li:last-of-type a").focus();
1118        }
1119      }
1120      // Mobile Icon shift tab
1121      else if (mobileIcon.is(":focus")) {
1122        e.preventDefault();
1123        headerLogo.focus();
1124      }
1125    } else if (e.key === "Tab") {
1126      // Logo tab
1127      if (headerLogo.is(":focus")) {
1128        e.preventDefault();
1129        mobileIcon.focus();
1130      }
1131      // Last element tab
1132      // Search input // if (search.length && search.find('button').is(':focus')) {
1133      if (search.length && search.is(":focus")) {
1134        e.preventDefault();
1135        headerLogo.focus();
1136      } else if (
1137        !search &&
1138        social.length &&
1139        social.find("li:last-of-type a").is(":focus")
1140      ) {
1141        e.preventDefault();
1142        headerLogo.focus();
1143      } else if (
1144        !search &&
1145        !social &&
1146        topNav.length &&
1147        topNav.find("li:last-of-type a").is(":focus")
1148      ) {
1149        e.preventDefault();
1150        headerLogo.focus();
1151      } else if (
1152        mobileMenu.find("ul:not(.sub-menu) li:last-of-type a").is(":focus")
1153      ) {
1154        e.preventDefault();
1155        headerLogo.focus();
1156      }
1157    }
1158  });
1159
1160  mobileMenu.on("keydown", function (e) {
1161    let focusEl = $(this).find(":focus").parent();
1162    let submenu = "";
1163    let menuBtn = "";
1164    if (focusEl.parents(".sub-menu.dropdown-menu").length) {
1165      submenu = focusEl.parent(".sub-menu.dropdown-menu");
1166      menuBtn = submenu.siblings(".menubutton");
1167    }
1168
1169    if (e.key === "Escape" && submenu.length > 0) {
1170      submenu.removeClass("open");
1171      submenu.parent().removeClass("open");
1172      submenu.slideToggle();
1173      menuBtn.attr("aria-expanded", "false");
1174    }
1175
1176    if (e.key === "Tab" && submenu.length > 0) {
1177      if (submenu.find("li:last-of-type a").is(":focus") && !e.shiftKey) {
1178        e.preventDefault();
1179        focusEl.parents(".menu-item").next("li").find("> a").focus();
1180      } else if (
1181        e.shiftKey &&
1182        submenu.find("li:first-of-type a").is(":focus")
1183      ) {
1184        e.preventDefault();
1185        menuBtn.focus();
1186      }
1187    }
1188
1189    if (e.key === "ArrowRight" || e.key === "ArrowDown") {
1190      e.preventDefault();
1191      menuBtn = focusEl.find(".menubutton");
1192      if (menuBtn.is(":focus") && menuBtn.attr("aria-expanded") == "true") {
1193        focusEl.find("> ul > li:first > a").focus();
1194      } else if (menuBtn.is(":focus")) {
1195        focusEl.next("li").find("> a").focus();
1196      } else if (focusEl.hasClass("dropdown")) {
1197        focusEl.find("> .menubutton").focus();
1198      } else {
1199        focusEl.next().find("> a").focus();
1200      }
1201    } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
1202      e.preventDefault();
1203      if (focusEl.find(".menubutton").is(":focus")) {
1204        if (focusEl.find("> a").length) {
1205          focusEl.find("> a").focus();
1206        } else {
1207          // if prev is span
1208          focusEl.prev().find(".menubutton").focus();
1209        }
1210      } else if (focusEl.prev().hasClass("dropdown")) {
1211        focusEl.prev().find(".menubutton").focus();
1212      } else {
1213        focusEl.prev().find("> a").focus();
1214      }
1215    } else if (e.key === "End") {
1216      e.preventDefault();
1217      if (!submenu.length) {
1218        $(this).find("li").last().find("> a").focus();
1219      } else {
1220        submenu.find("li").last().find("> a").focus();
1221      }
1222    } else if (e.key === "Home") {
1223      e.preventDefault();
1224      if (!submenu.length) {
1225        $(this).find("li").first().find("> a").focus();
1226      } else {
1227        submenu.find("li").first().find("> a").focus();
1228      }
1229    }
1230  });
1231
1232  // --------------------------------------------------------- //
1233
1234  // ----- Custom Select ----- //
1235  var x, i, j, l, ll, selElmnt, a, b, c;
1236  /* Look for any elements with the class "custom-select": */
1237  x = document.getElementsByClassName("select--custom");
1238  l = x.length;
1239  const customSVG =
1240    '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="8" viewBox="0 0 16 8" fill="none"><path d="M1.38321 0.812802L8.16101 3.85656L14.5704 0.684278C15.308 0.34142 16 0.598469 16 1.32728L16 1.92756C16 2.27042 15.7231 2.52747 15.4466 2.69909L8.62248 7.37171C8.3456 7.54333 7.88453 7.62914 7.51575 7.37171L0.368773 2.91342C0.184183 2.7849 -8.90132e-08 2.57056 -7.58935e-08 2.27042L-4.02854e-08 1.4558C-8.42817e-09 0.726993 0.645253 0.512659 1.38321 0.812802Z" fill="currentColor"/></svg>';
1241  for (i = 0; i < l; i++) {
1242    selElmnt = x[i].getElementsByTagName("select")[0];
1243    ll = selElmnt.length;
1244    elmntID = x[i].getAttribute("data-selectid");
1245
1246    /* For each element, create a new DIV that will act as the selected item: */
1247    a = document.createElement("BUTTON");
1248    a.setAttribute("id", elmntID + "_selected");
1249    a.setAttribute("class", "select-selected");
1250    a.setAttribute("aria-controls", elmntID + "_options");
1251    a.setAttribute("aria-haspopup", elmntID + "_options");
1252    a.setAttribute("aria-expanded", "false");
1253    a.setAttribute("aria-label", "filter displayed items");
1254    a.setAttribute("role", "combobox");
1255
1256    a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
1257    a.setAttribute("value", a.innerHTML);
1258    x[i].appendChild(a);
1259    a.innerHTML += customSVG;
1260    /* For each element, create a new DIV that will contain the option list: */
1261    b = document.createElement("UL");
1262    b.setAttribute("class", "select-items select-hide");
1263    b.setAttribute("id", elmntID + "_options");
1264    b.setAttribute("role", "listbox");
1265
1266    for (j = 1; j < ll; j++) {
1267      /* For each option in the original select element,
1268      create a new DIV that will act as an option item: */
1269      c = document.createElement("LI");
1270      c.setAttribute("role", "option");
1271      c.setAttribute("tabindex", 0);
1272      c.innerHTML = selElmnt.options[j].innerHTML;
1273      c.addEventListener("click", function (e) {
1274        /* When an item is clicked, update the original select box,
1275          and the selected item: */
1276        var y, i, k, s, h, sl, yl;
1277        s = this.parentNode.parentNode.getElementsByTagName("select")[0];
1278        sl = s.length;
1279        h = this.parentNode.previousSibling;
1280        for (i = 0; i < sl; i++) {
1281          if (s.options[i].innerHTML == this.innerHTML) {
1282            s.selectedIndex = i;
1283            h.innerHTML = this.innerHTML;
1284            a.setAttribute("value", this.innerHTML);
1285            h.innerHTML += customSVG;
1286            y = this.parentNode.getElementsByClassName("same-as-selected");
1287            yl = y.length;
1288            for (k = 0; k < yl; k++) {
1289              y[k].removeAttribute("class");
1290            }
1291            this.setAttribute("class", "same-as-selected");
1292            break;
1293          }
1294        }
1295        h.click();
1296      });
1297      b.appendChild(c);
1298    }
1299    x[i].appendChild(b);
1300    a.addEventListener("click", function (e) {
1301      /* When the select box is clicked, close any other select boxes,
1302      and open/close the current select box: */
1303      e.stopPropagation();
1304      closeAllSelect(this);
1305      this.nextSibling.classList.toggle("select-hide");
1306      this.classList.toggle("select-arrow-active");
1307      this.setAttribute(
1308        "aria-expanded",
1309        this.getAttribute("aria-expanded") === "false"
1310      );
1311    });
1312
1313    a.addEventListener("keydown", function (e) {
1314      const isOpen = $(this).attr("aria-expanded") === "true";
1315
1316      if (isOpen) {
1317        if (e.key === "ArrowDown") {
1318          e.preventDefault();
1319          // Skip the placeholder el and focus on the first dropdown el
1320          $(this).next().find("li:nth-of-type(2)").focus();
1321        } else if (e.key === "ArrowUp") {
1322          e.preventDefault();
1323          $(this).next().find("li:last").focus();
1324        } else if (e.key === "Escape") {
1325          // Esc
1326          e.preventDefault();
1327          closeAllSelect($(this));
1328          $(a).focus();
1329        }
1330      } else {
1331        if (e.key === "ArrowUp" || e.key === "ArrowDown") {
1332          // Arrow up || Arrow down
1333          e.preventDefault();
1334          this.nextSibling.classList.toggle("select-hide");
1335          this.classList.toggle("select-arrow-active");
1336          this.setAttribute(
1337            "aria-expanded",
1338            this.getAttribute("aria-expanded") === "false"
1339          );
1340        }
1341      }
1342      let i = 1;
1343    });
1344    b.addEventListener("keydown", function selListKeydown(e) {
1345      const currentEl = $(this).find("li:focus");
1346      if (e.key === "Escape") {
1347        e.preventDefault();
1348        closeAllSelect();
1349        $(a).focus();
1350      } else if (e.key === "Enter") {
1351        e.preventDefault();
1352        currentEl.trigger("click");
1353        a.focus();
1354      } else if (e.key === "ArrowDown") {
1355        e.preventDefault();
1356        if (currentEl.is(":last-child")) {
1357          $(b).find("li:nth-of-type(2)").focus();
1358        } else {
1359          currentEl.next().focus();
1360        }
1361      } else if (e.key === "ArrowUp") {
1362        e.preventDefault();
1363        if (currentEl.is(":nth-of-type(2)")) {
1364          $(b).find("li:last").focus();
1365        } else {
1366          currentEl.prev().focus();
1367        }
1368      } else if (
1369        e.key === "Tab" &&
1370        e.shiftKey &&
1371        currentEl.is(":nth-of-type(2):focus")
1372      ) {
1373        e.preventDefault();
1374        $(b).find("li:last").focus();
1375      } else if (
1376        e.key === "Tab" &&
1377        !e.shiftKey &&
1378        currentEl.is(":last-child:focus")
1379      ) {
1380        e.preventDefault();
1381        $(b).find("li:nth-of-type(2)").focus();
1382      }
1383    });
1384  }
1385
1386  function closeAllSelect(elmnt) {
1387    /* A function that will close all select boxes in the document,
1388    except the current select box: */
1389    var x,
1390      y,
1391      i,
1392      xl,
1393      yl,
1394      arrNo = [];
1395    x = document.getElementsByClassName("select-items");
1396    y = document.getElementsByClassName("select-selected");
1397    xl = x.length;
1398    yl = y.length;
1399    for (i = 0; i < yl; i++) {
1400      if (elmnt == y[i]) {
1401        arrNo.push(i);
1402      } else {
1403        y[i].classList.remove("select-arrow-active");
1404        y[i].setAttribute("aria-expanded", "false");
1405      }
1406    }
1407    for (i = 0; i < xl; i++) {
1408      if (arrNo.indexOf(i)) {
1409        x[i].classList.add("select-hide");
1410      }
1411    }
1412  }
1413  /* If the user clicks anywhere outside the select box,
1414  then close all select boxes: */
1415  document.addEventListener("click", closeAllSelect);
1416  // --------------------------------------------------------- //
1417});

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.