// JavaScript Document

// Scripts written by __gulp_init__author_name @ __gulp_init__author_company

import SuperSlide from "superslide.js";
import focusTrap from "focus-trap";

// get the elements
const CONTENT    = document.getElementById("page-container");
const SLIDER     = document.getElementById("mobile-menu");
const TOGGLE     = document.querySelector("[data-toggle=mobile-menu]");
const FOCUS_TRAP = focusTrap("#mobile-menu");

// verify that the elements exist
if (CONTENT !== null && SLIDER !== null && TOGGLE !== null) {
    // initialize the menu
    const MOBILE_MENU = new SuperSlide({
        allowContentInteraction: false,
        animation:               "slideLeft",
        closeOnBlur:             true,
        content:                 document.getElementById("page-container"),
        duration:                0.25,
        slideContent:            false,
        slider:                  document.getElementById("mobile-menu"),
        onOpen:                  () => {
            SLIDER.setAttribute("aria-hidden", false);
            FOCUS_TRAP.activate();
        },
        onClose:                 () => {
            SLIDER.setAttribute("aria-hidden", true);
            FOCUS_TRAP.deactivate();
        },
    });

    // open the menu when clicking on the toggle
    TOGGLE.addEventListener("click", (e) => {
        e.preventDefault();

        console.log(MOBILE_MENU.isOpen());

        if (!MOBILE_MENU.isOpen()) {
            MOBILE_MENU.open();
        } else {
            MOBILE_MENU.close();
        }
    });
}

// JavaScript Document

// Scripts written by __gulp_init__author_name @ __gulp_init__author_company

import SuperSlide from "superslide.js";

// get the elements
const CONTENT    = document.getElementById("page-container");
const SLIDER     = document.getElementById("mobile-menu");
const TOGGLE     = document.querySelector("[data-toggle=mobile-menu]");

// verify that the elements exist
if (CONTENT !== null && SLIDER !== null && TOGGLE !== null) {
    // initialize the menu
    const MOBILE_MENU = new SuperSlide({
        allowContentInteraction: false,
        animation:               "slideLeft",
        closeOnBlur:             true,
        content:                 document.getElementById("page-container"),
        duration:                0.25,
        slideContent:            false,
        slider:                  document.getElementById("mobile-menu"),
        onOpen:                  () => {
            SLIDER.setAttribute("aria-hidden", false);
        },
        onClose:                 () => {
            SLIDER.setAttribute("aria-hidden", true);
        },
    });

    // open the menu when clicking on the toggle
    TOGGLE.addEventListener("click", (e) => {
        e.preventDefault();

        console.log(MOBILE_MENU.isOpen());

        if (!MOBILE_MENU.isOpen()) {
            MOBILE_MENU.open();
        } else {
            MOBILE_MENU.close();
        }
    });
}

Revert "Trap focus to the menu when open"
Revert "Trap focus to the menu when open"

This reverts commit ed195f52702a7eead162d9f10e6e898de0fe9029.

Trapping focus was preventing the menu from being closeable
