import $ from 'jquery'; class IHKTopicTeasers { constructor(section) { this.section = section.addClass('initiated'); this.cols = section.find('.col'); const fullOffset = Math.ceil(this.cols.length / 3) * 3 - this.cols.last().index() - 1; if (fullOffset === 0) { return; } let firstHalfWidth = this.cols.length - fullOffset * 2; if (firstHalfWidth < 0) { firstHalfWidth = 0; } this.cols.eq(firstHalfWidth).addClass('width-half').nextAll().addClass('width-half'); } } export default IHKTopicTeasers; $('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () { $('.topics:not(.initiated)').each(() => { new IHKTopicTeasers($(this)); }); })