Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="page">
  
  <header role="banner">
    <div class="title">Globalis Media Systems</div>
    <div class="tagline">Accélérateur de projets digitaux</div>
  </header>
  <nav aria-label="Mythical University">
    <ul class="menubar-navigation" role="menubar" aria-label="Mythical University">
      <li role="none">
        <a role="menuitem" href="#home">
          Home
        </a>
      </li>
      <li role="none">
        <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#about">
          About
          <svg xmlns="http://www.w3.org/2000/svg" class="down" width="12" height="9" viewBox="0 0 12 9">
           <polygon points="1 0, 11 0, 6 8"></polygon>
          </svg>
        </a>
        <ul role="menu" aria-label="About">
          <li role="none">
            <a role="menuitem" href="#overview">Overview</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#administration">Administration</a>
          </li>
          <li role="none">
            <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#facts">
              Facts
              <svg xmlns="http://www.w3.org/2000/svg" class="right" width="9" height="12" viewBox="0 0 9 12">
               <polygon points="0 1, 0 11, 8 6"></polygon>
              </svg>
            </a>
            <ul role="menu" aria-label="Facts">
              <li role="none">
                <a role="menuitem" href="#history">History</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#current-statistics">Current Statistics</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#awards">Awards</a>
              </li>
            </ul>
          </li>
          <li role="none">
            <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#campus-tours">
              Campus Tours
              <svg xmlns="http://www.w3.org/2000/svg" class="right" width="9" height="12" viewBox="0 0 9 12">
               <polygon points="0 1, 0 11, 8 6"></polygon>
              </svg>
            </a>
            <ul role="menu" aria-label="Campus Tours">
              <li role="none">
                <a role="menuitem" href="#for-prospective-students">For prospective students</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#for-alumni">For alumni</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#for-visitors">For visitors</a>
              </li>
            </ul>
          </li>
        </ul>
      </li>
      <li role="none">
        <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#admissions">
          Tech
          <svg xmlns="http://www.w3.org/2000/svg" class="down" width="12" height="9" viewBox="0 0 12 9">
           <polygon points="1 0, 11 0, 6 8"></polygon>
          </svg>
        </a>
        <ul role="menu" aria-label="Admissions">
          <li role="none">
            <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#tuition">
              Tuition
              <svg xmlns="http://www.w3.org/2000/svg" class="right" width="9" height="12" viewBox="0 0 9 12">
               <polygon points="0 1, 0 11, 8 6"></polygon>
              </svg>
            </a>
            <ul role="menu" aria-label="Tuition">
              <li role="none">
                <a role="menuitem" href="#undergraduate">Undergraduate</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#graduate">Graduate</a>
              </li>
              <li role="none">
                <a role="menuitem" href="#professional-schools">Professional Schools</a>
              </li>
            </ul>
          </li>
          <li role="none">
            <a role="menuitem" href="#sign-up">Sign Up</a>
          </li>
          <li role="separator"></li>
          <li role="none">
            <a role="menuitem" href="#visit">Visit</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#photo-tour">Photo Tour</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#connect">Connect</a>
          </li>
        </ul>
      </li>
      <li role="none">
        <a role="menuitem" aria-haspopup="true" aria-expanded="false" href="#academics">
          News
          <svg xmlns="http://www.w3.org/2000/svg" class="down" width="12" height="9" viewBox="0 0 12 9">
           <polygon points="1 0, 11 0, 6 8"></polygon>
          </svg>
        </a>
        <ul role="menu" id="sub-menu-academics" aria-label="Academics">
          <li role="none">
            <a role="menuitem" href="#colleges-and-schools">Colleges &amp; Schools</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#programs-of-study">Programs of Study</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#honors-programs">Honors Programs</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#online-courses">Online Courses</a>
          </li>
          <li role="separator"></li>
          <li role="none">
            <a role="menuitem" href="#course-explorer">Course Explorer</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#register-for-class">Register for Class</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#academic-calendar">Academic Calendar</a>
          </li>
          <li role="none">
            <a role="menuitem" href="#tanscripts">Transcripts</a>
          </li>
        </ul>
      </li>
    </ul>
  </nav>
  
  <div class="main">
    <section aria-labelledby="id-page-title">
      <h1 id="id-page-title" class="page_title">Mythical University</h1>
      <div class="content">
        <p></p>
      </div>
    </section>
  </div>
    
  <footer role="contentinfo">
    Copyright Ⓒ Globalis 2022 - Mentions Légales
  </footer>
 </div>
    
              
            
