Sha256: 7de4e651047ce9882082cf799e591b60b318956b1696711474da84abf2a73abd

Contents?: true

Size: 1.73 KB

Versions: 7

Compression:

Stored size: 1.73 KB

Contents

const SearchInput   = $('.input.--search'),
      SearchResults = $('.block._results');

const OpenOverlay = type => {
  TweenMax.set(body,{className:'+=--overlay'});
  TweenMax.set('.overlay._' + type,{className:'+=--open'});
}

const CloseOverlay = type => {
  TweenMax.set(body,{className:'-=--overlay'});
  TweenMax.set('.overlay._' + type,{className:'-=--open'});
}

function KeyFunc(e) {
  let code = e.keyCode;

  if (code == 27) {
    if (AboutOpen) {
      CloseOverlay('about');
      AboutOpen = false;
    }
    if (BrowseOpen) {
      CloseOverlay('browse');
      BrowseOpen = false;
    }
    if (SearchOpen) {
      CloseOverlay('search');
      SearchInput.val('');
      SearchResults.html('');
      SearchOpen = false;
    }
  }

  if (AboutOpen == false && BrowseOpen == false && SearchOpen == false) {
    if (code == 65) {
      OpenOverlay('about');
      AboutOpen = true;
    }
    if (code == 66) {
      OpenOverlay('browse');
      BrowseOpen = true;
    }
    if (code == 83) {
      OpenOverlay('search');
      SearchInput.focus();
      SearchOpen = true;
    }
  }
}

$('.btn._nav.--about').click(function() {
  OpenOverlay('about');
  AboutOpen = true;
});

$('.btn._nav.--browse').click(function() {
  OpenOverlay('browse');
  BrowseOpen = true;
});

$('.btn._nav.--search').click(function() {
  OpenOverlay('search');
  SearchInput.focus();
  SearchOpen = true;
});

$('.exit._about').click(function() {
  CloseOverlay('about');
  AboutOpen = false;
});

$('.exit._browse').click(function() {
  CloseOverlay('browse');
  BrowseOpen = false;
});

$('.exit._search').click(function() {
  CloseOverlay('search');
  SearchInput.val('');
  SearchResults.html('');
  SearchOpen = false;
});

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
futuro-0.3.5 assets/js/custom/OpenOverlay.js
futuro-0.3.4 assets/js/custom/OpenOverlay.js
futuro-0.3.3 assets/js/custom/OpenOverlay.js
futuro-0.3.2 assets/js/custom/OpenOverlay.js
futuro-0.3.1 assets/js/custom/_OpenOverlay.js
futuro-0.3.0 assets/js/custom/_OpenOverlay.js
futuro-0.2.9 assets/js/custom/_OpenOverlay.js