+ function expandAllSecondaryMenuItems() {
+ secondaryMenuItems.forEach(function (item) {
+ expandSecondaryMenuItem($(item[0]));
+ });
+ }
+
+ function expandSecondaryMenuItem($item) {
+ $item.children("a")
+ .removeClass("dropdown-item")
+ .addClass("nav-link")
+ .addClass(function () {
+ return $(this).hasClass("active") ? "text-secondary-emphasis" : "text-secondary";
+ });
+ $item.addClass("nav-item").insertBefore("#compact-secondary-nav");
+ toggleCompactSecondaryNav();
+ }
+
+ 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();