!

CSS

              
                @charset "utf-8";

.page {
   justify-content: center;
}

.page header {
  border: rgb(48, 75, 149) solid 2px;
  background: rgb(48, 75, 149);
  color: white;
  text-align: center;
  padding: 1em;
}

.page header .title {
  font-size: 2.5em;
  font-weight: bold;
  font-family: serif;
}

.page header .tagline {
  font-style: italic;
}

.page .main {
  padding: 1em 5% 5em;
  border-left: 2px solid #eee;
  border-right: 2px solid #eee;
}

.page footer {
  display: flex;
  border: rgb(48, 75, 149) solid 2px;
  background: rgb(48, 75, 149);
  font-family: serif;
  color: white;
  font-style: italic;
  padding: 1em;
  justify-content: center;
}

.page nav {
  margin: 0;
  padding: 0;
  border: 2px solid #eee;
}

.menubar-navigation {
  margin: 0;
  padding: 2px;
  font-size: 110%;
  list-style: none;
  background-color: #eee;
  border: #eee solid 1px;
}

.menubar-navigation li {
  margin: 0;
  padding: 0;
  border: 0 solid black;
  list-style: none;
}

.menubar-navigation > li {
  display: inline-block;
  position: relative;
}

.menubar-navigation > li li {
  display: block;
}

.menubar-navigation > li > [role="menuitem"] {
  display: inline-block;
  margin: 2px;
  padding: 4px;
  padding-bottom: 8px;
  background-color: #eee;
  border: 0 solid #eee;
  color: black;
}

.menubar-navigation [role="separator"] {
  padding-top: 3px;
  background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cline x1='0' y1='6' x2='12' y2='6' style='stroke:black;stroke-width:1' /%3E%3C/svg%3E%0A");
  background-size: 10px 10px;
  background-position: center;
  background-repeat: repeat-x;
}

.menubar-navigation [role="menu"] [role="menuitem"],
.menubar-navigation [role="menu"] [role="separator"] {
  display: block;
  width: 12em;
  margin: 2px;
  padding: 4px;
  padding-left: 8px;
  background-color: #eee;
  border: 0 solid #eee;
  color: black;
}

.menubar-navigation [role="menuitem"] svg {
  fill: currentcolor;
  stroke: currentcolor;
}

.menubar-navigation [role="menuitem"] svg.down {
  padding-left: 0.125em;
}

.menubar-navigation [role="menuitem"] svg.right {
  position: absolute;
  padding-top: 0.35em;
  right: 0.75em;
}

.menubar-navigation [role="menuitem"][aria-expanded="true"] svg.down {
  transform: rotate(180deg);
}

.menubar-navigation [role="menuitem"][aria-expanded="true"] svg.right {
  transform: rotate(90deg) translate(5px, -5px);
}

.menubar-navigation [role="menu"] {
  display: none;
  position: absolute;
  margin: 0;
  padding: 0;
  padding: 7px 4px;
  border: 2px solid rgb(48, 75, 149);
  background-color: #eee;
}

.menubar-navigation [role="group"] {
  margin: 0;
  padding: 0;
}

/* aria-current styling */

.menubar-navigation > li > [role="menuitem"][aria-current],
.menubar-navigation > li > [role="menuitem"].aria-current-path {
  padding-bottom: 2px;
  border-bottom: 4px solid rgb(48,             75, 149);
}

.menubar-navigation [role="menu"] [role="menuitem"].aria-current-path,
.menubar-navigation [role="menu"] [role="menuitem"][aria-current] {
  padding-left: 4px;
  border-left: 4px solid rgb(48, 75,                149);
}

/* focus styling */

.menubar-navigation.focus {
  padding: 0;
  border: rgb(48, 75, 149) solid 3px;
}

.menubar-navigation > li > [aria-expanded="true"],
.menubar-navigation > li > [role="menuitem"]:focus,
.menubar-navigation > li > [role="menuitem"]:hover {
  outline: none;
  background-color: #ccc;
}

