//TODO: needs refactoring in future, gather tother with range-type.js for common script
var Wick = Wick || {};

Wick.StoreLocator = (function () {
  var $button = $('.store-locator__load-button'),
    cardsListOpenClass = 'cards-store-list_open',
    $cardsList = $('.cards-store-wrapper'),
    $buttons = $cardsList.find($button);

  $buttons.on('click', function () {
    if ($cardsList.hasClass(cardsListOpenClass)) {
      $('html, body').scrollTop($cardsList.parents('.cards-store-holder').offset().top + 20);
    }
    $cardsList.toggleClass(cardsListOpenClass);
    $buttons.toggle();
  });
})();


