// import $ from 'jquery'; const $ = require('jquery'); class Social { 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) } } /* ihk.Social = function (socialBox) { const t = this; t.socialBox = socialBox.addClass('initiated'); t.section = socialBox.closest('section'); t.isSocialSection = t.section.hasClass('social'); t.preventTabFocus(); //t.preventMobileScroll(); } ihk.Social.prototype.preventTabFocus = function(first_argument) { const t = this; t.prevFocusable = $('').insertBefore(t.socialBox); t.nextFocusable = $('').insertAfter(t.socialBox); t.prevFocusable.on('focus', function () { if (t.isSocialSection) { t.focusNextSection(); } else { const nextCol = t.socialBox.closest('.col').next('.col'); if (nextCol.length) { nextCol.find('.teaser').focus(); } else { t.focusNextSection(); } } }) t.nextFocusable.on('focus', function () { if (t.isSocialSection) { t.section.find('.social-icons a').last().focus(); } else { const prevCol = t.socialBox.closest('.col').prev('.col'); if (prevCol.length) { prevCol.find('.teaser').focus(); } else { t.focusPrevSection(); } } }) }; ihk.Social.prototype.preventMobileScroll = function() { const t = this; t.socialBox.on('touchmove', function (e) { console.log(e.targetTouches.length); if (e.targetTouches.length == 1) { t.socialBox.addClass('prevent-scroll'); } else { t.socialBox.addClass('allow-scroll'); } }) t.socialBox.on('touchend', function (e) { t.socialBox.removeClass('prevent-scroll').removeClass('allow-scroll'); }) }; ihk.Social.prototype.focusNextSection = function() { const t = this; if (t.section.nextAll('section').length > 0) { t.section.nextAll('section').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').first().focus(); } else { $('footer').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').first().focus(); } }; ihk.Social.prototype.focusPrevSection = function(first_argument) { const t = this; if (t.section.prevAll('section').length > 0) { t.section.prevAll('section').find('a, input, button, select, textarea').not(':disabled').not('[tabindex="-1"]').last().focus(); } else { $('header .toggle-nav').focus(); } }; */ $('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () { $('.social-box:not(.initiated)').each(function () { new Social($(this)); }) })