demo/dist/demo.js
function toggleMenu(input) {
	    var popup = this.elements.settings.popup;
	    var button = this.elements.buttons.settings; // Menu and button are required

	    if (!is$1.element(popup) || !is$1.element(button)) {
	      return;
	    } // True toggle by default


	    var hidden = popup.hidden;
	    var show = hidden;

	    if (is$1.boolean(input)) {
	      show = input;
	    } else if (is$1.keyboardEvent(input) && input.which === 27) {
	      show = false;
	    } else if (is$1.event(input)) {
	      // If Plyr is in a shadowDOM, the event target is set to the component, instead of the
	      // Element in the shadowDOM. The path, if available, is complete.
	      var target = is$1.function(input.composedPath) ? input.composedPath()[0] : input.target;
	      var isMenuItem = popup.contains(target); // If the click was inside the menu or if the click
	      // wasn't the button or menu item and we're trying to
	      // show the menu (a doc click shouldn't show the menu)

	      if (isMenuItem || !isMenuItem && input.target !== button && show) {
	        return;
	      }
	    } // Set button attributes


	    button.setAttribute('aria-expanded', show); // Show the actual popup

	    toggleHidden(popup, !show); // Add class hook

	    toggleClass(this.elements.container, this.config.classNames.menu.open, show); // Focus the first item if key interaction

	    if (show && is$1.keyboardEvent(input)) {
	      controls.focusFirstMenuItem.call(this, null, true);
	    } else if (!show && !hidden) {
	      // If closing, re-focus the button
	      setFocus.call(this, button, is$1.keyboardEvent(input));
	    }
	  }
function toggleMenu(input) {
	    var popup = this.elements.settings.popup;
	    var button = this.elements.buttons.settings; // Menu and button are required

	    if (!is$1.element(popup) || !is$1.element(button)) {
	      return;
	    } // True toggle by default


	    var hidden = popup.hidden;
	    var show = hidden;

	    if (is$1.boolean(input)) {
	      show = input;
	    } else if (is$1.keyboardEvent(input) && input.which === 27) {
	      show = false;
	    } else if (is$1.event(input)) {
	      // If Plyr is in a shadowDOM, the event target is set to the component, instead of the
	      // Element in the shadowDOM. The path, if available, is complete.
	      var target = is$1.function(input.composedPath) ? input.composedPath()[0] : input.target;
	      var isMenuItem = popup.contains(target); // If the click was inside the menu or if the click
	      // wasn't the button or menu item and we're trying to
	      // show the menu (a doc click shouldn't show the menu)

	      if (isMenuItem || !isMenuItem && input.target !== button && show) {
	        return;
	      }
	    } // Set button attributes


	    button.setAttribute('aria-expanded', show); // Show the actual popup

	    toggleHidden(popup, !show); // Add class hook

	    toggleClass(this.elements.container, this.config.classNames.menu.open, show); // Focus the first item if key interaction

	    if (show && is$1.keyboardEvent(input)) {
	      controls.focusFirstMenuItem.call(this, null, true);
	    } else if (!show && !hidden) {
	      // If closing, re-focus the button
	      setFocus.call(this, button, is$1.keyboardEvent(input));
	    }
	  }
function toggleMenu ( input ) { var popup = this . elements . settings . popup ; var button = this . elements . buttons . settings ; // Menu and button are required if ( ! is$1 . element ( popup ) || ! is$1 . element ( button ) ) { return ; } // True toggle by default var hidden = popup . hidden ; var show = hidden ; if ( is$1 . boolean ( input ) ) { show = input ; } else if ( is$1 . keyboardEvent ( input ) && input . which === 27 ) { show = false ; } else if ( is$1 . event ( input ) ) { // If Plyr is in a shadowDOM, the event target is set to the component, instead of the // Element in the shadowDOM. The path, if available, is complete. var target = is$1 . function ( input . composedPath ) ? input . composedPath ( ) [ 0 ] : input . target ; var isMenuItem = popup . contains ( target ) ; // If the click was inside the menu or if the click // wasn't the button or menu item and we're trying to // show the menu (a doc click shouldn't show the menu) if ( isMenuItem || ! isMenuItem && input . target !== button && show ) { return ; } } // Set button attributes button . setAttribute ( 'aria-expanded' , show ) ; // Show the actual popup toggleHidden ( popup , ! show ) ; // Add class hook toggleClass ( this . elements . container , this . config . classNames . menu . open , show ) ; // Focus the first item if key interaction if ( show && is$1 . keyboardEvent ( input ) ) { controls . focusFirstMenuItem . call ( this , null , true ) ; } else if ( ! show && ! hidden ) { // If closing, re-focus the button setFocus . call ( this , button , is$1 . keyboardEvent ( input ) ) ; } }
Show/hide menu
Show / hide menu