// External dependencies import includes from 'lodash/includes'; import isUndefined from 'lodash/isUndefined'; import get from 'lodash/get'; // Internal dependencies import './motion-effects'; import './sticky-elements'; import { getContentAreaSelector, } from 'gutenberg/utils/selectors'; import { isBuilder, isDiviTheme, isExtraTheme, } from '../utils/utils'; const _post_id = et_pb_custom.page_id; /*! ET frontend-builder-scripts.js */ (function($) { const isBlockLayoutPreview = 'undefined' !== typeof window.ETBlockLayoutModulesScript && $('body').hasClass('et-block-layout-preview'); const top_window = isBuilder || isBlockLayoutPreview ? ET_Builder.Frames.top : window; const $et_window = $(window); const $fullscreenSectionWindow = isBlockLayoutPreview ? $(top_window) : $(window); const $et_top_window = isBuilder ? top_window.jQuery(top_window) : $(window); const isTB = $('body').hasClass('et-tb'); const isBFB = $('body').hasClass('et-bfb'); const isVB = isBuilder && ! isBFB; const isScrollOnAppWindow = function() { if (isBlockLayoutPreview) { return false; } return isVB && ($('html').is('.et-fb-preview--wireframe') || $('html').is('.et-fb-preview--desktop')); }; const isBuilderModeZoom = function() { return isBuilder && $('html').is('.et-fb-preview--zoom'); }; const isInsideVB = function($node) { return $node.closest('#et-fb-app').length > 0; }; const getInsideVB = function($node) { return $('#et-fb-app').find($node); }; const getOutsideVB = function($node) { if ('string' === typeof $node) { $node = $($node); } return $node.not('#et-fb-app *'); }; window.et_load_event_fired = false; window.et_is_transparent_nav = $('body').hasClass('et_transparent_nav'); window.et_is_vertical_nav = $('body').hasClass('et_vertical_nav'); window.et_is_fixed_nav = $('body').hasClass('et_fixed_nav'); window.et_is_minified_js = $('body').hasClass('et_minified_js'); window.et_is_minified_css = $('body').hasClass('et_minified_css'); window.et_force_width_container_change = false; jQuery.fn.reverse = [].reverse; jQuery.fn.closest_descendent = function(selector) { let $found; let $current_children = this.children(); while ($current_children.length) { $found = $current_children.filter(selector); if ($found.length) { break; } $current_children = $current_children.children(); } return $found; }; // Star-based rating UI. // @see: WooCommerce's woocommerce/assets/js/frontend/single-product.js file window.et_pb_init_woo_star_rating = function($rating_selector) { const $rating_parent = $rating_selector.closest('div'); const $existing_stars = $rating_parent.find('p.stars'); if ($existing_stars.length > 0) { $existing_stars.remove(); } $rating_selector.hide().before('

\ \ 1\ 2\ 3\ 4\ 5\ \

