var Wick = Wick || {};
Wick.ShoppingCart = (function(){
  var $btn = $('.header-minicart__switcher');

  function isEmpty() {
    return localStorage.isEmpty === 'true';
  }

  function clear() {
    localStorage.isEmpty = true;
    $btn.find('.header-minicart__counter').removeClass('_is-visible');
    Wick.MiniBasket.disableRollover();
  }

  function add() {
    localStorage.isEmpty = false;
    $btn.find('.header-minicart__counter').addClass('_is-visible');
  }

  function bindEvents() {
    $('.btn-add-to-basket, .page-product-details .card-store-collect__btn').on('click', add);
  }

  var init = function () {
    bindEvents();

    if(isEmpty()){
      clear();
    } else {
      $btn.find('.header-minicart__counter').addClass('_is-visible');
    }
  };

  $(document).ready(init);

  return {
    clear: clear
  };
})();
