Sha256: 835a3d62663cbeb98e180212e9d8db005b7d9775e46a761ea452465a53c5a8aa

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 KB

Contents

const ChangeScreen = (index, value, state) => {
  let source = Overlay.custom[index],
    target = ".area.overlay-" + source.name,
    input = $(".input.text-search"),
    results = $(".wrap.results");

  if (state == "close") {
    gsap.set("body", {
      clearProps: "overflow",
    });

    gsap.set(target, {
      clearProps: "display",
    });

    source.open = false;

    if (value.name == "search") {
      input.val("");

      results.empty();
    }
  } else {
    gsap.set("body", {
      overflow: "hidden",
    });

    gsap.set(target, {
      display: Config.display,
    });

    source.open = true;

    if (value.name == "search") {
      input.focus();
    }
  }
};

const BuildScreens = (index, value) => {
  let button = Overlay.button + "." + value.name,
    exit = Overlay.exit + "." + value.name;

  $(button).click(function () {
    ChangeScreen(index, value, "open");
  });

  $(exit).click(function () {
    ChangeScreen(index, value, "close");
  });
};

const KeyUp = (e) => {
  $(Overlay.custom).map((index, value) => {
    if (value.open && e.keyCode == 27) {
      ChangeScreen(index, value, "close");
    }

    if (!value.open && !Site.inFocus) {
      if (e.keyCode == 65 && value.name == "about") {
        ChangeScreen(index, value, "open");
      }

      if (e.keyCode == 66 && value.name == "browse") {
        ChangeScreen(index, value, "open");
      }

      if (e.keyCode == 83 && value.name == "search") {
        ChangeScreen(index, value, "open");
      }
    }
  });
};

$(Overlay.custom).map((index, value) => {
  BuildScreens(index, value);
});

$(document).keyup(function (e) {
  KeyUp(e);
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
futuro-1.1.8 assets/js/footer/custom/4_Setup.overlays.js
futuro-1.1.7 assets/js/footer/custom/4_Setup.overlays.js
futuro-1.1.6 assets/js/footer/custom/4_Setup.overlays.js
futuro-1.1.5 assets/js/footer/custom/4_Setup.overlays.js
futuro-1.1.4 assets/js/footer/custom/4_Setup.overlays.js