'); }; window.et_pb_wrap_woo_attribute_fields_in_span = function() { // WooCommerce Modules :: Add To Cart const $et_variations_forms = $('form.variations_form'); // $.each() avoids multiple 's when more than one form exists. // @see https://github.com/elegantthemes/submodule-builder/pull/7022#discussion_r370703949 $.each($et_variations_forms, (idx, form) => { const $form = $(form); const $et_attribute_fields = $form.find('.variations select'); const $et_attribute_fields_parent = $form.find('.variations select').parent('td.value'); const $et_reset_variations = $form.find('.reset_variations'); // Checking length makes sure that `` isn't nested in VB. if (0 === $et_attribute_fields_parent.length || $et_attribute_fields_parent.attr('data-is-span-added')) { return; } $et_attribute_fields_parent.attr('data-is-span-added', '1'); $($et_attribute_fields).wrap(''); if (isVB && $et_reset_variations.length > 0) { $($et_reset_variations).remove(); } }); }; window.et_pb_init_modules = function() { $.et_pb_simple_slider = function(el, options) { const settings = $.extend({ slide: '.et-slide', // slide class arrows: '.et-pb-slider-arrows', // arrows container class prev_arrow: '.et-pb-arrow-prev', // left arrow class next_arrow: '.et-pb-arrow-next', // right arrow class controls: '.et-pb-controllers a', // control selector carousel_controls: '.et_pb_carousel_item', // carousel control selector control_active_class: 'et-pb-active-control', // active control class name previous_text: et_pb_custom.previous, // previous arrow text next_text: et_pb_custom.next, // next arrow text fade_speed: 500, // fade effect speed use_arrows: true, // use arrows? use_controls: true, // use controls? manual_arrows: '', // html code for custom arrows append_controls_to: '', // controls are appended to the slider element by default, here you can specify the element it should append to controls_below: false, controls_class: 'et-pb-controllers', // controls container class name slideshow: false, // automattic animation? slideshow_speed: 7000, // automattic animation speed show_progress_bar: false, // show progress bar if automattic animation is active tabs_animation: false, use_carousel: false, active_slide: 0, }, options); const $et_slider = $(el); let $et_slide = $et_slider.closest_descendent(settings.slide); const et_slides_number = $et_slide.length; const et_fade_speed = settings.fade_speed; let et_active_slide = settings.active_slide; let $et_slider_arrows; let $et_slider_prev; let $et_slider_next; let $et_slider_controls; let $et_slider_carousel_controls; let et_slider_timer; let controls_html = ''; let carousel_html = ''; const $progress_bar = null; const progress_timer_count = 0; const $et_pb_container = $et_slider.find('.et_pb_container'); const et_pb_container_width = $et_pb_container.width(); const is_post_slider = $et_slider.hasClass('et_pb_post_slider'); const et_slider_breakpoint = ''; let stop_slider = false; $et_slider.et_animation_running = false; $.data(el, 'et_pb_simple_slider', $et_slider); $et_slide.eq(0).addClass('et-pb-active-slide'); $et_slider.attr('data-active-slide', $et_slide.data('slide-id')); if (! settings.tabs_animation) { if (! $et_slider.hasClass('et_pb_bg_layout_dark') && ! $et_slider.hasClass('et_pb_bg_layout_light')) { $et_slider.addClass(et_get_bg_layout_color($et_slide.eq(0))); } } if (settings.use_arrows && et_slides_number > 1) { if ('' == settings.manual_arrows) { // Setting style="color:inherit" for Gallery Slider's arrows if (settings.hasOwnProperty('slide') && '.et_pb_gallery_item' === settings.slide) { $et_slider.append(`${''); } else { $et_slider.append(`${''); } } else { $et_slider.append(settings.manual_arrows); } $et_slider_arrows = $et_slider.find(settings.arrows); $et_slider_prev = $et_slider.find(settings.prev_arrow); $et_slider_next = $et_slider.find(settings.next_arrow); $et_slider.on('click.et_pb_simple_slider', settings.next_arrow, () => { if ($et_slider.et_animation_running) return false; $et_slider.et_slider_move_to('next'); return false; }); $et_slider.on('click.et_pb_simple_slider', settings.prev_arrow, () => { if ($et_slider.et_animation_running) return false; $et_slider.et_slider_move_to('previous'); return false; }); // swipe support requires et-jquery-touch-mobile $et_slider.on('swipeleft.et_pb_simple_slider', settings.slide, event => { // do not switch slide on selecting text in VB if ($(event.target).closest('.et-fb-popover-tinymce').length || $(event.target).closest('.et-fb-editable-element').length) { return; } $et_slider.et_slider_move_to('next'); }); $et_slider.on('swiperight.et_pb_simple_slider', settings.slide, event => { // do not switch slide on selecting text in VB if ($(event.target).closest('.et-fb-popover-tinymce').length || $(event.target).closest('.et-fb-editable-element').length) { return; } $et_slider.et_slider_move_to('previous'); }); } if (settings.use_controls && et_slides_number > 1) { for (var i = 1; i <= et_slides_number; i++) { controls_html += `${i}`; } if ($et_slider.find('video').length > 0) { settings.controls_class += ' et-pb-controllers-has-video-tag'; } controls_html = `
${ controls_html }
`; if ('' == settings.append_controls_to) $et_slider.append(controls_html); else $(settings.append_controls_to).append(controls_html); if (settings.controls_below) $et_slider_controls = $et_slider.parent().find(settings.controls); else $et_slider_controls = $et_slider.find(settings.controls); $et_slider_controls.on('click.et_pb_simple_slider', function() { if ($et_slider.et_animation_running) return false; $et_slider.et_slider_move_to($(this).index()); return false; }); } if (settings.use_carousel && et_slides_number > 1) { for (var i = 1; i <= et_slides_number; i++) { const slide_id = i - 1; const image_src = ($et_slide.eq(slide_id).data('image') !== undefined) ? `url(${$et_slide.eq(slide_id).data('image')})` : 'none'; carousel_html += `'; } carousel_html = `${''; $et_slider.after(carousel_html); $et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find(settings.carousel_controls); $et_slider_carousel_controls.on('click.et_pb_simple_slider', function() { if ($et_slider.et_animation_running) return false; const $this = $(this); $et_slider.et_slider_move_to($this.data('slide-id')); return false; }); } if (settings.slideshow && et_slides_number > 1) { $et_slider.on('mouseenter.et_pb_simple_slider', () => { if ($et_slider.hasClass('et_slider_auto_ignore_hover')) { return; } $et_slider.addClass('et_slider_hovered'); if (typeof et_slider_timer !== 'undefined') { clearTimeout(et_slider_timer); } }).on('mouseleave.et_pb_simple_slider', () => { if ($et_slider.hasClass('et_slider_auto_ignore_hover')) { return; } $et_slider.removeClass('et_slider_hovered'); et_slider_auto_rotate(); }); } et_slider_auto_rotate(); function et_slider_auto_rotate() { if (stop_slider) { return; } // Slider animation can be dynamically paused with et_pb_pause_slider // Make sure animation will start when class is removed by checking clas existence every 2 seconds. if ($et_slider.hasClass('et_pb_pause_slider')) { setTimeout(() => { et_slider_auto_rotate(); }, 2000); return; } if (settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass('et_slider_hovered')) { et_slider_timer = setTimeout(() => { $et_slider.et_slider_move_to('next'); }, settings.slideshow_speed); } } $et_slider.et_slider_destroy = function() { // Clear existing timer / auto rotate if (typeof et_slider_timer !== 'undefined') { clearTimeout(et_slider_timer); } stop_slider = true; // Deregister all own existing events $et_slider.off('.et_pb_simple_slider'); // Removing existing style from slide(s) $et_slider.find('.et_pb_slide').css({ 'z-index': '', display: '', opacity: '', }); // Removing existing classnames from slide(s) $et_slider.find('.et-pb-active-slide').removeClass('et-pb-active-slide'); $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); // Removing DOM that was added by slider $et_slider.find('.et-pb-slider-arrows, .et-pb-controllers').remove(); $et_slider.siblings('.et_pb_carousel, .et-pb-controllers').remove(); // Remove references $et_slider.removeData('et_pb_simple_slider'); }; function et_stop_video(active_slide) { let $et_video; let et_video_src; // if there is a video in the slide, stop it when switching to another slide if (active_slide.has('iframe').length) { $et_video = active_slide.find('iframe'); et_video_src = $et_video.attr('src'); $et_video.attr('src', ''); $et_video.attr('src', et_video_src); } else if (active_slide.has('video').length) { if (! active_slide.find('.et_pb_section_video_bg').length) { $et_video = active_slide.find('video'); $et_video[0].pause(); } } } // Remove inline width and height added by mediaelement.js function et_fix_slide_video_height() { const $this_slider = $et_slider; const $slide_video_container = $this_slider.find('.et-pb-active-slide .et_pb_slide_video'); const slide_video_container_height = parseFloat($slide_video_container.height()); const slide_wp_video_shortcode = $this_slider.find('.et_pb_slide_video .wp-video-shortcode'); slide_wp_video_shortcode.css({ width: '', height: '' }); if (! isNaN(slide_video_container_height)) { $slide_video_container.css('marginTop', `-${slide_video_container_height / 2}px`); } } $et_slider.et_fix_slider_content_images = et_fix_slider_content_images; function et_fix_slider_content_images() { const $this_slider = $et_slider; const $slide_image_container = $this_slider.find('.et-pb-active-slide .et_pb_slide_image'); const $slide_image = $slide_image_container.find('img'); const $slide_video_container = $this_slider.find('.et-pb-active-slide .et_pb_slide_video'); const $slide = $slide_image_container.closest('.et_pb_slide'); const $slider = $slide.closest('.et_pb_slider'); const slide_height = parseFloat($slider.innerHeight()); const image_height = parseFloat(slide_height * 0.8); let slide_image_container_height = parseFloat($slide_image_container.height()); const slide_video_container_height = parseFloat($slide_video_container.height()); if (! isNaN(image_height)) { $slide_image_container.find('img').css('maxHeight', `${image_height}px`); slide_image_container_height = parseInt($slide_image_container.height()); } if (! isNaN(slide_image_container_height) && $slide.hasClass('et_pb_media_alignment_center')) { $slide_image_container.css('marginTop', `-${slide_image_container_height / 2}px`); // Add load jQuery event only once. if (! $slide_image.data('hasLoadEvent')) { $slide_image.data('hasLoadEvent', true); // It will fix the image position when lazy loading image is enabled. $slide_image.on('load', () => { slide_image_container_height = parseFloat($slide_image_container.height()); $slide_image_container.css('marginTop', `-${slide_image_container_height / 2}px`); }); } } if (! isNaN(slide_video_container_height)) { $slide_video_container.css('marginTop', `-${slide_video_container_height / 2}px`); } } function et_get_bg_layout_color($slide) { if ($slide.hasClass('et_pb_bg_layout_light')) { return 'et_pb_bg_layout_light'; } return 'et_pb_bg_layout_dark'; } // fix the appearance of some modules inside the post slider function et_fix_builder_content() { if (is_post_slider) { setTimeout(() => { const $et_pb_circle_counter = $('.et_pb_circle_counter'); const $et_pb_number_counter = $('.et_pb_number_counter'); window.et_fix_testimonial_inner_width(); if ($et_pb_circle_counter.length) { window.et_pb_reinit_circle_counters($et_pb_circle_counter); } if ($et_pb_number_counter.length) { window.et_pb_reinit_number_counters($et_pb_number_counter); } window.et_reinit_waypoint_modules(); }, 1000); } } if (window.et_load_event_fired) { 'function' === typeof et_fix_slider_height && et_fix_slider_height($et_slider); } else { $et_window.on('load', () => { 'function' === typeof et_fix_slider_height && et_fix_slider_height($et_slider); }); } $et_window.on('resize.et_simple_slider', () => { et_fix_slider_height($et_slider); }); $et_slider.et_slider_move_to = function(direction) { $et_slide = $et_slider.closest_descendent(settings.slide); const $active_slide = $et_slide.eq(et_active_slide); $et_slider.et_animation_running = true; $et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass(`et_slide_transition_to_${direction}`); $et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide'); if ('next' === direction || 'previous' === direction) { if ('next' === direction) { et_active_slide = (et_active_slide + 1) < et_slides_number ? et_active_slide + 1 : 0; } else { et_active_slide = (et_active_slide - 1) >= 0 ? et_active_slide - 1 : et_slides_number - 1; } } else { if (et_active_slide === direction) { // When video is added, slider needs to be reloaded, so inline styles need to be added again $et_slider.find('.et-pb-inactive-slide').css({ 'z-index': '', display: '', opacity: 0, }); $active_slide.css({ display: 'block', opacity: 1 }).data('slide-status', 'active'); $et_slider.et_animation_running = false; return; } et_active_slide = direction; } $et_slider.attr('data-active-slide', $et_slide.eq(et_active_slide).data('slide-id')); if (typeof et_slider_timer !== 'undefined') { clearTimeout(et_slider_timer); } const $next_slide = $et_slide.eq(et_active_slide); $et_slider.trigger('slide', { current: $active_slide, next: $next_slide }); if (typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0].player !== 'undefined') { $active_slide.find('video')[0].player.pause(); } if (typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0].player !== 'undefined') { $next_slide.find('video')[0].player.play(); } const $active_slide_video = $active_slide.find('.et_pb_video_box iframe'); if ($active_slide_video.length) { let active_slide_video_src = $active_slide_video.attr('src'); // Removes the "autoplay=1" parameter when switching slides // by covering three possible cases: // "?autoplay=1" at the end of the URL active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1$/, ''); // "?autoplay=1" followed by another parameter active_slide_video_src = active_slide_video_src.replace(/\?autoplay=1&(amp;)?/, '?'); // "&autoplay=1" anywhere in the URL active_slide_video_src = active_slide_video_src.replace(/&(amp;)?autoplay=1/, ''); // Delays the URL update so that the cross-fade animation's smoothness is not affected setTimeout(() => { $active_slide_video.attr({ src: active_slide_video_src, }); }, settings.fade_speed); // Restores video overlay $active_slide_video.parents('.et_pb_video_box').next('.et_pb_video_overlay').css({ display: 'block', opacity: 1, }); } $et_slider.trigger('simple_slider_before_move_to', { direction, next_slide: $next_slide }); $et_slide.each(function() { $(this).css('zIndex', 1); }); // add 'slide-status' data attribute so it can be used to determine active slide in Visual Builder $active_slide.css('zIndex', 2).removeClass('et-pb-active-slide').addClass('et-pb-moved-slide').data('slide-status', 'inactive'); $next_slide.css({ display: 'block', opacity: 0 }).addClass('et-pb-active-slide').data('slide-status', 'active'); et_fix_slide_video_height(); et_fix_slider_content_images(); et_fix_builder_content(); if (settings.use_controls) $et_slider_controls.removeClass(settings.control_active_class).eq(et_active_slide).addClass(settings.control_active_class); if (settings.use_carousel && $et_slider_carousel_controls) $et_slider_carousel_controls.removeClass(settings.control_active_class).eq(et_active_slide).addClass(settings.control_active_class); if (! settings.tabs_animation) { $next_slide.animate({ opacity: 1 }, et_fade_speed); $active_slide.addClass('et_slide_transition').css({ display: 'list-item', opacity: 1 }).animate({ opacity: 0 }, et_fade_speed, function() { const active_slide_layout_bg_color = et_get_bg_layout_color($active_slide); const next_slide_layout_bg_color = et_get_bg_layout_color($next_slide); // Builder dynamically updates the slider options, so no need to set `display: none;` because it creates unwanted visual effects. if (isBuilder) { $(this).removeClass('et_slide_transition'); } else { $(this).css('display', 'none').removeClass('et_slide_transition'); } et_stop_video($active_slide); $et_slider .removeClass(active_slide_layout_bg_color) .addClass(next_slide_layout_bg_color); $et_slider.et_animation_running = false; $et_slider.trigger('simple_slider_after_move_to', { next_slide: $next_slide }); }); } else { $next_slide.css({ display: 'none', opacity: 0 }); $active_slide.addClass('et_slide_transition').css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, et_fade_speed, function() { $(this).css('display', 'none').removeClass('et_slide_transition'); $next_slide.css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, et_fade_speed, () => { $et_slider.et_animation_running = false; $et_slider.trigger('simple_slider_after_move_to', { next_slide: $next_slide }); $(window).trigger('resize'); }); }); } if ($next_slide.find('.et_parallax_bg').length) { // reinit parallax on slide change to make sure it displayed correctly window.et_pb_parallax_init($next_slide.find('.et_parallax_bg')); } et_slider_auto_rotate(); }; }; $.fn.et_pb_simple_slider = function(options) { return this.each(function() { const slider = $.data(this, 'et_pb_simple_slider'); return slider || new $.et_pb_simple_slider(this, options); }); }; const et_hash_module_seperator = '||'; const et_hash_module_param_seperator = '|'; function process_et_hashchange(hash) { // Bail early when hash is empty if (! hash.length) { return; } let modules; let module_params; let element; if ((hash.indexOf(et_hash_module_seperator, 0)) !== - 1) { modules = hash.split(et_hash_module_seperator); for (let i = 0; i < modules.length; i++) { module_params = modules[i].split(et_hash_module_param_seperator); element = module_params[0]; module_params.shift(); if (element.length && $(`#${element}`).length) { $(`#${element}`).trigger({ type: 'et_hashchange', params: module_params, }); } } } else { module_params = hash.split(et_hash_module_param_seperator); element = module_params[0]; module_params.shift(); if (element.length && $(`#${element}`).length) { $(`#${element}`).trigger({ type: 'et_hashchange', params: module_params, }); } } } function et_set_hash(module_state_hash) { const module_id = module_state_hash.split(et_hash_module_param_seperator)[0]; if (! $(`#${module_id}`).length) { return; } if (window.location.hash) { var hash = window.location.hash.substring(1); // Puts hash in variable, and removes the # character const new_hash = []; if ((hash.indexOf(et_hash_module_seperator, 0)) !== - 1) { const modules = hash.split(et_hash_module_seperator); let in_hash = false; for (let i = 0; i < modules.length; i++) { var element = modules[i].split(et_hash_module_param_seperator)[0]; if (element === module_id) { new_hash.push(module_state_hash); in_hash = true; } else { new_hash.push(modules[i]); } } if (! in_hash) { new_hash.push(module_state_hash); } } else { const module_params = hash.split(et_hash_module_param_seperator); var element = module_params[0]; if (element !== module_id) { new_hash.push(hash); } new_hash.push(module_state_hash); } hash = new_hash.join(et_hash_module_seperator); } else { hash = module_state_hash; } const yScroll = document.body.scrollTop; window.location.hash = hash; document.body.scrollTop = yScroll; } $.et_pb_simple_carousel = function(el, options) { const settings = $.extend({ slide_duration: 500, }, options); const $et_carousel = $(el); const $carousel_items = $et_carousel.find('.et_pb_carousel_items'); const $the_carousel_items = $carousel_items.find('.et_pb_carousel_item'); $et_carousel.et_animation_running = false; $et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', event => { set_carousel_columns($et_carousel); set_carousel_height($et_carousel); }); $carousel_items.data('items', $the_carousel_items.toArray()); $et_carousel.data('columns_setting_up', false); $carousel_items.prepend(`${''); set_carousel_columns($et_carousel); set_carousel_height($et_carousel); const $et_carousel_next = $et_carousel.find('.et-pb-arrow-next'); const $et_carousel_prev = $et_carousel.find('.et-pb-arrow-prev'); $et_carousel.on('click', '.et-pb-arrow-next', () => { if ($et_carousel.et_animation_running) return false; $et_carousel.et_carousel_move_to('next'); return false; }); $et_carousel.on('click', '.et-pb-arrow-prev', () => { if ($et_carousel.et_animation_running) return false; $et_carousel.et_carousel_move_to('previous'); return false; }); // swipe support requires et-jquery-touch-mobile $et_carousel.on('swipeleft', () => { $et_carousel.et_carousel_move_to('next'); }); $et_carousel.on('swiperight', () => { $et_carousel.et_carousel_move_to('previous'); }); function set_carousel_height($the_carousel) { const carousel_items_width = $the_carousel_items.width(); let carousel_items_height = $the_carousel_items.height(); // Account for borders when needed if ($the_carousel.parent().hasClass('et_pb_with_border')) { carousel_items_height = $the_carousel_items.outerHeight(); } $carousel_items.css('height', `${carousel_items_height}px`); } function set_carousel_columns($the_carousel) { let columns = 3; const $carousel_parent = $the_carousel.parents('.et_pb_column:not(".et_pb_specialty_column")'); if ($carousel_parent.hasClass('et_pb_column_4_4') || $carousel_parent.hasClass('et_pb_column_3_4') || $carousel_parent.hasClass('et_pb_column_2_3')) { if ($et_window.width() >= 768) { columns = 4; } } else if ($carousel_parent.hasClass('et_pb_column_1_4')) { if ($et_window.width() <= 480 && $et_window.width() >= 980) { columns = 2; } } else if ($carousel_parent.hasClass('et_pb_column_3_5')) { columns = 4; } else if ($carousel_parent.hasClass('et_pb_column_1_5') || $carousel_parent.hasClass('et_pb_column_1_6')) { columns = 2; } if (columns === $carousel_items.data('portfolio-columns')) { return; } if ($the_carousel.data('columns_setting_up')) { return; } $the_carousel.data('columns_setting_up', true); // store last setup column $carousel_items.removeClass(`columns-${$carousel_items.data('portfolio-columns')}`); $carousel_items.addClass(`columns-${columns}`); $carousel_items.data('portfolio-columns', columns); // kill all previous groups to get ready to re-group if ($carousel_items.find('.et-carousel-group').length) { $the_carousel_items.appendTo($carousel_items); $carousel_items.find('.et-carousel-group').remove(); } // setup the grouping const the_carousel_items = $carousel_items.data('items'); const $carousel_group = $('