.menubar-navigation > li > [role="menuitem"]:focus,
.menubar-navigation > li > [role="menuitem"]:hover {
  padding: 2px;
  padding-bottom: 4px;
  border: 2px solid rgb(48, 75, 149);
}

.menubar-navigation [role="menu"] [aria-expanded="true"],
.menubar-navigation [role="menu"] [role="menuitem"]:focus,
.menubar-navigation [role="menu"] [role="menuitem"]:hover {
  outline: none;
  background-color: #ccc;
}

.menubar-navigation [role="menu"] [role="menuitem"]:focus,
.menubar-navigation [role="menu"] [role="menuitem"]:hover {
  padding: 2px;
  padding-left: 6px;
  border: 2px solid  rgb(48, 75, 149);
}

.menubar-navigation > li > [aria-expanded="true"].aria-current-path,
.menubar-navigation > li > [role="menuitem"].aria-current-path:focus,
.menubar-navigation > li > [role="menuitem"].aria-current-path:hover,
.menubar-navigation > li > [role="menuitem"][aria-current]:focus,
.menubar-navigation > li > [role="menuitem"][aria-current]:hover {
  padding-bottom: 2px;
  border-bottom: 4px solid rgb(48, 75, 149);
}

.menubar-navigation [role="menu"] [aria-expanded="true"].aria-current-path,
.menubar-navigation [role="menu"] [role="menuitem"].aria-current-path:focus,
.menubar-navigation [role="menu"] [role="menuitem"].aria-current-path:hover,
.menubar-navigation [role="menu"] [role="menuitem"][aria-current]:focus,
.menubar-navigation [role="menu"] [role="menuitem"][aria-current]:hover {
  padding-left: 4px;
  border-left: 4px solid rgb(48, 75, 149);
}

              
            
!

JS

              
                'use strict';

class NavigationContentGenerator {
  constructor(siteURL, siteName) {
    this.siteName = siteName;
    this.siteURL = siteURL;
    this.fillerTextSentences = [];

    this.fillerTextSentences.push(
      'The content on this page is associated with the <a href="$linkURL">$linkName</a> link for <a href="$siteURL">$siteName</a>.'
    );
  }

  renderParagraph(linkURL, linkName) {
    var content = '';
    this.fillerTextSentences.forEach(
      (s) =>
        (content += s
          .replace('$siteName', this.siteName)
          .replace('$siteURL', this.siteURL)
          .replace('$linkName', linkName)
          .replace('$linkURL', linkURL))
    );
    return content;
  }
}

class MenubarNavigation {
  constructor(domNode) {
    var linkURL, linkTitle;

    this.domNode = domNode;

    this.menuitems = [];
    this.popups = [];
    this.menuitemGroups = {};
    this.menuOrientation = {};
    this.isPopup = {};
    this.isPopout = {};
    this.openPopups = false;

    this.firstChars = {}; // see Menubar init method
    this.firstMenuitem = {}; // see Menubar init method
    this.lastMenuitem = {}; // see Menubar init method

    this.initMenu(domNode, 0);

    domNode.addEventListener('focusin', this.onMenubarFocusin.bind(this));
    domNode.addEventListener('focusout', this.onMenubarFocusout.bind(this));

    window.addEventListener(
      'pointerdown',
      this.onBackgroundPointerdown.bind(this),
      true
    );

    domNode.querySelector('[role=menuitem]').tabIndex = 0;

    // Initial content for page
    if (location.href.split('#').length > 1) {
      linkURL = location.href;
      linkTitle = getLinkNameFromURL(location.href);
    } else {
      linkURL = location.href + '#home';
      linkTitle = 'Home';
    }

    this.contentGenerator = new NavigationContentGenerator(
      '#home',
      'Mythical University'
    );
    this.updateContent(linkURL, linkTitle, false);

    function getLinkNameFromURL(url) {
      function capitalize(str) {
        return str.charAt(0).toUpperCase() + str.slice(1);
      }

      var name = url.split('#')[1];
      if (typeof name === 'string') {
        name = name.split('-').map(capitalize).join(' ');
      } else {
        name = 'Home';
      }
      return name;
    }
  }

  getParentMenuitem(menuitem) {
    var node = menuitem.parentNode;
    if (node) {
      node = node.parentNode;
      if (node) {
        node = node.previousElementSibling;
        if (node) {
          if (node.getAttribute('role') === 'menuitem') {
            return node;
          }
        }
      }
    }
    return false;
  }

