- for (var i = 0; i < queryitems.length; i++) {
- if (match = queryitems[i].match(/^(.*)=(.*)$/)) {
- args[unescape(match[1])] = unescape(match[2]);
+$(document).ready(function () {
+ // NB: Turns Turbo Drive off by default. Turbo Drive must be opt-in on a per-link and per-form basis
+ // See https://turbo.hotwired.dev/reference/drive#turbo.session.drive
+ Turbo.session.drive = false;
+
+ const $expandedSecondaryMenu = $("header nav.secondary > ul"),
+ $collapsedSecondaryMenu = $("#compact-secondary-nav > ul"),
+ secondaryMenuItems = [],
+ breakpointWidth = 768;
+ let moreItemWidth = 0;
+
+ function updateHeader() {
+ const windowWidth = $(window).width();
+
+ if (windowWidth < breakpointWidth) {
+ $("body").addClass("small-nav");
+ expandAllSecondaryMenuItems();
+ } else {
+ $("body").removeClass("small-nav");
+ const availableWidth = $expandedSecondaryMenu.width();
+ secondaryMenuItems.forEach(function (item) {
+ $(item[0]).remove();
+ });
+ let runningWidth = 0,
+ i = 0,
+ requiredWidth;
+ for (; i < secondaryMenuItems.length; i++) {
+ runningWidth += secondaryMenuItems[i][1];
+ if (i < secondaryMenuItems.length - 1) {
+ requiredWidth = runningWidth + moreItemWidth;