import $ from 'jquery';

class IHKSocialBox {
  constructor(socialBox) {
    this.box = socialBox.addClass('initiated')
    this.tabindexSet = false;

    this.checkIframe();
  }

  checkIframe() {
    setTimeout(() => {
      const iframe = this.box.find('iframe');
      if (iframe.length) {
        iframe.attr('tabindex', '-1');
      }
      else {
        this.checkIframe();
      }
    }, 1000)
  }
}

export default IHKSocialBox;

$('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () {
  $('.social-box:not(.initiated)').each(function () {
    new IHKSocialBox($(this));
  })
})
