import $ from "jquery";
import IHKSwitch from "../ihk-switch/ihk-switch";

class IHKCommonContent {
  constructor(wrapper) {
    this.wrapper = wrapper;
    this.wrapper = wrapper.addClass('initiated');
    wrapper.find('a.primary-light').on('click', (e) => {
      e.preventDefault();
      wrapper.addClass("hidden");
    });
    wrapper.find('a.secondary').on('click', (e) => {
      e.preventDefault();
      this.changeSwitcher(e);
    });
  }
  changeSwitcher() {
    let ihkSwitchZip = document.getElementById("ihk-switch-zip");
    if (ihkSwitchZip) {
      //hide already shown ihk switcher
      let ihkSwitchSep = document.getElementById("ihk-switch-step");
      if (ihkSwitchSep) {
        ihkSwitchSep.classList.add("hide");
      }
      //show ihk switcher with finder
      ihkSwitchZip.classList.remove("initialized");
      ihkSwitchZip.setAttribute("data-show-step", "");
      new IHKSwitch($(ihkSwitchZip));
    }
  }
}
export default IHKCommonContent;
$('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () {
  $('.common-content:not(.initiated)').each(() => {
    new IHKCommonContent($(this));
  });
});
