PageSourceSearch

https://www.cytivalifesciences.co.kr/wp-content/plugins/oxyextras/…/flickity/flickity-init-4.js?ver=2.3.5

js cytivalifesciences.co.kr collected 2026-10-08 07:24:54 UTC 24,304 bytes, 618 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    // iOS Safari fix: Patch onresize to only trigger when width changes
49    var originalOnResize = Flickity.prototype.onresize;
50    Flickity.prototype.onresize = function() {
51      var currentWidth = this.element.offsetWidth;
52      
53      if (this._lastResizeWidth === undefined || currentWidth !== this._lastResizeWidth) {
54        this._lastResizeWidth = currentWidth;
55        originalOnResize.call(this);
56      }
57    };
58
59    /* Fix for iOS15 */
60	;(function () {
61        let touchingCarousel = false
62        let startXCoordinate
63  
64        document.body.addEventListener('touchstart', e => {
65          if (e.target.closest('.flickity-slider')) {
66            touchingCarousel = true
67          } else {
68            touchingCarousel = false
69            return
70          }
71          startXCoordinate = e.touches[0].pageX
72        })
73  
74        document.body.addEventListener('touchmove', e => {
75          if (
76            !touchingCarousel ||
77            !e.cancelable ||
78            Math.abs(e.touches[0].pageX - startXCoordinate) < 4
79          ) return
80          e.preventDefault()
81          e.stopPropagation()
82        }, { passive: false })
83      }())
84
85
86    var extrasCarousel = function ( container ) {
87        
88        $(container).find('.oxy-carousel-builder').each(function(i, carousel){    
89
90        var $carousel = $( carousel ),
91            $inner = $carousel.find('.oxy-carousel-builder_inner'),
92            $carouselslider = '#' + $carousel.attr('id') + ' ' + $inner.data('carousel'),
93            $carouselcell;
94
95            if ('.oxy-dynamic-list' === $inner.data('carousel')) {
96                if ( true != $inner.data('repeater-cell') ) {
97
98                    var id_attr = $($carouselslider).children('.ct-div-block').attr('data-id');
99
100                    if (typeof id_attr !== typeof undefined && id_attr !== false) {
101                        $carouselcell = '[data-id="' + id_attr + '"]';
102                    } else {
103                        $carouselcell = '#' + $($carouselslider).children('.ct-div-block').attr('id');
104                    }
105                   
106                } else {
107                    $carouselcell = $inner.data('cell');
108                }
109            } else {
110                 $carouselcell = $inner.data('cell');
111            }
112
113        
114
115        var $prev = $inner.data('prev'),
116            $next = $inner.data('next'),
117            $contain = $inner.data('contain'),
118            $free_scroll = $inner.data('freescroll'),
119            $draggable = $inner.data('draggable'),
120            $wrap_around = $inner.data('wraparound'),
121            $group_cells = $inner.data('groupcells'),
122            $autoplay = $inner.data('autoplay'),
123            $initial_index = $inner.data('initial') - 1,
124            $accessibility = $inner.data('accessibility'),
125            $cell_align = $inner.data('cellalign'),
126            $right_to_left = $inner.data('righttoleft'),
127            $images_loaded = false == $inner.data('images-loaded') ? false : true,
128            $page_dots = $inner.data('pagedots'),
129            $percent = $inner.data('percent'),
130            $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],
131            $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'),
132            $dragthreshold = $inner.data('dragthreshold'),
133            $selectedattraction = $inner.data('selectedattraction'),
134            $friction = $inner.data('friction'),
135            $freescrollfriction = $inner.data('freescrollfriction'),
136            $bgspeed = $inner.data('bgspeed'),
137            $adaptheight = $inner.data('adaptheight'),
138            $fullscreen = $inner.data('fullscreen'),
139            $lazy = $inner.data('lazy'),
140            $bglazy = $inner.data('bg-lazy'),
141            $maybe_fade = $inner.data('fade'),
142            $pause_autoplay = $inner.data('pauseautoplay'),
143            $triggeraos = $inner.data('trigger-aos'),
144            $triggeraosDelay = $inner.data('trigger-aos-delay'),
145            $resumeAutoplay = $inner.data('resume-autoplay'),
146            $hash = $inner.data('hash'),
147            $fixHiddenFocus = $inner.data('fix-hidden-focus'); 
148
149        // Accessibility fix: Prevent focus on hidden slides
150        function manageSlideFocus() {
151            if (true !== $fixHiddenFocus) return;
152            var flickity = $($carouselslider).data('flickity');
153            if (!flickity) return;
154            
155            // Find all focusable elements selector
156            var focusableSelector = 'a, button, input, select, textarea, [tabindex]:not
156([tabindex="-1"])';
157            
158            flickity.slides.forEach(function(slide, i) {
159                var cell = slide.cells[0].element;
160                var isHidden = cell.getAttribute('aria-hidden') === 'true';
161                
162                // Check if the cell itself is focusable (e.g., an <a> tag)
163                if (cell.matches(focusableSelector)) {
164                    if (isHidden) {
165                        if (!cell.hasAttribute('data-oxy-carousel-tabindex')) {
166                            cell.setAttribute('data-oxy-carousel-tabindex', 'modified');
167                            cell.setAttribute('tabindex', '-1');
168                        }
169                    } else {
170                        if (cell.hasAttribute('data-oxy-carousel-tabindex')) {
171                            cell.removeAttribute('data-oxy-carousel-tabindex');
172                            cell.removeAttribute('tabindex');
173                        }
174                    }
175                }
176                
177                // Also check focusable elements inside the cell
178                var focusableElements = cell.querySelectorAll(focusableSelector);
179                
180                focusableElements.forEach(function(element) {
181                    if (isHidden) {
182                        // Hidden slide: disable focus and mark with data attribute
183                        if (!element.hasAttribute('data-oxy-carousel-tabindex')) {
184                            element.setAttribute('data-oxy-carousel-tabindex', 'modified');
185                            element.setAttribute('tabindex', '-1');
186                        }
187                    } else {
188                        // Visible slide: restore focus if we modified it
189                        if (element.hasAttribute('data-oxy-carousel-tabindex')) {
190                            element.removeAttribute('data-oxy-carousel-tabindex');
191                            element.removeAttribute('tabindex');
192                        }
193                    }
194                });
195            });
196        }
197
198        $($carouselslider).on('ready.flickity', function(event, index) {
199
200            setTimeout(function() {
201                disable_nav(); // disable navigation on ready, depending on which cell we're on.
202                manageSlideFocus(); // Fix accessibility on ready
203            }, 0);
204
205        }); 
206        
207        
208        if (true === $triggeraos) {
209        
210            $($carouselslider).find('.aos-init').css("visibility", "hidden");
211            $($carouselslider).find('.aos-init').removeClass('aos-animate');
212
213            $($carouselslider).on( 'ready.flickity', function() {
214
215                $($carouselslider).find('.aos-init').css("visibility", "visible");
216                $($carouselslider).find('.aos-init').removeClass('aos-animate');
217
218                if (typeof AOS !== 'undefined') {
219                    AOS.refresh(true); 
220                }   
221
222                setTimeout(function(){ 
223                    $($carouselslider).find('.is-selected').siblings().find('.aos-init').removeClass('aos-animate');
224                }, $triggeraosDelay);
225            });
226            
227        }
228        
229        $inner.removeClass('oxy-carousel-builder_hidden');
230        // trigger redraw for transition
231        if (null != $($carouselslider)[0]) {
232            $($carouselslider)[0].offsetHeight;
233        }
234
235        var options = {
236            groupCells: $group_cells,
237            contain: $contain,
238            freeScroll: $free_scroll,
239            draggable: $draggable,
240            wrapAround: $wrap_around,
241            cellSelector: $carouselcell,
242            autoPlay: $autoplay,
243            accessibility: $accessibility,
244            cellAlign: $cell_align,
245            rightToLeft: $right_to_left,
246            pageDots: $page_dots,
247            percentPosition: $percent,
248            asNavFor: $asnavfor,
249            adaptiveHeight: $adaptheight,
250            dragThreshold: $dragthreshold,
251            selectedAttraction: $selectedattraction,
252            friction: $friction,
253            freeScrollFriction: $freescrollfriction,
254            imagesLoaded: $images_loaded,
255            lazyLoad: $lazy,
256            bgLazyLoad: $bglazy,
257            prevNextButtons: false,
258            watchCSS: true,
259            fullscreen: $fullscreen,
260            fade: $maybe_fade,
261            pauseAutoPlayOnHover: $pause_autoplay,
262            sync: $sync,
263            hash: $hash
264        };
265
266        if (true !== $hash) {
267            Object.assign(options, {initialIndex: $initial_index});
268        }
269        
270        var $flickityCarousel = $($carouselslider).flickity(options);
271        
272        // Add change event handler for accessibility fix
273        $flickityCarousel.on('change.flickity', manageSlideFocus);
274        
275        // Add focusin handler to catch when user tabs into hidden slides
276        if (true === $fixHiddenFocus) {
277            $($carouselslider).on('focusin', function(e) {
278                var $target = $(e.target);
279                var $cell = $target.closest('.flickity-slider > *');
280                
281                // If focus landed on an element in an aria-hidden slide
282                if ($cell.length && $cell.attr('aria-hidden') === 'true') {
283                    // Remove focus from the hidden element
284                    e.target.blur();
285                    // Run manageSlideFocus to ensure all tabindex values are correct
286                    manageSlideFocus();
287                }
288            });
289        }
290        
291        var currentCarousel;
292
293        /* do prev/next */
294        $next = ($next === '.oxy-carousel-builder_next') ? '#' + $carousel.attr('id') + ' ' + $next : $next;
295        $prev = ($prev === '.oxy-carousel-builder_prev') ? '#' + $carousel.attr('id') + ' ' + $prev : $prev;
296
297        $($next).off('click');
298        $($next).on('click', function(e) {
299            e.preventDefault();
300            
301            if ($(this).parent('.oxy-carousel-builder').length) {
302                currentCarousel = $(this).parent('.oxy-carousel-builder').find($inner.data('carousel'));
303            } else {
304                currentCarousel = $($carouselslider);
305            }
306
307            currentCarousel.flickity('next');
308            
309            if (0 !== $autoplay) {
310                currentCarousel.flickity('pausePlayer');
311                setTimeout(function(){ currentCarousel.flickity('unpausePlayer') }, $autoplay); 
312            }
313        });
314
315        $($prev).off('click');
316        $($prev).on('click', function(e) {
317            e.preventDefault();
318            
319            if ($(this).parent('.oxy-carousel-builder').length) {
320                currentCarousel = $(this).parent('.oxy-carousel-builder').find($inner.data('carousel'));
321            } else {
322                currentCarousel = $($carouselslider);
323            }
324            
325            currentCarousel.flickity('previous');
326            
327            if (0 !== $autoplay) {
328                currentCarousel.flickity('pausePlayer');
329                //setTimeout(() => currentCarousel.flickity('unpausePlayer'), $autoplay);
330                setTimeout(function(){ currentCarousel.flickity('unpausePlayer') }, $autoplay); 
331            }
332            
333        });
334
335        // Keyboard navigation for prev/next buttons
336        $($next).off('keydown');
337        $($next).on('keydown', function(e) {
338            if (e.key === 'Enter' || e.key === ' ') {
339                e.preventDefault();
340                if ($(this).attr('aria-disabled') !== 'true') {
341                    $(this).trigger('click');
342                }
343            }
344        });
345
346        $($prev).off('keydown');
347        $($prev).on('keydown', function(e) {
348            if (e.key === 'Enter' || e.key === ' ') {
349                e.preventDefault();
350                if ($(this).attr('aria-disabled') !== 'true') {
351                    $(this).trigger('click');
352                }
353            }
354        });
355
356        // Cells are clickable to select
357        if (true === $inner.data('clickselect')) {
358
359            $flickityCarousel.on('staticClick.flickity', function(event, pointer, cellElement, cellIndex) {
360                if (typeof cellIndex == 'number') {
361                    $(this).flickity('selectCell', cellIndex);
362                }
363            });
364
365        }
366        
367        // Prevent click triggering.
368        $flickityCarousel.on('dragStart.flickity', function(){ $($carouselslider).find('.flickity-slider >
368 *').css('pointer-events', 'none')});
369        $flickityCarousel.on('dragEnd.flickity', function(){ $($carouselslider).find('.flickity-slider > *').css('pointer-events', 'all')});
370
371        // Parallax Elems    
372        if (true === $inner.data('parallaxbg')) {
373
374            if ('.oxy-dynamic-list' === $inner.data('carousel')) {
375                var $parallaxCells = $flickityCarousel.find('.flickity-slider').children('.ct-div-block');
376            } else {
377                var $parallaxCells = $flickityCarousel.find($carouselcell);
378            }
379            
380
381            var docStyle = document.documentElement.style;
382            var transformProp = typeof docStyle.transform == 'string' ?
383                'transform' : 'WebkitTransform';
384
385            var flkty = $flickityCarousel.data('flickity');
386
387
388            function parallaxbg() {
389                flkty.slides.forEach(function(slide, i) {
390
391                    var $parallaxCell = $parallaxCells[i];
392                    var $parallaxElem = $($parallaxCell).find('[data-speed]');
393
394                    var x = (slide.target + flkty.x); // Cell transform
395
396                    $parallaxElem.each(function() {
397
398                        var $parallaxSpeed = $(this).attr('data-speed');
399                        var $parallaxElemDom = $(this)[0];
400                        var trans = x * (-1 / $parallaxSpeed); // Cell transform * paralax speed
401
402                        $parallaxElemDom.style[transformProp] = 'translateX(' + trans + 'px)';
403
404                    });
405
406                });
407            }
408
409            parallaxbg();
410
411            $flickityCarousel.on('scroll.flickity', function(event, progress) {
412
413                parallaxbg();
414
415            });
416
417
418        }
419        
420        // if aos
421        if (true === $triggeraos) {
422        
423            $flickityCarousel.on( 'change.flickity', function( event, index ) {
424
425                $($carouselslider).find('.aos-init').css("visibility", "hidden");
426                $($carouselslider).find('.aos-init').removeClass('aos-animate');
427
428                setTimeout(function(){ 
429                    $($carouselslider).find('.is-selected .aos-init').css("visibility", "visible");
430                     setTimeout(function(){ 
431                        $($carouselslider).find('.is-selected .aos-init').addClass('aos-animate');
432                        $($carouselslider).find('.is-selected').siblings().find('.aos-init').removeClass('aos-animate');
433                        
434                    }, 20);
435                }, $triggeraosDelay);
436
437
438            });
439            
440        }
441
442
443        // If ticker mode is selected & wraparound enabled
444        if ((true === $inner.data('tick')) && (true === $inner.data('wraparound'))) {
445
446            var tickerSpeed = $inner.data('ticker');
447
448            var flickity = null;
449            var isPaused = false;
450            const slideshowEl = document.querySelector($carouselslider);
451
452            const update = function() {
453                if (isPaused) return;
454                if (flickity.slides) {
455                    flickity.x = (flickity.x - tickerSpeed) % flickity.slideableWidth;
456                    flickity.selectedIndex = flickity.dragEndRestingSelect();
457                    flickity.updateSelectedSlide();
458                    flickity.settle(flickity.x);
459                }
460                window.requestAnimationFrame(update);
461            };
462
463            const pause = function() {
464                isPaused = true;
465            };
466
467            const play = function() {
468                if (isPaused) {
469                    isPaused = false;
470                    window.requestAnimationFrame(update);
471                }
472            };
473
474            flickity = $($carouselslider).data('flickity');
475            flickity.x = 0;
476            
477            if (true === $inner.data('tickerpause')) {
478
479                slideshowEl.addEventListener('mouseenter', pause, false);
480                slideshowEl.addEventListener('focusin', pause, false);
481                slideshowEl.addEventListener('mouseleave', play, false);
482                slideshowEl.addEventListener('focusout', play, false);
483            
484            }
485
486            flickity.on('dragStart', function() {
487                isPaused = true;
488            });
489
490
491            update();
492
493        }
494
495        $flickityCarousel.on('select.flickity', function(event, index) {
496            disable_nav();
497        });
498        
499        
500        
501        $flickityCarousel.on( 'fullscreenChange.flickity', function( event, isFullscreen ) {
502            
503            if (true === isFullscreen) {
504                $($prev).addClass('oxy-carousel-builder_icon-fullscreen');
505                $($next).addClass('oxy-carousel-builder_icon-fullscreen');
506            } else {
507                $($prev).removeClass('oxy-carousel-builder_icon-fullscreen');
508                $($next).removeClass('oxy-carousel-builder_icon-fullscreen');
509            }
510            
511            setTimeout(function(){
512                $flickityCarousel.flickity('resize');
513            }, 300); // wait
514        });
515        
516        
517
518        function disable_nav() {
519
520            // Only if wraparound disabled, othwerwise no end
521            if (false === $inner.data('wraparound')) {
522
523                var flickity = $($carouselslider).data('flickity');
524                
525                if ( null != flickity.selectedCell ) {
526
527                    var target = flickity.selectedCell.target;
528                    
529                    if (!flickity.slides[flickity.selectedIndex - 1] && !flickity.slides[flickity.selectedIndex + 1]) {
530                        $($prev).addClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'true');
531                        $($next).addClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'true');
532                    } else if (!flickity.slides[flickity.selectedIndex - 1]) {
533                        $($prev).addClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'true');
534                        $($next).removeClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'false');
535                      } else if (!flickity.slides[flickity.selectedIndex + 1]) {
536                        $($next).addClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'true');
537                        $($prev).removeClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'false');
538                      } else {
539                        $($prev).removeClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'false');
540                        $($next).removeClass('oxy-carousel-builder_icon_disabled').attr('aria-disabled', 'false');
541                      }
542
543                }
544
545            }
546        }
547        
548        if ((0 !== $autoplay) && (null != $resumeAutoplay)) {
549            
550            $flickityCarousel.on( 'dragEnd.flickity', function() {
551                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
552            });
553
554            $flickityCarousel.on( 'staticClick.flickity', function() {
555                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
556            });
557
558            $flickityCarousel.on( 'pointerMove.flickity', function() {
559                setTimeout(function(){ $($carouselslider).flickity('playPlayer')}, $resumeAutoplay);
560            });
561            
562        }
563        
564        $carousel.find('.oxy-carousel-next').parent('.oxy-carousel-navigation').addClass('oxy-carousel-navigation_next');
565        $carousel.find('.oxy-carousel-previous').parent('.oxy-carousel-navigation').addClass('oxy-carousel-navigation_prev');
566        
567        $(window).on('load', function(){
568            $flickityCarousel.flickity('resize');
569        });
570
571        if ($($carouselslider).has('.oxy-read-more-less')) {
572            $($carouselslider).find('.oxy-read-more-less').on('extras_readmore:expand extras_readmore:collapse', function() {
573		
574                setTimeout(function(){
575                    $flickityCarousel.flickity('resize');
576                }, 5);
577            
578            });
579        }
580
581    }); 
582    
583    // If inside tabs, make sure carousel resizes as tabs are opened
584        if ($('.oxy-tab-content').length) {
585
586            // do not run the code in Oxygen
587	        if(window.angular) return;
588
589            if ($('.oxy-tab-content').has('.oxy-carousel-builder')) {
590
591                $('.oxy-tabs').on('click', function() {
592
593                    let tabContent = '#' + $(this).attr('data-oxy-tabs-contents-wrapper');
594                    let tabCarousels = $(tabContent).find('.oxy-carousel-builder');
595        
596                    tabCarousels.each(function() {
597            
598                        let tabflkty = Flickity.data($(this).find('.flickity-enabled')[0]);
599            
600                        setTimeout(function() {
601                            tabflkty.resize();
602                        }, 20);
603            
604                    });
605
606                });
607
608            }
609        }
610
611    };
612
613    extrasCarousel('body');
614
615    // Expose function
616    window.doExtrasCarousel = extrasCarousel;
617
618};

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.