  updateContent(linkURL, linkName, moveFocus) {
    var h1Node, paraNodes, pathNode;

    if (typeof moveFocus !== 'boolean') {
      moveFocus = true;
    }

    // Update content area
    h1Node = document.querySelector('.page .main h1');
    if (h1Node) {
      h1Node.textContent = linkName;
      h1Node.tabIndex = -1;
      if (moveFocus) {
        h1Node.focus();
      }
    }
    paraNodes = document.querySelectorAll('.page .main p');
    paraNodes.forEach(
      (p) =>
        (p.innerHTML = this.contentGenerator.renderParagraph(linkURL, linkName))
    );

    // Update aria-current
    this.menuitems.forEach((item) => {
      item.removeAttribute('aria-current');
      item.classList.remove('aria-current-path');
      item.title = '';
    });

    this.menuitems.forEach((item) => {
      if (item.href === linkURL) {
        item.setAttribute('aria-current', 'page');
        pathNode = this.getParentMenuitem(item);
        while (pathNode) {
          pathNode.classList.add('aria-current-path');
          pathNode.title = 'Contains current page link';
          pathNode = this.getParentMenuitem(pathNode);
        }
      }
    });
  }

  getMenuitems(domNode, depth) {
    var nodes = [];

    var initMenu = this.initMenu.bind(this);
    var popups = this.popups;

    function findMenuitems(node) {
      var role, flag;

      while (node) {
        flag = true;
        role = node.getAttribute('role');

        if (role) {
          role = role.trim().toLowerCase();
        }

        switch (role) {
          case 'menu':
            node.tabIndex = -1;
            initMenu(node, depth + 1);
            flag = false;
            break;

          case 'menuitem':
            if (node.getAttribute('aria-haspopup') === 'true') {
              popups.push(node);
            }
            nodes.push(node);
            break;

          default:
            break;
        }

        if (
          flag &&
          node.firstElementChild &&
          node.firstElementChild.tagName !== 'svg'
        ) {
          findMenuitems(node.firstElementChild);
        }
        node = node.nextElementSibling;
      }
    }
    findMenuitems(domNode.firstElementChild);
    return nodes;
  }

  initMenu(menu, depth) {
    var menuitems, menuitem, role;

    var menuId = this.getMenuId(menu);

    menuitems = this.getMenuitems(menu, depth);
    this.menuOrientation[menuId] = this.getMenuOrientation(menu);

    this.isPopup[menuId] = menu.getAttribute('role') === 'menu' && depth === 1;
    this.isPopout[menuId] = menu.getAttribute('role') === 'menu' && depth > 1;

    this.menuitemGroups[menuId] = [];
    this.firstChars[menuId] = [];
    this.firstMenuitem[menuId] = null;
    this.lastMenuitem[menuId] = null;

    for (var i = 0; i < menuitems.length; i++) {
      menuitem = menuitems[i];
      role = menuitem.getAttribute('role');

      if (role.indexOf('menuitem') < 0) {
        continue;
      }

      menuitem.tabIndex = -1;
      this.menuitems.push(menuitem);
      this.menuitemGroups[menuId].push(menuitem);
      this.firstChars[menuId].push(
        menuitem.textContent.trim().toLowerCase()[0]
      );

      menuitem.addEventListener('keydown', this.onKeydown.bind(this));
      menuitem.addEventListener('click', this.onMenuitemClick.bind(this), {
        capture: true,
      });

      menuitem.addEventListener(
        'pointerover',
        this.onMenuitemPointerover.bind(this)
      );

      if (!this.firstMenuitem[menuId]) {
        if (this.hasPopup(menuitem)) {
          menuitem.tabIndex = 0;
        }
        this.firstMenuitem[menuId] = menuitem;
      }
      this.lastMenuitem[menuId] = menuitem;
    }
  }

  setFocusToMenuitem(menuId, newMenuitem) {
    this.closePopupAll(newMenuitem);

    if (this.menuitemGroups[menuId]) {
      this.menuitemGroups[menuId].forEach(function (item) {
        if (item === newMenuitem) {
          item.tabIndex = 0;
          newMenuitem.focus();
        } else {
          item.tabIndex = -1;
        }
      });
    }
  }

