PageSourceSearch

https://omni-templates.untsystem.edu/_resources-redesign/js/scripts.js

js untsystem.edu collected 2026-10-03 22:02:07 UTC 7,367 bytes, 249 lines download raw bytes

1//Adds auto focus to search when opened
2$("#siteSearch").on("shown.bs.modal", function () {
3  $("body").addClass("modal-open-search");
4  $("#siteSearch .form-text").focus();
5});
6$("#siteSearch").on("hide.bs.modal", function () {
7  $("body").removeClass("modal-open-search");
8});
9
10$("#site-navigation").on("shown.bs.modal", function () {
11  $("body").addClass("modal-open-menu-mobile");
12});
13$("#site-navigation").on("hide.bs.modal", function () {
14  $("body").removeClass("modal-open-menu-mobile");
15});
16
17jQuery(document).ready(function ($) {
18  var alterClass = function () {
19    var ww = document.body.clientWidth;
20    if (ww >= 1200) {
21      $(".modal").modal("hide");
22    }
23  };
24  $(window).resize(function () {
25    alterClass();
26  });
27  //Fire it when the page first loads:
28  alterClass();
29});
30
31//Scroll to top button
32jQuery(document).ready(function ($) {
33  // browser window scroll (in pixels) after which the "back to top" link is shown
34  var offset = 300,
35    //browser window scroll (in pixels) after which the "back to top" link opacity is reduced
36    offset_opacity = 1200,
37    //duration of the top scrolling animation (in ms)
38    scroll_top_duration = 700,
39    //grab the "back to top" link
40    $back_to_top = $(".cd-top");
41
42  //hide or show the "back to top" link
43  $(window).scroll(function () {
44    $(this).scrollTop() > offset
45      ? $back_to_top.addClass("cd-is-visible")
46      : $back_to_top.removeClass("cd-is-visible cd-fade-out");
47    if ($(this).scrollTop() > offset_opacity) {
48      $back_to_top.addClass("cd-fade-out");
49    }
50  });
51
52  //smooth scroll to top
53  $back_to_top.on("click", function (event) {
54    event.preventDefault();
55    $("body,html").animate(
56      {
57        scrollTop: 0,
58      },
59      scroll_top_duration
60    );
61  });
62});
63
64$(document).ready(function () {
65  document.getElementById("year").innerHTML = new Date().getFullYear();
66});
67
68$(document).ready(function () {
69  // Select all links with hashes
70  $('a[href*="#"]')
71    // Remove links that don't actually link to anything
72    .not('[href="#"]')
73    .not('[href="#0"]')
74    .not("[data-bs-toggle]")
75    .click(function (event) {
76      // On-page links
77      if (
78        location.pathname.replace(/^\//, "") ===
79        this.pathname.replace(/^\//, "") &&
80        location.hostname === this.hostname
81      ) {
82        // Figure out element to scroll to
83        var target = $(this.hash);
84        target = target.length
85          ? target
86          : $("[name=" + this.hash.slice(1) + "]");
87        // Does a scroll target exist?
88        if (target.length) {
89          // Only prevent default if animation is actually gonna happen
90          event.preventDefault();
91          $("html, body").animate(
92            {
93              scrollTop: target.offset().top,
94            },
95            1000,
96            function () {
97              // Callback after animation
98              // Must change focus!
99              var $target = $(target);
100              $target.focus();
101              if ($target.is(":focus")) {
102                // Checking if the target was focused
103                return false;
104              } else {
105                $target.attr("tabindex", "-1"); // Adding tabindex for elements not focusable
106                $target.focus(); // Set focus again
107              }
108            }
109          );
110        }
111      }
112    });
113});
114
115document.addEventListener("DOMContentLoaded", function () {
116  "use strict";
117
118  var cookieAlert = document.querySelector(".cookiealert");
119  var acceptCookies = document.querySelector(".acceptcookies");
120
121  if (!cookieAlert) {
122    return;
123  }
124
125  cookieAlert.offsetHeight; // Force browser to trigger reflow (https://stackoverflow.com/a/39451131)
126
127  // Show the alert if we can't find the "acceptCookies" cookie
128  if (!getCookie("acceptCookies")) {
129    cookieAlert.classList.add("show");
130  }
131
132  // When clicking on the agree button, create a 1 year
133  // cookie to remember the user's choice and close the banner
134  acceptCookies.addEventListener("click", function () {
135    setCookie("acceptCookies", true, 365);
136    cookieAlert.classList.remove("show");
137  });
138
139  // Cookie functions from w3schools
140  function setCookie(cname, cvalue, exdays) {
141    var d = new Date();
142    d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
143    var expires = "expires=" + d.toUTCString();
144    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
145  }
146
147  function getCookie(cname) {
148    var name = cname + "=";
149    var decodedCookie = decodeURIComponent(document.cookie);
150    var ca = decodedCookie.split(";");
151    for (var i = 0; i < ca.length; i++) {
152      var c = ca[i];
153      while (c.charAt(0) === " ") {
154        c = c.substring(1);
155      }
156      if (c.indexOf(name) === 0) {
157        return c.substring(name.length, c.length);
158      }
159    }
160    return "";
161  }
162});
163
164
165
166function hasTouch() {
167  return (
168    "ontouchstart" in document.documentElement ||
169    navigator.maxTouchPoints > 0 ||
170    navigator.msMaxTouchPoints > 0
171  );
172}
173
174if (hasTouch()) {
175  // remove all the :hover stylesheets
176  try {
177    // prevent exception on browsers not supporting DOM styleSheets properly
178    for (var si in document.styleSheets) {
179      var styleSheet = document.styleSheets[si];
180      if (!styleSheet.rules) continue;
181
182      for (var ri = styleSheet.rules.length - 1; ri >= 0; ri--) {
183        if (!styleSheet.rules[ri].selectorText) continue;
184
185        if (styleSheet.rules[ri].selectorText.match(":hover")) {
186          styleSheet.deleteRule(ri);
187        }
188      }
189    }
190  } catch (ex) { }
191}
192
193// reset sidenav when pasing breakpoint
194window.addEventListener("DOMContentLoaded", function () {
195  const sidenavHeading = document.querySelector(
196    ".sidenav-accordion .sidenav-heading"
197  );
198  const accordionMainCollapse = document.querySelector(
199    ".sidenav-accordion .accordion-main-collapse"
200  );
201
202  if (!sidenavHeading || !accordionMainCollapse) return;
203
204  const mediaQuery = window.matchMedia("(min-width: 992px)");
205
206  function handleToggle() {
207    if (mediaQuery.matches) {
208      // Desktop view: show and disable toggling
209      accordionMainCollapse.classList.add("show", "collapse");
210      accordionMainCollapse.classList.remove("collapsing");
211      accordionMainCollapse.style.height = "";
212      sidenavHeading.removeAttribute("data-bs-toggle");
213      sidenavHeading.setAttribute("aria-expanded", "true");
214    } else {
215      // Mobile view: collapse and allow toggling
216      accordionMainCollapse.classList.remove("show");
217      accordionMainCollapse.classList.add("collapse");
218      accordionMainCollapse.classList.remove("collapsing");
219      accordionMainCollapse.style.height = "";
220      sidenavHeading.setAttribute("data-bs-toggle", "collapse");
221      sidenavHeading.setAttribute("aria-expanded", "false");
222    }
223  }
224
225  handleToggle();
226  mediaQuery.addEventListener("change", handleToggle);
227});
228
229
230
231// Hero Video Play/Pause Toggle
232$(document).ready(function () {
233  const $playPauseButton = $('.play-pause');
234  const heroVideo = document.getElementById("heroVideo");
235
236  if ($playPauseButton.length && heroVideo) {
237    let isPlaying = true;
238    $playPauseButton.on('click', function () {
239      if (isPlaying) {
240        heroVideo.pause();
241        $(this).html("<span class='fa fa-play'></span>");
242      } else {
243        heroVideo.play();
244        $(this).html("<span class='fa fa-pause'></span>");
245      }
246      isPlaying = !isPlaying;
247    });
248  }
249});

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.