+ function collapseSecondaryMenuItem($item) {
+ $item.children("a")
+ .addClass("dropdown-item")
+ .removeClass("nav-link text-secondary text-secondary-emphasis");
+ $item.removeClass("nav-item").appendTo($collapsedSecondaryMenu);
+ toggleCompactSecondaryNav();
+ }
+
+ function toggleCompactSecondaryNav() {
+ $("#compact-secondary-nav").toggle(
+ $collapsedSecondaryMenu.find("li").length > 0
+ );
+ }
+
+ /*
+ * Chrome 60 and later seem to fire the "ready" callback
+ * before the DOM is fully ready causing us to measure the
+ * wrong sizes for the header elements - use a 0ms timeout
+ * to defer the measurement slightly as a workaround.
+ */
+ setTimeout(function () {
+ $expandedSecondaryMenu.find("li:not(#compact-secondary-nav)").each(function () {
+ secondaryMenuItems.push([this, $(this).width()]);
+ });
+ moreItemWidth = $("#compact-secondary-nav").width();
+
+ updateHeader();
+
+ $(window).resize(updateHeader);
+ $(document).on("turbo:render", updateHeader);
+ }, 0);
+
+ $("#menu-icon").on("click", function (e) {