var Wick = Wick || {};
Wick.RangeTypes = (function () {
  var $button = $('.range-types .range-types__load-button'),
    $tabSelector = $('.range-types__tab'),
    tabOpenClass = 'range-types__tab_open',
    $buttons = $tabSelector.find($button);

  $buttons.on('click', function (e) {
    if ($tabSelector.hasClass(tabOpenClass)) {
      $('html, body').scrollTop($tabSelector.parents('.tab-content').offset().top + 20);
    }
    $(e.target).parents('.tab-pane').toggleClass(tabOpenClass);
    $(e.target).parents('.tab-pane').find($buttons).toggle();
  });
})();
