PageSourceSearch

https://www.theindustry.fashion/wp-content/plugins/oxyextras/compo…/flickity/flickity-init-4.js?ver=2.3.3

js theindustry.fashion collected 2026-09-24 08:32:33 UTC 19,508 bytes, 518 lines download raw bytes

1jQuery(document).ready(oxygen_init_repeater_carousel);
2function oxygen_init_repeater_carousel($) {
3
4    Flickity.createMethods.push('_createPrevNextCells');
5
6    Flickity.prototype._createPrevNextCells = function() {
7        this.on('select', this.setPrevNextCells);
8    };
9
10    Flickity.prototype.setPrevNextCells = function() {
11        // remove classes
12        changeSlideClasses(this.previousSlide, 'remove', 'is-previous');
13        changeSlideClasses(this.nextSlide, 'remove', 'is-next');
14        // set slides
15        var previousI = fizzyUIUtils.modulo(this.selectedIndex - 1, this.slides.length);
16        var nextI = fizzyUIUtils.modulo(this.selectedIndex + 1, this.slides.length);
17        this.previousSlide = this.slides[previousI];
18        this.nextSlide = this.slides[nextI];
19        // add classes
20        changeSlideClasses(this.previousSlide, 'add', 'is-previous');
21        changeSlideClasses(this.nextSlide, 'add', 'is-next');
22    };
23
24    function changeSlideClasses(slide, method, className) {
25        if (!slide) {
26            return;
27        }
28        slide.getCellElements().forEach(function(cellElem) {
29            cellElem.classList[method](className);
30        });
31    }
32    
33    Flickity.prototype._createResizeClass = function() {
34      this.element.classList.add('flickity-resize');
35    };
36
37    Flickity.createMethods.push('_createResizeClass');
38
39    var resize = Flickity.prototype.resize;
40    Flickity.prototype.resize = function() {
41      this.element.classList.remove('flickity-resize');
42	  if (!this.isAnimating) {
43		 resize.call( this );
44	  }
45      this.element.classList.add('flickity-resize');
46    };
47
48    /* Fix for iOS15 */
49	;(function () {
50        let touchingCarousel = false
51        let startXCoordinate
52  
53        document.body.addEventListener('touchstart', e => {
54          if (e.target.closest('.flickity-slider')) {
55            touchingCarousel = true
56          } else {
57            touchingCarousel = false
58            return
59          }
60          startXCoordinate = e.touches[0].pageX
61        })
62  
63        document.body.addEventListener('touchmove', e => {
64          if (
65            !touchingCarousel ||
66            !e.cancelable ||
67            Math.abs(e.touches[0].pageX - startXCoordinate) < 4
68          ) return
69          e.preventDefault()
70          e.stopPropagation()
71        }, { passive: false })
72      }())
73
74
75    var extrasCarousel = function ( container ) {
76        
77        $(container).find('.oxy-carousel-builder').each(function(i, carousel){    
78
79        var $carousel = $( carousel ),
80            $inner = $carousel.find('.oxy-carousel-builder_inner'),
81            $carouselslider = '#' + $carousel.attr('id') + ' ' + $inner.data('carousel'),
82            $carouselcell;
83
84            if ('.oxy-dynamic-list' === $inner.data('carousel')) {
85                if ( true != $inner.data('repeater-cell') ) {
86
87                    var id_attr = $($carouselslider).children('.ct-div-block').attr('data-id');
88
89                    if (typeof id_attr !== typeof undefined && id_attr !== false) {
90                        $carouselcell = '[data-id="' + id_attr + '"]';
91                    } else {
92                        $carouselcell = '#' + $($carouselslider).children('.ct-div-block').attr('id');
93                    }
94                   
95                } else {
96                    $carouselcell = $inner.data('cell');
97                }
98            } else {
99                 $carouselcell = $inner.data('cell');
100            }
101
102        
103
104        var $prev = $inner.data('prev'),
105            $next = $inner.data('next'),
106            $contain = $inner.data('contain'),
107            $free_scroll = $inner.data('freescroll'),
108            $draggable = $inner.data('draggable'),
109            $wrap_around = $inner.data('wraparound'),
110            $group_cells = $inner.data('groupcells'),
111            $autoplay = $inner.data('autoplay'),
112            $initial_index = $inner.data('initial') - 1,
113            $accessibility = $inner.data('accessibility'),
114            $cell_align = $inner.data('cellalign'),
115            $right_to_left = $inner.data('righttoleft'),
116            $images_loaded = false == $inner.data('images-loaded') ? false : true,
117            $page_dots = $inner.data('pagedots'),
118            $percent = $inner.data('percent'),
119            $asnavfor = $inner.closest('.oxy-dynamic-list > .ct-div-block').length ? $( '#' + $inner.closest('.oxy-dynamic-list > .ct-div-block').attr('id') + ' ' +  $inner.data('asnavfor') + ' ' + $($inner.data('asnavfor')).find('.oxy-carousel-builder_inner').data('carousel') )[0] : $( $inner.data('asnavfor') + ' ' + $($inner.data('asnavfor')).find('.oxy-carousel-builder_inner').data('carousel') )[0],
120            $sync = $inner.closest('.oxy-dynamic-list > .ct-div-block').length ? '#' + $inner.closest('.oxy-dynamic-list > .ct-div-block').attr('id') + ' ' + $inner.data('sync') + ' ' + $($inner.data('sync')).find('.oxy-carousel-builder_inner').data('carousel') : $inner.data('sync') + ' ' + $($inner.data('sync')).find('.oxy-carousel-builder_inner').data('carousel'),
121            $dragthreshold = $inner.data('dragthreshold'),
122            $selectedattraction = $inner.data('selectedattraction'),
123            $friction = $inner.data('friction'),
124            $freescrollfriction = $inner.data('freescrollfriction'),
125            $bgspeed = $inner.data('bgspeed'),
126            $adaptheight = $inner.data('adaptheight'),
127            $fullscreen = $inner.data('fullscreen'),
128            $lazy = $inner.data('lazy'),
129            $bglazy = $inner.data('bg-lazy'),
130            $maybe_fade = $inner.data('fade'),
131            $pause_autoplay = $inner.data('pauseautoplay'),
132            $triggeraos = $inner.data('trigger-aos'),
133            $triggeraosDelay = $inner.data('trigger-aos-delay'),
134            $resumeAutoplay = $inner.data('resume-autoplay'),
135            $hash = $inner.data('hash'); 
136
137
138        $($carouselslider).on('ready.flickity', function(event, index) {
139
140            setTimeout(function() {
141                disable_nav(); // disable navigation on ready, depending on which cell we're on.
142            }, 0);
143
144        }); 
145        
146        
147        if (true === $triggeraos) {
148        
149            $($carouselslider).find('.aos-init').css("visibility", "hidden");
150            $($carouselslider).find('.aos-init').removeClass('aos-animate');
151
152            $($carouselslider).on( 'ready.flickity', function() {
153
154                $($carouselslider).find('.aos-init').css("visibility", "visible");
155                $($carouselslider).find('.aos-init').removeClass('aos-animate');
156
157                if (typeof AOS !== 'undefined') {
158                    AOS.refresh(true); 
159                }   
160
161                setTimeout(function(){ 
162                    $($carouselslider).find('.is-selected').siblings().find('.aos-init').removeClass('aos-animate');
163                }, $triggeraosDelay);
164            });
165            
166        }
167        
168        $inner.removeClass('oxy-carousel-builder_hidden');
169        // trigger redraw for transition
170        if (null != $($carouselslider)[0]) {
171            $($carouselslider)[0].offsetHeight;
172        }
173
174        var options = {
175            groupCells: $group_cells,
176            contain: $contain,
177            freeScroll: $free_scroll,
178            draggable: $draggable,
179            wrapAround: $wrap_around,
180            cellSelector: $carouselcell,
181            autoPlay: $autoplay,
182            accessibility: $accessibility,
183            cellAlign: $cell_align,
184            rightToLeft: $right_to_left,
185            pageDots: $page_dots,
186            percentPosition: $percent,
187            asNavFor: $asnavfor,
188            adaptiveHeight: $adaptheight,
189            dragThreshold: $dragthreshold,
190            selectedAttraction: $selectedattraction,
191            friction: $friction,
192            freeScrollFriction: $freescrollfriction,
193            imagesLoaded: $images_loaded,
194            lazyLoad: $lazy,
195            bgLazyLoad: $bglazy,
196            prevNextButtons: false,
197            watchCSS: true,
198            fullscreen: $fullscreen,
199            fade: $maybe_fade,
200            pauseAutoPlayOnHover: $pause_autoplay,
201            sync: $sync,
202            hash: $hash
203        };
204
205        if (true !== $hash) {
206            Object.assign(options, {initialIndex: $initial_index});
207        }
208        
209        var $flickityCarousel = $($carouselslider).flickity(options);
210        
211        var currentCarousel;
212
213        /* do prev/next */
214        $next = ($next === '.oxy-carousel-builder_next') ? '#' + $carousel.attr('id') + ' ' + $next : $next;
215        $prev = ($prev === '.oxy-carousel-builder_prev') ? '#' + $carousel.attr('id') + ' ' + $prev : $prev;
216
217        $($next).off('click');
218        $($next).on('click', function(e) {
219            e.preventDefault();
220            
221            if ($(this).parent('.oxy-carousel-builder').length) {
222                currentCarousel = $(this).parent('.oxy-carousel-builder').find($inner.data('carousel'));
223            } else {
224                currentCarousel = $($carouselslider);
225            }
226
227            currentCarousel.flickity('next');
228            
229            if (0 !== $autoplay) {
230                currentCarousel.flickity('pausePlayer');
231                setTimeout(function(){ currentCarousel.flickity('unpausePlayer') }, $autoplay); 
232            }
233        });
234
235        $($prev).off('click');
236        $($prev).on('click', function(e) {
237            e.preventDefault();
238            
239            if ($(this).parent('.oxy-carousel-builder').length) {
240                currentCarousel = $(this).parent('.oxy-carousel-builder').find($inner.data('carousel'));
241            } else {
242                currentCarousel = $($carouselslider);
243            }
244            
245            currentCarousel.flickity('previous');
246            
247            if (0 !== $autoplay) {
248                currentCarousel.flickity('pausePlayer');
249                //setTimeout(() => currentCarousel.flickity('unpausePlayer'), $autoplay);
250                setTimeout(function(){ currentCarousel.flickity('unpausePlayer') }, $autoplay); 
251            }
252            
253        });
254
255
256        // Cells are clickable to select
257        if (true === $inner.data('clickselect')) {
258
259            $flickityCarousel.on('staticClick.flickity', function(event, pointer, cellElement, cellIndex) {
260                if (typeof cellIndex == 'number') {
261                    $(this).flickity('selectCell', cellIndex);
262                }
263            });
264
265        }
266        
267        // Prevent click triggering.
268        $flickityCarousel.on('dragStart.flickity', function(){ $($carouselslider).find('.flickity-slider > *').css('pointer-events', 'none')});
269        $flickityCarousel.on('dragEnd.flickity', function(){ $($carouselslider).find('.flickity-slider > *').css('pointer-events', 'all')});
270
271        // Parallax Elems    
272        if (true === $inner.data('parallaxbg')) {
273
274            if ('.oxy-dynamic-list' === $inner.data('carousel')) {
275                var $parallaxCells = $flickityCarousel.find('.flickity-slider').children('.ct-div-block');
276            } else {
277                var $parallaxCells = $flickityCarousel.find($carouselcell);
278            }
279            
280
281            var docStyle = document.documentElement.style;
282            var transformProp = typeof docStyle.transform == 'string' ?
283                'transform' : 'WebkitTransform';
284
285            var flkty = $flickityCarousel.data('flickity');
286
287
288            function parallaxbg() {
289                flkty.slides.forEach(function(slide, i) {
290
291                    var $parallaxCell = $parallaxCells[i];
292                    var $parallaxElem = $($parallaxCell).find('[data-speed]');
293
294                    var x = (slide.target + flkty.x); // Cell transform
295
296                    $parallaxElem.each(function() {
297
298                        var $parallaxSpeed = $(this).attr('data-speed');
299                        var $parallaxElemDom = $(this)[0];
300                        var trans = x * (-1 / $parallaxSpeed); // Cell transform * paralax speed
301
302                        $parallaxElemDom.style[transformProp] = 'translateX(' + trans + 'px)';
303
304                    });
305
306                });
307            }
308
309            parallaxbg();
310
311            $flickityCarousel.on('scroll.flickity', function(event, progress) {
312
313                parallaxbg();
314
315            });
316
317
318        }
319        
320        // if aos
321        if (true === $triggeraos) {
322        
323            $flickityCarousel.on( 'change.flickity', function( event, index ) {
324
325                $($carouselslider).find('.aos-init').css("visibility", "hidden");
326                $($carouselslider).find('.aos-init').removeClass('aos-animate');
327
328                setTimeout(function(){ 
329                    $($carouselslider).find('.is-selected .aos-init').css("visibility", "visible");
330                     setTimeout(function(){ 
331                        $($carouselslider).find('.is-selected .aos-init').addClass('aos-animate');
332                        $($carouselslider).find('.is-selected').siblings().find('.aos-init').removeClass('aos-animate');
333                        
334                    }, 20);
335                }, $triggeraosDelay);
336
337
338            });
339            
340        }
341
342
343        // If ticker mode is selected & wraparound enabled
344        if ((true === $inner.data('tick')) && (true === $inner.data('wraparound'))) {
345
346            var tickerSpeed = $inner.data('ticker');
347
348            var flickity = null;
349            var isPaused = false;
350            const slideshowEl = document.querySelector($carouselslider);
351
352            const update = function() {
353                if (isPaused) return;
354                if (flickity.slides) {
355                    flickity.x = (flickity.x - tickerSpeed) % flickity.slideableWidth;
356                    flickity.selectedIndex = flickity.dragEndRestingSelect();
357                    flickity.updateSelectedSlide();
358                    flickity.settle(flickity.x);
359                }
360                window.requestAnimationFrame(update);
361            };
362
363            const pause = function() {
364                isPaused = true;
365            };
366
367            const play = function() {
368                if (isPaused) {
369                    isPaused = false;
370                    window.requestAnimationFrame(update);
371                }
372            };
373
374            flickity = $($carouselslider).data('flickity');
375            flickity.x = 0;
376            
377            if (true === $inner.data('tickerpause')) {
378
379                slideshowEl.addEventListener('mouseenter', pause, false);
380                slideshowEl.addEventListener('focusin', pause, false);
381                slideshowEl.addEventListener('mouseleave', play, false);
382                slideshowEl.addEventListener('focusout', play, false);
383            
384            }
385
386            flickity.on('dragStart', function() {
387                isPaused = true;
388            });
389
390
391            update();
392
393        }
394
395        $flickityCarousel.on('select.flickity', function(event, index) {
396            disable_nav();
397        });
398        
399        
400        
401        $flickityCarousel.on( 'fullscreenChange.flickity', function( event, isFullscreen ) {
402            
403            if (true === isFullscreen) {
404                $($prev).addClass('oxy-carousel-builder_icon-fullscreen');
405                $($next).addClass('oxy-carousel-builder_icon-fullscreen');
406            } else {
407                $($prev).removeClass('oxy-carousel-builder_icon-fullscreen');
408                $($next).removeClass('oxy-carousel-builder_icon-fullscreen');
409            }
410            
411            setTimeout(function(){
412                $flickityCarousel.flickity('resize');
413            }, 300); // wait
414        });
415        
416        
417
418        function disable_nav() {
419
420            // Only if wraparound disabled, othwerwise no end
421            if (false === $inner.data('wraparound')) {
422
423                var flickity = $($carouselslider).data('flickity');
424                
425                if ( null != flickity.selectedCell ) {
426
427                    var target = flickity.selectedCell.target;
428                    
429                    if (!flickity.slides[flickity.selectedIndex - 1] && !flickity.slides[flickity.selectedIndex + 1]) {
430                        $($prev).addClass('oxy-carousel-builder_icon_disabled');
431                        $($next).addClass('oxy-carousel-builder_icon_disabled');
432                    } else if (!flickity.slides[flickity.selectedIndex - 1]) {
433                        $($prev).addClass('oxy-carousel-builder_icon_disabled');
434                        $($next).removeClass('oxy-carousel-builder_icon_disabled');
435                      } else if (!flickity.slides[flickity.selectedIndex + 1]) {
436                        $($next).addClass('oxy-carousel-builder_icon_disabled');
437                        $($prev).removeClass('oxy-carousel-builder_icon_disabled');
438                      } else {
439                        $($prev).removeClass('oxy-carousel-builder_icon_disabled');
440                        $($next).removeClass('oxy-carousel-builder_icon_disabled');
441                      }
442
443                }
444
445            }
446        }
447        
448        if ((0 !== $autoplay) && (null != $resumeAutoplay)) {
449            
450            $flickityCarousel.on( 'dragEnd.flickity', function() {
451                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
452            });
453
454            $flickityCarousel.on( 'staticClick.flickity', function() {
455                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
456            });
457
458            $flickityCarousel.on( 'pointerMove.flickity', function() {
459                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
460            });
461            
462        }
463        
464        $carousel.find('.oxy-carousel-next').parent('.oxy-carousel-navigation').addClass('oxy-carousel-navigation_next');
465        $carousel.find('.oxy-carousel-previous').parent('.oxy-carousel-navigation').addClass('oxy-carousel-navigation_prev');
466        
467        $(window).on('load', function(){
468            $flickityCarousel.flickity('resize');
469        });
470
471        if ($($carouselslider).has('.oxy-read-more-less')) {
472            $($carouselslider).find('.oxy-read-more-less').on('extras_readmore:expand extras_readmore:collapse', function() {
473		
474                setTimeout(function(){
475                    $flickityCarousel.flickity('resize');
476                }, 5);
477            
478            });
479        }
480
481    }); 
482    
483    // If inside tabs, make sure carousel resizes as tabs are opened
484        if ($('.oxy-tab-content').length) {
485
486            // do not run the code in Oxygen
487	        if(window.angular) return;
488
489            if ($('.oxy-tab-content').has('.oxy-carousel-builder')) {
490
491                $('.oxy-tabs').on('click', function() {
492
493                    let tabContent = '#' + $(this).attr('data-oxy-tabs-contents-wrapper');
494                    let tabCarousels = $(tabContent).find('.oxy-carousel-builder');
495        
496                    tabCarousels.each(function() {
497            
498                        let tabflkty = Flickity.data($(this).find('.flickity-enabled')[0]);
499            
500                        setTimeout(function() {
501                            tabflkty.resize();
502                        }, 20);
503            
504                    });
505
506                });
507
508            }
509        }
510
511    };
512
513    extrasCarousel('body');
514
515    // Expose function
516    window.doExtrasCarousel = extrasCarousel;
517
518};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.