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