  setFocusToFirstMenuitem(menuId) {
    this.setFocusToMenuitem(menuId, this.firstMenuitem[menuId]);
  }

  setFocusToLastMenuitem(menuId) {
    this.setFocusToMenuitem(menuId, this.lastMenuitem[menuId]);
  }

  setFocusToPreviousMenuitem(menuId, currentMenuitem) {
    var newMenuitem, index;

    if (currentMenuitem === this.firstMenuitem[menuId]) {
      newMenuitem = this.lastMenuitem[menuId];
    } else {
      index = this.menuitemGroups[menuId].indexOf(currentMenuitem);
      newMenuitem = this.menuitemGroups[menuId][index - 1];
    }

    this.setFocusToMenuitem(menuId, newMenuitem);

    return newMenuitem;
  }

  setFocusToNextMenuitem(menuId, currentMenuitem) {
    var newMenuitem, index;

    if (currentMenuitem === this.lastMenuitem[menuId]) {
      newMenuitem = this.firstMenuitem[menuId];
    } else {
      index = this.menuitemGroups[menuId].indexOf(currentMenuitem);
      newMenuitem = this.menuitemGroups[menuId][index + 1];
    }
    this.setFocusToMenuitem(menuId, newMenuitem);

    return newMenuitem;
  }

  setFocusByFirstCharacter(menuId, currentMenuitem, char) {
    var start, index;

    char = char.toLowerCase();

    // Get start index for search based on position of currentItem
    start = this.menuitemGroups[menuId].indexOf(currentMenuitem) + 1;
    if (start >= this.menuitemGroups[menuId].length) {
      start = 0;
    }

    // Check remaining slots in the menu
    index = this.getIndexFirstChars(menuId, start, char);

    // If not found in remaining slots, check from beginning
    if (index === -1) {
      index = this.getIndexFirstChars(menuId, 0, char);
    }

    // If match was found...
    if (index > -1) {
      this.setFocusToMenuitem(menuId, this.menuitemGroups[menuId][index]);
    }
  }

  // Utilities

  getIndexFirstChars(menuId, startIndex, char) {
    for (var i = startIndex; i < this.firstChars[menuId].length; i++) {
      if (char === this.firstChars[menuId][i]) {
        return i;
      }
    }
    return -1;
  }

  isPrintableCharacter(str) {
    return str.length === 1 && str.match(/\S/);
  }

  getIdFromAriaLabel(node) {
    var id = node.getAttribute('aria-label');
    if (id) {
      id = id.trim().toLowerCase().replace(' ', '-').replace('/', '-');
    }
    return id;
  }

  getMenuOrientation(node) {
    var orientation = node.getAttribute('aria-orientation');

    if (!orientation) {
      var role = node.getAttribute('role');

      switch (role) {
        case 'menubar':
          orientation = 'horizontal';
          break;

        case 'menu':
          orientation = 'vertical';
          break;

        default:
          break;
      }
    }

    return orientation;
  }

  getMenuId(node) {
    var id = false;
    var role = node.getAttribute('role');

    while (node && role !== 'menu' && role !== 'menubar') {
      node = node.parentNode;
      if (node) {
        role = node.getAttribute('role');
      }
    }

    if (node) {
      id = role + '-' + this.getIdFromAriaLabel(node);
    }

    return id;
  }

  getMenu(menuitem) {
    var menu = menuitem;
    var role = menuitem.getAttribute('role');

    while (menu && role !== 'menu' && role !== 'menubar') {
      menu = menu.parentNode;
      if (menu) {
        role = menu.getAttribute('role');
      }
    }

    return menu;
  }

  // Popup menu methods

  isAnyPopupOpen() {
    for (var i = 0; i < this.popups.length; i++) {
      if (this.popups[i].getAttribute('aria-expanded') === 'true') {
        return true;
      }
    }
    return false;
  }

  setMenubarDataExpanded(value) {
    this.domNode.setAttribute('data-menubar-item-expanded', value);
  }

  isMenubarDataExpandedTrue() {
    return this.domNode.getAttribute('data-menubar-item-expanded') === 'true';
  }

