847b0db4bbe1ea3a032f604d566f0aa6d7894e5cfab58d1118e5a77a86f154e1

Source Code:

var NaviApiTabletBasket = function () {};

// Opened
NaviApiTabletBasket.openBasket = function () {
  NaviApiTabletBasket.main.style.visibility = 'visible';
  NaviApiTabletBasket.main.style.opacity = 1;
  NaviApiTabletBasket.main.style.zIndex = 1100;
  NaviApiTabletBasket.isOpened = true;
};

// Closed
NaviApiTabletBasket.closeBasket = function () {
  NaviApiTabletBasket.main.style.visibility = 'hidden';
  NaviApiTabletBasket.main.style.opacity = 0;
  NaviApiTabletBasket.main.style.zIndex = 1;
  NaviApiTabletBasket.isOpened = false;
};

// Validate
NaviApiTabletBasket.isBasket = function (tapTargetElement, openNavigationElement) {
  if (tapTargetElement === openNavigationElement) {
    return true;
  }
  if (tapTargetElement.parentNode === null) {
    return false;
  }
  return NaviApiTabletBasket.isBasket(tapTargetElement.parentNode, openNavigationElement);
};

// script attribute defer is mandatory
NaviApiTabletBasket.isOpened = false;
// TODO replace `class` to `id`
NaviApiTabletBasket.root = document.getElementsByClassName('_n4v1-basket')[0];
NaviApiTabletBasket.icon = document.getElementsByClassName('_n4v1-basket-default')[0];
NaviApiTabletBasket.iconLink = document.getElementsByClassName('_n4v1-basket-link')[0];
NaviApiTabletBasket.main = document.getElementsByClassName('_n4v1-basket-main')[0];

// Add Listner:Open
NaviApiTabletBasket.icon.addEventListener('touchend', function () {
  if (NaviApiTabletBasket.isOpened) {
    NaviApiTabletBasket.closeBasket();
  } else {
    NaviApiTabletBasket.openBasket();
  }
});

// Add Listner:Close
document.body.addEventListener('touchend', function (e) {
  if (!NaviApiTabletBasket.isBasket(e.target, NaviApiTabletBasket.root)) {
    NaviApiTabletBasket.closeBasket();
  }
});