  openPopup(menuId, menuitem) {
    // set aria-expanded attribute
    var popupMenu = menuitem.nextElementSibling;

    if (popupMenu) {
      var rect = menuitem.getBoundingClientRect();

      // Set CSS properties
      if (this.isPopup[menuId]) {
        popupMenu.parentNode.style.position = 'relative';
        popupMenu.style.display = 'block';
        popupMenu.style.position = 'absolute';
        popupMenu.style.left = rect.width + 10 + 'px';
        popupMenu.style.top = '0px';
        popupMenu.style.zIndex = 100;
      } else {
        popupMenu.style.display = 'block';
        popupMenu.style.position = 'absolute';
        popupMenu.style.left = '0px';
        popupMenu.style.top = rect.height + 8 + 'px';
        popupMenu.style.zIndex = 100;
      }

      menuitem.setAttribute('aria-expanded', 'true');
      this.setMenubarDataExpanded('true');
      return this.getMenuId(popupMenu);
    }

    return false;
  }

  closePopout(menuitem) {
    var menu,
      menuId = this.getMenuId(menuitem),
      cmi = menuitem;

    while (this.isPopup[menuId] || this.isPopout[menuId]) {
      menu = this.getMenu(cmi);
      cmi = menu.previousElementSibling;
      menuId = this.getMenuId(cmi);
      menu.style.display = 'none';
    }
    cmi.focus();
    return cmi;
  }

  closePopup(menuitem) {
    var menu,
      menuId = this.getMenuId(menuitem),
      cmi = menuitem;

    if (this.isMenubar(menuId)) {
      if (this.isOpen(menuitem)) {
        menuitem.setAttribute('aria-expanded', 'false');
        menuitem.nextElementSibling.style.display = 'none';
      }
    } else {
      menu = this.getMenu(menuitem);
      cmi = menu.previousElementSibling;
      cmi.setAttribute('aria-expanded', 'false');
      cmi.focus();
      menu.style.display = 'none';
    }

    return cmi;
  }

  doesNotContain(popup, menuitem) {
    if (menuitem) {
      return !popup.nextElementSibling.contains(menuitem);
    }
    return true;
  }

  closePopupAll(menuitem) {
    if (typeof menuitem !== 'object') {
      menuitem = false;
    }
    for (var i = 0; i < this.popups.length; i++) {
      var popup = this.popups[i];
      if (this.doesNotContain(popup, menuitem) && this.isOpen(popup)) {
        var cmi = popup.nextElementSibling;
        if (cmi) {
          popup.setAttribute('aria-expanded', 'false');
          cmi.style.display = 'none';
        }
      }
    }
  }

  hasPopup(menuitem) {
    return menuitem.getAttribute('aria-haspopup') === 'true';
  }

  isOpen(menuitem) {
    return menuitem.getAttribute('aria-expanded') === 'true';
  }

  isMenubar(menuId) {
    return !this.isPopup[menuId] && !this.isPopout[menuId];
  }

  isMenuHorizontal(menuitem) {
    return this.menuOrientation[menuitem] === 'horizontal';
  }

  hasFocus() {
    return this.domNode.classList.contains('focus');
  }

  // Menu event handlers

  onMenubarFocusin() {
    // if the menubar or any of its menus has focus, add styling hook for hover
    this.domNode.classList.add('focus');
  }

  onMenubarFocusout() {
    // remove styling hook for hover on menubar item
    this.domNode.classList.remove('focus');
  }

  onKeydown(event) {
    var tgt = event.currentTarget,
      key = event.key,
      flag = false,
      menuId = this.getMenuId(tgt),
      id,
      popupMenuId,
      mi;

    switch (key) {
      case ' ':
      case 'Enter':
        if (this.hasPopup(tgt)) {
          this.openPopups = true;
          popupMenuId = this.openPopup(menuId, tgt);
          this.setFocusToFirstMenuitem(popupMenuId);
        } else {
          if (tgt.href !== '#') {
            this.closePopupAll();
            this.updateContent(tgt.href, tgt.textContent.trim());
            this.setMenubarDataExpanded('false');
          }
        }
        flag = true;
        break;

      case 'Esc':
      case 'Escape':
        this.openPopups = false;
        mi = this.closePopup(tgt);
        id = this.getMenuId(mi);
        this.setMenubarDataExpanded('false');
        flag = true;
        break;

      case 'Up':
      case 'ArrowUp':
        if (this.isMenuHorizontal(menuId)) {
          if (this.hasPopup(tgt)) {
            this.openPopups = true;
            popupMenuId = this.openPopup(menuId, tgt);
            this.setFocusToLastMenuitem(popupMenuId);
          }
        } else {
          this.setFocusToPreviousMenuitem(menuId, tgt);
        }
        flag = true;
        break;

      case 'ArrowDown':
      case 'Down':
        if (this.isMenuHorizontal(menuId)) {
          if (this.hasPopup(tgt)) {
            this.openPopups = true;
            popupMenuId = this.openPopup(menuId, tgt);
            this.setFocusToFirstMenuitem(popupMenuId);
          }
        } else {
          this.setFocusToNextMenuitem(menuId, tgt);
        }
        flag = true;
        break;

      case 'Left':
      case 'ArrowLeft':
        if (this.isMenuHorizontal(menuId)) {
          mi = this.setFocusToPreviousMenuitem(menuId, tgt);
          if (this.isAnyPopupOpen() || this.isMenubarDataExpandedTrue()) {
            this.openPopup(menuId, mi);
          }
        } else {
          if (this.isPopout[menuId]) {
            mi = this.closePopup(tgt);
            id = this.getMenuId(mi);
            mi = this.setFocusToMenuitem(id, mi);
          } else {
            mi = this.closePopup(tgt);
            id = this.getMenuId(mi);
            mi = this.setFocusToPreviousMenuitem(id, mi);
            this.openPopup(id, mi);
          }
        }
        flag = true;
        break;

      case 'Right':
      case 'ArrowRight':
        if (this.isMenuHorizontal(menuId)) {
          mi = this.setFocusToNextMenuitem(menuId, tgt);
          if (this.isAnyPopupOpen() || this.isMenubarDataExpandedTrue()) {
            this.openPopup(menuId, mi);
          }
        } else {
          if (this.hasPopup(tgt)) {
            popupMenuId = this.openPopup(menuId, tgt);
            this.setFocusToFirstMenuitem(popupMenuId);
          } else {
            mi = this.closePopout(tgt);
            id = this.getMenuId(mi);
            mi = this.setFocusToNextMenuitem(id, mi);
            this.openPopup(id, mi);
          }
        }
        flag = true;
        break;

      case 'Home':
      case 'PageUp':
        this.setFocusToFirstMenuitem(menuId, tgt);
        flag = true;
        break;

      case 'End':
      case 'PageDown':
        this.setFocusToLastMenuitem(menuId, tgt);
        flag = true;
        break;

      case 'Tab':
        this.openPopups = false;
        this.setMenubarDataExpanded('false');
        this.closePopup(tgt);
        break;

      default:
        if (this.isPrintableCharacter(key)) {
          this.setFocusByFirstCharacter(menuId, tgt, key);
          flag = true;
        }
        break;
    }

    if (flag) {
      event.stopPropagation();
      event.preventDefault();
    }
  }

  onMenuitemClick(event) {
    var tgt = event.currentTarget;
    var menuId = this.getMenuId(tgt);

    if (this.hasPopup(tgt)) {
      if (this.isOpen(tgt)) {
        this.closePopup(tgt);
      } else {
        this.closePopupAll(tgt);
        this.openPopup(menuId, tgt);
      }
    } else {
      this.updateContent(tgt.href, tgt.textContent.trim());
      this.closePopupAll();
    }
    event.stopPropagation();
    event.preventDefault();
  }

  onMenuitemPointerover(event) {
    var tgt = event.currentTarget;
    var menuId = this.getMenuId(tgt);

    if (this.hasFocus()) {
      this.setFocusToMenuitem(menuId, tgt);
    }

    if (this.isAnyPopupOpen() || this.hasFocus()) {
      this.closePopupAll(tgt);
      if (this.hasPopup(tgt)) {
        this.openPopup(menuId, tgt);
      }
    }
  }

  onBackgroundPointerdown(event) {
    if (!this.domNode.contains(event.target)) {
      this.closePopupAll();
    }
  }
}

// Initialize menubar editor

window.addEventListener('load', function () {
  var menubarNavs = document.querySelectorAll('.menubar-navigation');
  for (var i = 0; i < menubarNavs.length; i++) {
    new MenubarNavigation(menubarNavs[i]);
  }
});

              
            
!
999px

Console