1/** 2 * Image Carousel â vanilla JS (Swiper, lazy backgrounds, responsive gallery). 3 * Magnific Popup lightbox still uses `jQuery.fn.magnificPopup` when present (jQuery plugin). 4 */ 5( function () { 6 'use strict'; 7 8 var IC_SEL = '.dsm_image_carousel_container'; 9 var IC_ROOT_SEL = '.dsm_image_carousel'; 10 11 /** Animate.css class names bundled in `dsm-supreme-animate` (strip before re-applying). */ 12 var DSM_IC_ANIM_CLASS_NAMES = [ 13 'bounce', 14 'flash', 15 'pulse', 16 'rubberBand', 17 'shake', 18 'swing', 19 'tada', 20 'wobble', 21 'jello', 22 'heartBeat', 23 'fadeIn', 24 'fadeInDown', 25 'fadeInDownBig', 26 'fadeInLeft', 27 'fadeInLeftBig', 28 'fadeInRight', 29 'fadeInRightBig', 30 'fadeInUp', 31 'fadeInUpBig', 32 'flipInX', 33 'flipInY', 34 'lightSpeedIn', 35 'rotateIn', 36 'rotateInDownLeft', 37 'rotateInDownRight', 38 'rotateInUpLeft', 39 'rotateInUpRight', 40 'slideInUp', 41 'slideInDown', 42 'slideInLeft', 43 'slideInRight', 44 'bounceIn', 45 'bounceInDown', 46 'bounceInLeft', 47 'bounceInRight', 48 'bounceInUp', 49 'zoomIn', 50 'zoomInDown', 51 'zoomInLeft', 52 'zoomInRight', 53 'zoomInUp', 54 'jackInTheBox', 55 'rollIn', 56 ]; 57 58 var DSM_IC_ANIM_OUT_CLASS_NAMES = [ 59 'bounceOut', 60 'bounceOutDown', 61 'bounceOutLeft', 62 'bounceOutRight', 63 'bounceOutUp', 64 'fadeOut', 65 'fadeOutDown', 66 'fadeOutDownBig', 67 'fadeOutLeft', 68 'fadeOutLeftBig', 69 'fadeOutRight', 70 'fadeOutRightBig', 71 'fadeOutUp', 72 'fadeOutUpBig', 73 'flipOutX', 74 'flipOutY', 75 'lightSpeedOut', 76 'rollOut', 77 'slideOutDown', 78 'slideOutLeft', 79 'slideOutRight', 80 'slideOutUp', 81 'zoomOut', 82 'zoomOutDown', 83 'zoomOutLeft', 84 'zoomOutRight', 85 'zoomOutUp', 86 ]; 87 88 var DSM_IC_ALL_TITLE_ANIM_CLASS_NAMES = DSM_IC_ANIM_CLASS_NAMES.concat( 89 DSM_IC_ANIM_OUT_CLASS_NAMES 90 ); 91 92 /** @type {WeakMap<Element, Record<string, *>>} */ 93 var icStore = new WeakMap(); 94 95 function icGet( el ) { 96 if ( ! icStore.has( el ) ) { 97 icStore.set( el, {} ); 98 } 99 return icStore.get( el ); 100 } 101 102 function dataAttrToCamel( name ) { 103 return name.replace( /-([a-z])/g, function ( _, c ) { 104 return c.toUpperCase(); 105 } ); 106 } 107 108 /** 109 * Normalize title animation duration/delay from data attributes (ms digits or legacy `1s`). 110 * 111 * @param {string|undefined|null} raw 112 * @param {string} fallbackDigits Milliseconds without unit. 113 * @returns {string} 114 */ 115 function dsmIcNormalizeCssAnimationTime( raw, fallbackDigits ) { 116 var s = raw == null ? '' : String( raw ).trim(); 117 if ( s === '' ) { 118 return fallbackDigits + 'ms'; 119 } 120 if ( /ms$/i.test( s ) ) { 121 return s; 122 } 123 if ( /^-?\d+(\.\d+)?s$/i.test( s ) ) { 124 return s; 125 } 126 if ( /^-?\d+(\.\d+)?$/.test( s ) ) { 127 return s + 'ms'; 128 } 129 return fallbackDigits + 'ms'; 130 } 131 132 /** 133 * @param {string|number|undefined|null} cssTime 134 * @returns {number} 135 */ 136 function dsmIcCssTimeToMs( cssTime ) { 137 var s = cssTime == null ? '' : String( cssTime ).trim(); 138 if ( s === '' ) { 139 return 0; 140 } 141 if ( /ms$/i.test( s ) ) { 142 return parseFloat( s ) || 0; 143 } 144 if ( /^-?\d+(\.\d+)?s$/i.test( s ) && ! /ms$/i.test( s ) ) { 145 return ( parseFloat( s ) || 0 ) * 1000; 146 } 147 var n = parseFloat( s ); 148 return isNaN( n ) ? 0 : n; 149 } 150 151 function dsmIcStripAnimateCssClasses( el ) { 152 if ( ! el ) { 153 return; 154 } 155 el.classList.remove( 'animated' ); 156 for ( var ci = 0; ci < DSM_IC_ALL_TITLE_ANIM_CLASS_NAMES.length; ci++ ) { 157 el.classList.remove( DSM_IC_ALL_TITLE_ANIM_CLASS_NAMES[ ci ] ); 158 } 159 el.style.animationDuration = ''; 160 el.style.animationDelay = ''; 161 } 162 163 function dsmIcOutTimingMsPair( container, durKey, delKey ) { 164 var oduIc = dsmIcNormalizeCssAnimationTime( 165 readData( container, durKey ), 166 '1000' 167 ); 168 var odlIc = dsmIcNormalizeCssAnimationTime( 169 readData( container, delKey ), 170 '0' 171 ); 172 return Math.ceil( 173 dsmIcCssTimeToMs( odlIc ) + dsmIcCssTimeToMs( oduIc ) + 50 174 ); 175 } 176 177 function dsmIcTheoreticalCaptionOutPadMs( container ) { 178 if ( readData( container, 'type' ) !== 'slideshow' ) { 179 return 0; 180 } 181 var max = 0; 182 var showTitle = readData( container, 'slideshow-show-slide-title' ) === true; 183 var showDesc = readData( container, 'slideshow-show-slide-description' ) === true; 184 185 var tAnim = readData( container, 'slideshow-title-animation-out' ); 186 if ( 187 showTitle && 188 ( tAnim === undefined || tAnim === null || tAnim === '' ) 189 ) { 190 tAnim = 'fadeOutDown'; 191 } 192 if ( showTitle && tAnim && tAnim !== 'none' ) { 193 max = Math.max( 194 max, 195 dsmIcOutTimingMsPair( 196 container, 197 'slideshow-title-animation-out-duration', 198 'slideshow-title-animation-out-delay' 199 ) 200 ); 201 } 202 203 var dAnim = readData( container, 'slideshow-description-animation-out' ); 204 if ( 205 showDesc &&
206 ( dAnim === undefined || dAnim === null || dAnim === '' ) 207 ) { 208 dAnim = 'fadeOutDown'; 209 } 210 if ( showDesc && dAnim && dAnim !== 'none' ) { 211 max = Math.max( 212 max, 213 dsmIcOutTimingMsPair( 214 container, 215 'slideshow-description-animation-out-duration', 216 'slideshow-description-animation-out-delay' 217 ) 218 ); 219 } 220 221 var wrapAnim = readData( container, 'slideshow-wrapper-animation-out' ); 222 if ( 223 wrapAnim && 224 wrapAnim !== 'none' && 225 ( showTitle || showDesc ) 226 ) { 227 max = Math.max( 228 max, 229 dsmIcOutTimingMsPair( 230 container, 231 'slideshow-wrapper-animation-out-duration', 232 'slideshow-wrapper-animation-out-delay' 233 ) 234 ); 235 } 236 237 return max; 238 } 239 240 function dsmIcLiveCaptionOutMsFromSlide( fromSlide, container ) { 241 if ( ! fromSlide ) { 242 return 0; 243 } 244 var showTitle = readData( container, 'slideshow-show-slide-title' ) === true; 245 var showDesc = readData( container, 'slideshow-show-slide-description' ) === true; 246 247 var wrapEl = fromSlide.querySelector( '.dsm_image_carousel_slideshow_content' ); 248 var titleEl = fromSlide.querySelector( '.dsm_image_carousel_slide_title' ); 249 var descEl = fromSlide.querySelector( '.dsm_image_carousel_slide_description' ); 250 251 var max = 0; 252 253 var tAnim = readData( container, 'slideshow-title-animation-out' ); 254 if ( 255 showTitle && 256 ( tAnim === undefined || tAnim === null || tAnim === '' ) 257 ) { 258 tAnim = 'fadeOutDown'; 259 } 260 if ( showTitle && titleEl && tAnim && tAnim !== 'none' ) { 261 max = Math.max( 262 max, 263 dsmIcOutTimingMsPair( 264 container, 265 'slideshow-title-animation-out-duration', 266 'slideshow-title-animation-out-delay' 267 ) 268 ); 269 } 270 271 var dAnim = readData( container, 'slideshow-description-animation-out' ); 272 if ( 273 showDesc && 274 ( dAnim === undefined || dAnim === null || dAnim === '' ) 275 ) { 276 dAnim = 'fadeOutDown'; 277 } 278 if ( showDesc && descEl && dAnim && dAnim !== 'none' ) { 279 max = Math.max( 280 max, 281 dsmIcOutTimingMsPair( 282 container, 283 'slideshow-description-animation-out-duration', 284 'slideshow-description-animation-out-delay' 285 ) 286 ); 287 } 288 289 var wAnim = readData( container, 'slideshow-wrapper-animation-out' ); 290 if ( wrapEl && wAnim && wAnim !== 'none' && ( showTitle || showDesc ) ) { 291 max = Math.max( 292 max, 293 dsmIcOutTimingMsPair( 294 container, 295 'slideshow-wrapper-animation-out-duration', 296 'slideshow-wrapper-animation-out-delay' 297 ) 298 ); 299 } 300 301 return max; 302 } 303 304 function parseDataValue( str ) { 305 if ( str === 'true' ) { 306 return true; 307 } 308 if ( str === 'false' ) { 309 return false; 310 } 311 if ( str === '' || str === null || typeof str === 'undefined' ) { 312 return str; 313 } 314 var n = Number( str ); 315 if ( ! isNaN( n ) && String( str ).trim() !== '' ) { 316 return n; 317 } 318 return str; 319 } 320 321 /** 322 * Read `data-*` like jQuery `.data( name )` (kebab-case key). 323 * 324 * @param {Element} el 325 * @param {string} key kebab-case, e.g. `autoplay-speed` 326 * @return {*} 327 */ 328 function readData( el, key ) { 329 var camel = dataAttrToCamel( key ); 330 if ( ! el.dataset || typeof el.dataset[ camel ] === 'undefined' ) { 331 return undefined; 332 } 333 return parseDataValue( el.dataset[ camel ] ); 334 } 335 336 var DSM_IC_LOOP_MIN_CLONE_CLASS = 'dsm-image-carousel-loop-minimum-clone'; 337 338 /** 339 * Parse a positive integer from a data-* value. Empty, 0, or NaN uses fallback (min 1). 340 * 341 * @param {*} raw 342 * @param {number|string} fallback 343 * @return {number} 344 */ 345 function dsmIcPositiveInt( raw, fallback ) { 346 var leaf = raw; 347 if ( 348 leaf && 349 typeof leaf === 'object' && 350 ! Array.isArray( leaf ) && 351 Object.prototype.hasOwnProperty.call( leaf, 'value' ) 352 ) { 353 leaf = leaf.value; 354 } 355 var n = parseFloat( 356 String( 357 leaf == null || leaf === true || leaf === false ? '' : leaf 358 ).trim() 359 ); 360 if ( ! isNaN( n ) && n >= 1 ) { 361 return Math.max( 1, Math.round( n ) ); 362 } 363 var fb = parseFloat( 364 String( 365 fallback == null || fallback === true || fallback === false 366 ? '' 367 : fallback 368 ).trim() 369 ); 370 return ! isNaN( fb ) && fb >= 1 ? Math.max( 1, Math.round( fb ) ) : 1; 371 } 372 373 /** 374 * Swiper Grid only when multiple rows is actually used. `grid.rows: 1` still 375 * enables the Grid module and can ignore slidesPerView changes (VB + FE). 376 * 377 * @param {number} rows 378 * @return {{ rows: number, fill: string }|null} 379 */ 380 function dsmIcGridIfMultiRow( rows ) { 381 var r = dsmIcPositiveInt( rows, 1 ); 382 if ( r < 2 ) { 383 return null; 384 } 385 return { 386 rows: r, 387 fill: 'row', 388 }; 389 } 390 391 /** 392 * @param {number} slidesPerView 393 * @param {number} slidesPerGroup 394 * @param {number} spaceBetween 395 * @param {number} rows 396 * @return {Object} 397 */ 398 function dsmIcBreakpointParams( 399 slidesPerView, 400 slidesPerGroup, 401 spaceBetween, 402 rows 403 ) { 404 var bp = { 405 slidesPerView: slidesPerView, 406 slidesPerGroup: slidesPerGroup, 407 spaceBetween: spaceBetween, 408 }; 409 var grid = dsmIcGridIfMultiRow( rows ); 410 if ( grid ) { 411 bp.grid = grid; 412 } 413 return bp; 414 } 415 416 /** 417 * Resolve slidesPerView from a data attr. Missing/empty uses emptyFallback (PHP: tablet 2, phone 1). 418 * 419 * @param {Element} container 420 * @param {string} key kebab-case data key 421 * @param {number} emptyFallback 422 * @return {number} 423 */
424 function dsmIcSlidesPerViewFromData( container, key, emptyFallback ) { 425 var raw = readData( container, key ); 426 if ( raw === '' || typeof raw === 'undefined' || raw === null ) { 427 return dsmIcPositiveInt( emptyFallback, 1 ); 428 } 429 return dsmIcPositiveInt( raw, emptyFallback ); 430 } 431 432 /** 433 * Numeric data attr (0 is valid). Missing/empty uses fallback. 434 * 435 * @param {*} raw 436 * @param {number} fallback 437 * @return {number} 438 */ 439 function dsmIcNumberOr( raw, fallback ) { 440 if ( raw === '' || typeof raw === 'undefined' || raw === null ) { 441 return fallback; 442 } 443 var n = Number( raw ); 444 return isNaN( n ) ? fallback : n; 445 } 446 447 /** 448 * @param {*} effectVal 449 * @param {*} typeVal 450 * @return {boolean} 451 */ 452 function dsmIcIsSingleSlideView( effectVal, typeVal ) { 453 return ( 454 'cube' === effectVal || 455 'flip' === effectVal || 456 'slideshow' === typeVal 457 ); 458 } 459 460 /** 461 * Swiper 12 loop requires slide count >= slidesPerView + slidesPerGroup (+1 when centered). 462 * 463 * @param {number} slidesPerView 464 * @param {number} slidesPerGroup 465 * @param {boolean} centeredSlides 466 * @return {number} 467 */ 468 function dsmIcGetLoopMinimumSlideCount( 469 slidesPerView, 470 slidesPerGroup, 471 centeredSlides 472 ) { 473 var spv = Math.max( 1, Number( slidesPerView ) || 1 ); 474 var spg = Math.max( 1, Number( slidesPerGroup ) || 1 ); 475 return spv + spg + ( centeredSlides ? 1 : 0 ); 476 } 477 478 /** 479 * @param {number} slideCount 480 * @param {number} slidesPerView 481 * @param {number} slidesPerGroup 482 * @param {boolean} centeredSlides 483 * @param {boolean} infinite 484 * @return {number} 485 */ 486 function dsmIcGetLoopTargetSlideCount( 487 slideCount, 488 slidesPerView, 489 slidesPerGroup, 490 centeredSlides, 491 infinite 492 ) { 493 var group = Math.max( 1, Number( slidesPerGroup ) || 1 ); 494 var count = Math.max( 0, Number( slideCount ) || 0 ); 495 var target = dsmIcGetLoopMinimumSlideCount( 496 slidesPerView, 497 group, 498 centeredSlides 499 ); 500 501 if ( infinite ) { 502 target = Math.max( 503 target, 504 Math.max( 1, Number( slidesPerView ) || 1 ) * 2, 505 6 506 ); 507 } 508 509 target = Math.max( count, target ); 510 var remainder = target % group; 511 512 if ( 0 !== remainder ) { 513 target += group - remainder; 514 } 515 516 return target; 517 } 518 519 /** 520 * @param {Element|null|undefined} wrapper 521 * @return {void} 522 */ 523 function dsmIcRemoveLoopMinClones( wrapper ) { 524 if ( ! wrapper || typeof wrapper.querySelectorAll !== 'function' ) { 525 return; 526 } 527 wrapper 528 .querySelectorAll( 529 '.' + DSM_IC_LOOP_MIN_CLONE_CLASS + ', .swiper-slide-blank' 530 ) 531 .forEach( function ( node ) { 532 if ( node.parentNode ) { 533 node.parentNode.removeChild( node ); 534 } 535 } ); 536 } 537 538 /** 539 * Pad real slides before Swiper init so loop / infinite smooth scrolling can keep 540 * breakpoint slidesPerView (card-carousel loop minimum; infinite also fills ~2Ã view). 541 * 542 * @param {Element|null|undefined} wrapper 543 * @param {{ loop?: boolean, infinite?: boolean, slidesPerView?: number, slidesPerGroup?: number, centeredSlides?: boolean }} options 544 * @return {void} 545 */ 546 function dsmIcEnsureLoopMinimumSlides( wrapper, options ) { 547 if ( ! wrapper || ! options ) { 548 return; 549 } 550 if ( ! options.loop && ! options.infinite ) { 551 return; 552 } 553 554 dsmIcRemoveLoopMinClones( wrapper ); 555 556 var realSlides = Array.prototype.filter.call( 557 wrapper.children, 558 function ( slide ) { 559 return ( 560 slide.nodeType === 1 && 561 ! slide.classList.contains( 'swiper-slide-duplicate' ) && 562 ! slide.classList.contains( 'swiper-slide-blank' ) && 563 ! slide.classList.contains( DSM_IC_LOOP_MIN_CLONE_CLASS ) 564 ); 565 } 566 ); 567 var slideCount = realSlides.length; 568 if ( slideCount === 0 ) { 569 return; 570 } 571 572 var group = Math.max( 1, Number( options.slidesPerGroup ) || 1 ); 573 var target = dsmIcGetLoopTargetSlideCount( 574 slideCount, 575 options.slidesPerView, 576 group, 577 !! options.centeredSlides, 578 !! options.infinite 579 ); 580 581 if ( slideCount >= target && 0 === slideCount % group ) { 582 return; 583 } 584 585 var totalSlides = slideCount; 586 var cycle = 0; 587 var maxSlides = target + slideCount * group; 588 589 while ( 590 ( totalSlides < target || 0 !== totalSlides % group ) && 591 totalSlides < maxSlides 592 ) { 593 var src = realSlides[ cycle % slideCount ]; 594 if ( ! src ) { 595 break; 596 } 597 var clone = src.cloneNode( true ); 598 [ 599 'swiper-slide-active', 600 'swiper-slide-next', 601 'swiper-slide-prev', 602 'swiper-slide-fully-visible', 603 'swiper-slide-visible', 604 ].forEach( function ( cls ) { 605 clone.classList.remove( cls ); 606 } ); 607 clone.removeAttribute( 'data-swiper-slide-index' ); 608 clone.classList.add( DSM_IC_LOOP_MIN_CLONE_CLASS ); 609 clone.setAttribute( 'aria-hidden', 'true' ); 610 wrapper.appendChild( clone ); 611 totalSlides += 1; 612 cycle += 1; 613 } 614 } 615 616 function nextSiblingMatch( el, selector ) { 617 var s = el.nextElementSibling; 618 while ( s ) { 619 if ( s.matches && s.matches( selector ) ) { 620 return s; 621 } 622 s = s.nextElementSibling; 623 } 624 return null; 625 } 626 627 function siblingsMatch( el, selector ) { 628 var p = el.parentElement; 629 if ( ! p ) { 630 return []; 631 } 632 return Array.prototype.filter.call( p.children, function ( c ) { 633 return c !== el && c.matches( selector ); 634 } ); 635 } 636 637 function dsmIcGetGalleryBreakpoint() { 638 if ( window.matchMedia( '(min-width: 981px)' ).matches ) { 639 return 'desktop'; 640 } 641 if ( window.matchMedia( '(min-width: 768px)' ).matches ) { 642 return 'tablet'; 643 } 644 return 'phone'; 645 } 646 647 function dsmIcParseResponsivePayload( container ) { 648 var script = nextSiblingMatch( container, '.dsm-ic-responsive-gallery' ); 649 if ( ! script ) { 650 return null; 651 } 652 try { 653 return JSON.parse( script.textContent || '' ); 654 } catch ( e ) { 655 return null; 656 } 657 } 658 659 function dsmIcApplyResponsiveGallery( container, payload ) { 660 if ( ! payload ) { 661 return; 662 } 663 var bp = dsmIcGetGalleryBreakpoint(); 664 var mainWrapper = container.querySelector( '.swiper-wrapper' ); 665 var thumbs = siblingsMatch( container, '.dsm_image_gallery_thumbs' )[ 0 ]; 666 var thumbWrapper = thumbs 667 ? thumbs.querySelector( '.swiper-wrapper' ) 668 : null; 669 670 var st = icGet( container ); 671 if ( ! st.dsmIcDesktopMainHtml && mainWrapper ) { 672 st.dsmIcDesktopMainHtml = mainWrapper.innerHTML; 673 if ( thumbWrapper ) { 674 st.dsmIcDesktopThumbsHtml = thumbWrapper.innerHTML; 675 } 676 } 677 678 var htmlMain = st.dsmIcDesktopMainHtml; 679 var htmlThumbs = st.dsmIcDesktopThumbsHtml || ''; 680 var typeVal = readData( container, 'type' ); 681 682 if ( bp === 'tablet' && payload.tablet && payload.tablet.main ) { 683 htmlMain = payload.tablet.main; 684 if ( 'slideshow' === typeVal && payload.tablet.thumbs ) { 685 htmlThumbs = payload.tablet.thumbs; 686 } 687 } else if ( bp === 'phone' ) { 688 if ( payload.phone && payload.phone.main ) { 689 htmlMain = payload.phone.main; 690 if ( 'slideshow' === typeVal && payload.phone.thumbs ) { 691 htmlThumbs = payload.phone.thumbs; 692 } 693 } else if ( payload.tablet && payload.tablet.main ) { 694 htmlMain = payload.tablet.main; 695 if ( 'slideshow' === typeVal && payload.tablet.thumbs ) { 696 htmlThumbs = payload.tablet.thumbs; 697 } 698 } 699 } 700 701 if ( mainWrapper ) { 702 mainWrapper.innerHTML = htmlMain; 703 } 704 if ( thumbWrapper && htmlThumbs ) { 705 thumbWrapper.innerHTML = htmlThumbs; 706 } 707 } 708 709 function dsmIcDebouncedResize( fn, ms ) { 710 var t; 711 return function () { 712 clearTimeout( t ); 713 t = setTimeout( fn, ms ); 714 }; 715 } 716 717 /** 718 * @param {Element} root Module root (`.dsm_image_carousel`). 719 */
720 function dsmIcObserveLazyBackgrounds( root ) { 721 if ( 722 ! root || 723 typeof IntersectionObserver === 'undefined' 724 ) { 725 return; 726 } 727 var pending = root.querySelectorAll( 728 '[data-dsm-lazy-bg]:not([data-dsm-bg-loaded])' 729 ); 730 if ( ! pending.length ) { 731 return; 732 } 733 var obs = new IntersectionObserver( 734 function ( entries ) { 735 entries.forEach( function ( entry ) { 736 if ( ! entry.isIntersecting ) { 737 return; 738 } 739 var el = entry.target; 740 var url = el.getAttribute( 'data-dsm-lazy-bg' ); 741 if ( url ) { 742 el.style.backgroundImage = 743 'url("' + 744 url.replace( /\\/g, '\\\\' ).replace( /"/g, '\\"' ) + 745 '")'; 746 el.setAttribute( 'data-dsm-bg-loaded', '1' ); 747 } 748 obs.unobserve( el ); 749 } ); 750 }, 751 { rootMargin: '200px 0px', threshold: 0.01 } 752 ); 753 Array.prototype.forEach.call( pending, function ( el ) { 754 obs.observe( el ); 755 } ); 756 } 757 758 /** 759 * Magnific `item.el` may be jQuery or DOM. 760 * 761 * @param {*} el 762 * @return {Element|null} 763 */ 764 function toDom( el ) { 765 if ( ! el ) { 766 return null; 767 } 768 if ( el.nodeType === 1 ) { 769 return el; 770 } 771 if ( el[ 0 ] && el[ 0 ].nodeType === 1 ) { 772 return el[ 0 ]; 773 } 774 return null; 775 } 776 777 function initMagnificWhenPossible( rootEl, options ) { 778 if ( 779 typeof window.jQuery !== 'undefined' && 780 window.jQuery.fn && 781 window.jQuery.fn.magnificPopup 782 ) { 783 window.jQuery( rootEl ).magnificPopup( options ); 784 } 785 } 786 787 function bindLightboxForContainers( containers ) { 788 Array.prototype.forEach.call( containers, function ( container ) { 789 var carouselType = container.getAttribute( 'data-type' ); 790 var lightboxTitle = readData( container, 'lightbox-title' ); 791 var lightboxCaption = readData( container, 'lightbox-caption' ); 792 793 var gallery_check; 794 if ( readData( container, 'lightbox-gallery' ) === true ) { 795 gallery_check = { 796 enabled: true, 797 navigateByImgClick: false, 798 preload: [ 0, 1 ], 799 tCounter: '', 800 }; 801 } else { 802 gallery_check = { enabled: false }; 803 } 804 805 var caption_check = { 806 titleSrc: function ( item ) { 807 var root = toDom( item.el ); 808 if ( ! root ) { 809 return ''; 810 } 811 var img = 812 'slideshow' !== carouselType 813 ? root.querySelector( 'img' ) 814 : root.querySelector( 815 '.dsm_image_carousel_slideshow_bg' 816 ); 817 var Title = ''; 818 var Caption = ''; 819 if ( lightboxCaption === true && img ) { 820 var desc = img.getAttribute( 'data-dsm-image-description' ) || ''; 821 Caption = 822 desc !== '' 823 ? '<small>' + 824 desc.replace( /[^]/g, function ( c ) { 825 return ( 826 '&#' + c.charCodeAt( 0 ) + ';' 827 ); 828 } ) + 829 '</small>' 830 : ''; 831 } 832 if ( lightboxTitle === true && img ) { 833 var t = img.getAttribute( 'title' ); 834 Title = 835 typeof t === 'undefined' || t === '' 836 ? '' 837 : t.replace( /[^]/g, function ( c ) { 838 return '&#' + c.charCodeAt( 0 ) + ';'; 839 } ); 840 } 841 842 return Title + Caption; 843 }, 844 }; 845 846 if ( readData( container, 'show-lightbox' ) === true ) { 847 var showLightboxPopup = { 848 type: 'image', 849 delegate: 'a.dsm_image_carousel_lightbox', 850 removalDelay: 500, 851 gallery: gallery_check, 852 image: caption_check, 853 mainClass: 'mfp-fade', 854 zoom: { 855 enabled: true, 856 duration: 500, 857 opener: function ( element ) { 858 var el = toDom( element ); 859 if ( ! el ) { 860 return null; 861 } 862 var img = 863 'slideshow' !== carouselType 864 ? el.querySelector( 'img' ) 865 : el.querySelector( 866 '.dsm_image_carousel_slideshow_bg' 867 ); 868 if ( 869 img && 870 typeof window.jQuery !== 'undefined' 871 ) { 872 return window.jQuery( img ); 873 } 874 return img; 875 }, 876 }, 877 callbacks: { 878 open: function () { 879 if ( 880 this.currItem && 881 this.currItem.el && 882 this.currItem.el[ 0 ] && 883 this.currItem.el[ 0 ].offsetParent 884 ) { 885 this.currItem.el[ 0 ].offsetParent.getAttribute( 886 'data-swiper-slide-index' 887 ); 888 } 889 }, 890 }, 891 preload: [ 0, 1 ], 892 allowHTMLInTemplate: true, 893 }; 894 895 initMagnificWhenPossible( container, showLightboxPopup ); 896 897 if ( readData( container, 'lightbox-gallery' ) === true ) { 898 container.addEventListener( 'click', function ( event ) { 899 var t = event.target.closest( 900 '.dsm_image_carousel_item.swiper-slide-duplicate a.dsm_image_carousel_lightbox' 901 ); 902 if ( ! t ) { 903 return; 904 } 905 event.preventDefault(); 906 var href = t.getAttribute( 'href' ); 907 if ( 908 ! href || 909 typeof window.jQuery === 'undefined' || 910 ! window.jQuery.fn.magnificPopup 911 ) { 912 return; 913 } 914 var links = container.querySelectorAll( 915 '.dsm_image_carousel_item:not(.swiper-slide-duplicate) a.dsm_image_carousel_lightbox' 916 ); 917 Array.prototype.forEach.call( links, function ( a, index ) { 918 if ( a.getAttribute( 'href' ) === href ) { 919 window.jQuery( container ).magnificPopup( 920 'open', 921 index 922 ); 923 } 924 } ); 925 } ); 926 } 927 } 928 } ); 929 } 930 931 function initCarouselInstance( container, options ) { 932 options = options || {}; 933 var st = icGet( container ); 934 if ( st.dsmIcTitleOutTimerId ) { 935 window.clearTimeout( st.dsmIcTitleOutTimerId ); 936 st.dsmIcTitleOutTimerId = null; 937 } 938 st.dsmIcTitleOutBusy = false;
939 var payload = st.dsmIcPayload; 940 if ( ! payload ) { 941 payload = dsmIcParseResponsivePayload( container ); 942 if ( payload ) { 943 st.dsmIcPayload = payload; 944 } 945 } 946 if ( ! options.skipApply ) { 947 if ( payload ) { 948 dsmIcApplyResponsiveGallery( container, payload ); 949 } 950 } 951 st.dsmIcCurrentBp = dsmIcGetGalleryBreakpoint(); 952 953 var lazyOn = container.getAttribute( 'data-lazyload' ) === 'true'; 954 955 var swiperWrapper = container.querySelector( '.swiper-wrapper' ); 956 957 var imageCarouselThumbs = siblingsMatch( 958 container, 959 '.dsm_image_gallery_thumbs' 960 )[ 0 ]; 961 962 var prevNavButton = siblingsMatch( 963 container, 964 '.swiper-button-prev' 965 )[ 0 ]; 966 var nextNavButton = siblingsMatch( 967 container, 968 '.swiper-button-next' 969 )[ 0 ]; 970 971 var typeVal = readData( container, 'type' ); 972 var effectVal = readData( container, 'effect' ); 973 var slideshowEffectVal = readData( container, 'slideshow-effect' ); 974 var isInfiniteScrolling = 975 readData( container, 'infinite-scrolling' ) === true; 976 var isLoop = readData( container, 'loop' ) === true; 977 var isCentered = readData( container, 'centered-slides' ) === true; 978 var isSingleView = dsmIcIsSingleSlideView( effectVal, typeVal ); 979 980 var slidesPerViewDesktop = isSingleView 981 ? 1 982 : dsmIcSlidesPerViewFromData( container, 'slide-to-show', 4 ); 983 var slidesPerViewTablet = isSingleView 984 ? 1 985 : dsmIcSlidesPerViewFromData( 986 container, 987 'slide-to-show-tablet', 988 2 989 ); 990 var slidesPerViewPhone = isSingleView 991 ? 1 992 : dsmIcSlidesPerViewFromData( 993 container, 994 'slide-to-show-phone', 995 1 996 ); 997 998 var slidesPerGroupDesktop = dsmIcPositiveInt( 999 readData( container, 'slide-to-scroll' ), 1000 1 1001 ); 1002 var slidesPerGroupTablet = dsmIcPositiveInt( 1003 readData( container, 'slide-to-scroll-tablet' ), 1004 1 1005 ); 1006 var slidesPerGroupPhone = dsmIcPositiveInt( 1007 readData( container, 'slide-to-scroll-phone' ), 1008 1 1009 ); 1010 1011 var spaceDesktop = dsmIcNumberOr( 1012 readData( container, 'space-between' ), 1013 0 1014 ); 1015 var spaceTablet = dsmIcNumberOr( 1016 readData( container, 'space-between-tablet' ), 1017 spaceDesktop 1018 ); 1019 var spacePhone = dsmIcNumberOr( 1020 readData( container, 'space-between-phone' ), 1021 spaceDesktop 1022 ); 1023 1024 var slideRowDesktop = dsmIcPositiveInt( 1025 readData( container, 'slide-row' ), 1026 1 1027 ); 1028 var slideRowTablet = dsmIcPositiveInt( 1029 readData( container, 'slide-row-tablet' ), 1030 slideRowDesktop 1031 ); 1032 var slideRowPhone = dsmIcPositiveInt( 1033 readData( container, 'slide-row-phone' ), 1034 slideRowTablet 1035 ); 1036 1037 var maxLoopSlidesPerView = Math.max( 1038 slidesPerViewDesktop, 1039 slidesPerViewTablet, 1040 slidesPerViewPhone 1041 ); 1042 var maxLoopSlidesPerGroup = Math.max( 1043 slidesPerGroupDesktop, 1044 slidesPerGroupTablet, 1045 slidesPerGroupPhone 1046 ); 1047 1048 dsmIcEnsureLoopMinimumSlides( swiperWrapper, { 1049 loop: isLoop, 1050 infinite: isInfiniteScrolling, 1051 slidesPerView: maxLoopSlidesPerView, 1052 slidesPerGroup: maxLoopSlidesPerGroup, 1053 centeredSlides: isCentered, 1054 } ); 1055 1056 var autoplaySpeed = isInfiniteScrolling 1057 ? 0 1058 : parseInt( 1059 String( readData( container, 'autoplay-speed' ) || '0' ), 1060 10 1061 ); 1062 1063 var slideshowToShowDesktop = dsmIcSlidesPerViewFromData( 1064 container, 1065 'slideshow-to-show', 1066 4 1067 ); 1068 var slideshowToShowTablet = dsmIcSlidesPerViewFromData( 1069 container, 1070 'slideshow-to-show-tablet', 1071 slideshowToShowDesktop 1072 ); 1073 var slideshowToShowPhone = dsmIcSlidesPerViewFromData( 1074 container, 1075 'slideshow-to-show-phone', 1076 slideshowToShowTablet 1077 ); 1078 1079 var slideShowSwiper; 1080 1081 if ( imageCarouselThumbs ) { 1082 slideShowSwiper = new window.Swiper( imageCarouselThumbs, { 1083 init: true, 1084 loop: true, 1085 loopAddBlankSlides: false, 1086 freeMode: false, 1087 watchSlidesVisibility: true, 1088 watchSlidesProgress: true, 1089 resizeObserver: true, 1090 observer: true, 1091 observeParents: true, 1092 observeSlideChildren: true, 1093 lazyPreloadPrevNext: lazyOn ? 2 : 0, 1094 slidesPerView: slideshowToShowPhone, 1095 breakpoints: { 1096 981: { 1097 slidesPerView: slideshowToShowDesktop, 1098 spaceBetween: spaceDesktop, 1099 }, 1100 768: { 1101 slidesPerView: slideshowToShowTablet, 1102 spaceBetween: spaceTablet, 1103 }, 1104 480: { 1105 slidesPerView: slideshowToShowPhone, 1106 spaceBetween: spacePhone, 1107 }, 1108 320: { 1109 slidesPerView: slideshowToShowPhone, 1110 spaceBetween: spacePhone, 1111 }, 1112 }, 1113 } ); 1114 } 1115 1116 var titleOutPadMs = 1117 'slideshow' === typeVal ? dsmIcTheoreticalCaptionOutPadMs( container ) : 0; 1118 1119 // Pagination markup is a sibling of `.dsm_image_carousel_container` (carousel only; slideshow uses thumbnails). 1120 var paginationEl = 1121 'carousel' === typeVal 1122 ? siblingsMatch( container, '.swiper-pagination' )[ 0 ] || null 1123 : null; 1124 1125 var mainSwiperConfig = { 1126 observer: false, 1127 observeParents: false, 1128 observeSlideChildren: false, 1129 resizeObserver: true, 1130 crossFade: true, 1131 direction: readData( container, 'slider-orientation' ), 1132 effect: 1133 'carousel' === typeVal ? effectVal : slideshowEffectVal, 1134 coverflowEffect: { 1135 slideShadows: readData( container, 'slider-effect-shadows' ), 1136 rotate: readData( container, 'slider-effect-coverflow-rotate' ), 1137 depth: readData( container, 'slider-effect-coverflow-depth' ), 1138 }, 1139 flipEffect: { 1140 rotate: 30, 1141 slideShadows: readData( container, 'slider-effect-shadows' ), 1142 }, 1143 cubeEffect: { 1144 slideShadows: readData( container, 'slider-effect-shadows' ), 1145 shadow: readData( container, 'slider-effect-shadows' ), 1146 shadowOffset: 20, 1147 shadowScale: 0.94, 1148 }, 1149 centeredSlides: isCentered, 1150 speed: parseInt( 1151 String( readData( container, 'speed' ) || '0' ), 1152 10 1153 ), 1154 loop: isLoop, 1155 loopAddBlankSlides: false, 1156 mousewheel: readData( container, 'mousewheel' ), 1157 slidesPerView: slidesPerViewPhone, 1158 pagination: paginationEl 1159 ? { 1160 el: paginationEl, 1161 type: 'bullets', 1162 clickable: true, 1163 } 1164 : false, 1165 navigation: { 1166 nextEl: nextNavButton || undefined, 1167 prevEl: prevNavButton || undefined, 1168 }, 1169 autoplay: { 1170 enabled: false, 1171 delay: isInfiniteScrolling 1172 ? 0 1173 : autoplaySpeed + titleOutPadMs, 1174 disableOnInteraction: false, 1175 }, 1176 grabCursor: 1177 false === readData( container, 'touch-move' ) 1178 ? false 1179 : readData( container, 'grab' ), 1180 lazyPreloadPrevNext: lazyOn ? 2 : 0, 1181 allowTouchMove: readData( container, 'touch-move' ), 1182 a11y: { 1183 enabled: false, 1184 slideRole: 'group', 1185 }, 1186 breakpoints: { 1187 981: dsmIcBreakpointParams( 1188 slidesPerViewDesktop, 1189 slidesPerGroupDesktop, 1190 spaceDesktop, 1191 slideRowDesktop 1192 ), 1193 768: dsmIcBreakpointParams( 1194 slidesPerViewTablet, 1195 slidesPerGroupTablet, 1196 spaceTablet, 1197 slideRowTablet 1198 ), 1199 480: dsmIcBreakpointParams( 1200 slidesPerViewPhone, 1201 slidesPerGroupPhone, 1202 spacePhone, 1203 slideRowPhone 1204 ), 1205 320: dsmIcBreakpointParams( 1206 slidesPerViewPhone, 1207 slidesPerGroupPhone, 1208 spacePhone, 1209 slideRowPhone 1210 ), 1211 }, 1212 }; 1213 1214 if ( slideShowSwiper ) { 1215 mainSwiperConfig.thumbs = { 1216 swiper: slideShowSwiper, 1217 }; 1218 } 1219 1220 var ImageCarouselSwiper = new window.Swiper( 1221 container, 1222 mainSwiperConfig 1223 ); 1224 1225 var captionOutSlidePatchActive = 1226 'slideshow' === typeVal && 1227 dsmIcTheoreticalCaptionOutPadMs( container ) > 0; 1228 1229 if ( captionOutSlidePatchActive ) { 1230 var innerSlideToIc = ImageCarouselSwiper.slideTo.bind( 1231 ImageCarouselSwiper 1232 ); 1233 ImageCarouselSwiper.slideTo = function ( 1234 index, 1235 speed, 1236 runCallbacks, 1237 internal, 1238 initial 1239 ) { 1240 var sw = this; 1241 if ( initial ) { 1242 return innerSlideToIc( 1243 index, 1244 speed, 1245 runCallbacks, 1246 internal, 1247 initial 1248 ); 1249 } 1250 var speedForBypass = speed; 1251 if ( typeof speedForBypass === 'undefined' ) { 1252 speedForBypass = sw.params.speed; 1253 } 1254 if ( 1255 internal && 1256 Number( speedForBypass ) === 0 && 1257 runCallbacks === false 1258 ) { 1259 return innerSlideToIc( 1260 index, 1261 speed, 1262 runCallbacks, 1263 internal, 1264 initial 1265 ); 1266 } 1267 if ( st.dsmIcTitleOutBusy ) { 1268 return undefined; 1269 } 1270 var tgtSlide = sw.slides[ index ]; 1271 var tgtRi = tgtSlide 1272 ? parseInt( 1273 tgtSlide.getAttribute( 'data-swiper-slide-index' ) || 1274 String( index ), 1275 10 1276 ) 1277 : index; 1278 if ( tgtRi === sw.realIndex ) { 1279 return innerSlideToIc( 1280 index, 1281 speed, 1282 runCallbacks, 1283 internal, 1284 initial 1285 ); 1286 } 1287 var fromSlideIc = sw.slides[ sw.activeIndex ]; 1288 var wrapOutEl = fromSlideIc 1289 ? fromSlideIc.querySelector( 1290 '.dsm_image_carousel_slideshow_content' 1291 ) 1292 : null; 1293 var titleOutEl = fromSlideIc 1294 ? fromSlideIc.querySelector( 1295 '.dsm_image_carousel_slide_title' 1296 ) 1297 : null; 1298 var descOutEl = fromSlideIc 1299 ? fromSlideIc.querySelector( 1300 '.dsm_image_carousel_slide_description' 1301 ) 1302 : null; 1303 1304 var waitOutMs = dsmIcLiveCaptionOutMsFromSlide( 1305 fromSlideIc, 1306 container 1307 ); 1308 if ( waitOutMs <= 0 ) { 1309 return innerSlideToIc( 1310 index, 1311 speed, 1312 runCallbacks, 1313 internal, 1314 initial 1315 ); 1316 } 1317 1318 var showTitle =
1319 readData( container, 'slideshow-show-slide-title' ) === true; 1320 var showDesc = 1321 readData( container, 'slideshow-show-slide-description' ) === 1322 true; 1323 1324 var animOutTitle = readData( 1325 container, 1326 'slideshow-title-animation-out' 1327 ); 1328 if ( 1329 showTitle && 1330 ( animOutTitle === undefined || 1331 animOutTitle === null || 1332 animOutTitle === '' ) 1333 ) { 1334 animOutTitle = 'fadeOutDown'; 1335 } 1336 1337 var animOutDesc = readData( 1338 container, 1339 'slideshow-description-animation-out' 1340 ); 1341 if ( 1342 showDesc && 1343 ( animOutDesc === undefined || 1344 animOutDesc === null || 1345 animOutDesc === '' ) 1346 ) { 1347 animOutDesc = 'fadeOutDown'; 1348 } 1349 1350 var animOutWrap = readData( 1351 container, 1352 'slideshow-wrapper-animation-out' 1353 ); 1354 1355 st.dsmIcTitleOutBusy = true; 1356 1357 var doWrapOut = 1358 wrapOutEl && 1359 animOutWrap && 1360 animOutWrap !== 'none' && 1361 ( showTitle || showDesc ); 1362 var doTitleOut = 1363 showTitle && 1364 titleOutEl && 1365 animOutTitle && 1366 animOutTitle !== 'none'; 1367 var doDescOut = 1368 showDesc && 1369 descOutEl && 1370 animOutDesc && 1371 animOutDesc !== 'none'; 1372 1373 if ( doWrapOut ) { 1374 dsmIcStripAnimateCssClasses( wrapOutEl ); 1375 } 1376 if ( doTitleOut ) { 1377 dsmIcStripAnimateCssClasses( titleOutEl ); 1378 } 1379 if ( doDescOut ) { 1380 dsmIcStripAnimateCssClasses( descOutEl ); 1381 } 1382 1383 if ( doWrapOut ) { 1384 var wodu = dsmIcNormalizeCssAnimationTime( 1385 readData( 1386 container, 1387 'slideshow-wrapper-animation-out-duration' 1388 ), 1389 '1000' 1390 ); 1391 var wodl = dsmIcNormalizeCssAnimationTime( 1392 readData( 1393 container, 1394 'slideshow-wrapper-animation-out-delay' 1395 ), 1396 '0' 1397 ); 1398 void wrapOutEl.offsetWidth; 1399 wrapOutEl.style.animationDuration = String( wodu ); 1400 wrapOutEl.style.animationDelay = String( wodl ); 1401 wrapOutEl.classList.add( 'animated', animOutWrap ); 1402 } 1403 if ( doTitleOut ) { 1404 var oduIc = dsmIcNormalizeCssAnimationTime( 1405 readData( 1406 container, 1407 'slideshow-title-animation-out-duration' 1408 ), 1409 '1000' 1410 ); 1411 var odlIc = dsmIcNormalizeCssAnimationTime( 1412 readData( 1413 container, 1414 'slideshow-title-animation-out-delay' 1415 ), 1416 '0' 1417 ); 1418 void titleOutEl.offsetWidth; 1419 titleOutEl.style.animationDuration = String( oduIc ); 1420 titleOutEl.style.animationDelay = String( odlIc ); 1421 titleOutEl.classList.add( 'animated', animOutTitle ); 1422 } 1423 if ( doDescOut ) { 1424 var dduO = dsmIcNormalizeCssAnimationTime( 1425 readData( 1426 container, 1427 'slideshow-description-animation-out-duration' 1428 ), 1429 '1000' 1430 ); 1431 var ddlO = dsmIcNormalizeCssAnimationTime( 1432 readData( 1433 container, 1434 'slideshow-description-animation-out-delay' 1435 ), 1436 '0' 1437 ); 1438 void descOutEl.offsetWidth; 1439 descOutEl.style.animationDuration = String( dduO ); 1440 descOutEl.style.animationDelay = String( ddlO ); 1441 descOutEl.classList.add( 'animated', animOutDesc ); 1442 } 1443 1444 if ( st.dsmIcTitleOutTimerId ) { 1445 window.clearTimeout( st.dsmIcTitleOutTimerId ); 1446 } 1447 st.dsmIcTitleOutTimerId = window.setTimeout( function () { 1448 st.dsmIcTitleOutTimerId = null; 1449 st.dsmIcTitleOutBusy = false; 1450 innerSlideToIc( 1451 index, 1452 speed, 1453 runCallbacks, 1454 internal, 1455 initial 1456 ); 1457 }, waitOutMs ); 1458 return undefined; 1459 }; 1460 } 1461 1462 /** 1463 * Replay Animate.css on slideshow caption wrapper, title, and description (slideshow + options). 1464 * 1465 * @param {Element} swiperHost `.dsm_image_carousel_container` 1466 * @param {*} swiperInstance Main Swiper instance 1467 */ 1468 function dsmIcApplySlideCaptionAnimations( swiperHost, swiperInstance ) { 1469 if ( readData( swiperHost, 'type' ) !== 'slideshow' ) { 1470 return; 1471 } 1472 var showTitle = 1473 readData( swiperHost, 'slideshow-show-slide-title' ) === true; 1474 var showDesc = 1475 readData( swiperHost, 'slideshow-show-slide-description' ) === 1476 true; 1477 var root = swiperHost.closest( IC_ROOT_SEL ); 1478 if ( ! root ) { 1479 root = swiperHost.parentElement; 1480 } 1481 if ( ! root ) { 1482 return; 1483 } 1484 1485 var contents = root.querySelectorAll( 1486 '.dsm_image_carousel_slideshow_content' 1487 ); 1488 var titles = root.querySelectorAll( '.dsm_image_carousel_slide_title' ); 1489 var descs = root.querySelectorAll( 1490 '.dsm_image_carousel_slide_description' 1491 ); 1492 Array.prototype.forEach.call( contents, function ( el ) {
1493 dsmIcStripAnimateCssClasses( el ); 1494 } ); 1495 Array.prototype.forEach.call( titles, function ( el ) { 1496 dsmIcStripAnimateCssClasses( el ); 1497 } ); 1498 Array.prototype.forEach.call( descs, function ( el ) { 1499 dsmIcStripAnimateCssClasses( el ); 1500 } ); 1501 1502 var slide = swiperInstance.slides[ swiperInstance.activeIndex ]; 1503 if ( ! slide ) { 1504 return; 1505 } 1506 var wrapEl = slide.querySelector( 1507 '.dsm_image_carousel_slideshow_content' 1508 ); 1509 var activeTitle = slide.querySelector( 1510 '.dsm_image_carousel_slide_title' 1511 ); 1512 var activeDesc = slide.querySelector( 1513 '.dsm_image_carousel_slide_description' 1514 ); 1515 1516 var wrapAnimIn = readData( 1517 swiperHost, 1518 'slideshow-wrapper-animation-in' 1519 ); 1520 if ( 1521 wrapEl && 1522 wrapAnimIn && 1523 wrapAnimIn !== 'none' && 1524 ( showTitle || showDesc ) 1525 ) { 1526 var wDur = dsmIcNormalizeCssAnimationTime( 1527 readData( 1528 swiperHost, 1529 'slideshow-wrapper-animation-in-duration' 1530 ), 1531 '1000' 1532 ); 1533 var wDel = dsmIcNormalizeCssAnimationTime( 1534 readData( 1535 swiperHost, 1536 'slideshow-wrapper-animation-in-delay' 1537 ), 1538 '0' 1539 ); 1540 void wrapEl.offsetWidth; 1541 wrapEl.style.animationDuration = String( wDur ); 1542 wrapEl.style.animationDelay = String( wDel ); 1543 wrapEl.classList.add( 'animated', wrapAnimIn ); 1544 } 1545 1546 if ( showTitle && activeTitle ) { 1547 var anim = readData( swiperHost, 'slideshow-title-animation' ); 1548 if ( anim === undefined || anim === null || anim === '' ) { 1549 anim = 'fadeInUp'; 1550 } 1551 if ( anim !== 'none' ) { 1552 var durRaw = readData( 1553 swiperHost, 1554 'slideshow-title-animation-duration' 1555 ); 1556 var delRaw = readData( 1557 swiperHost, 1558 'slideshow-title-animation-delay' 1559 ); 1560 var dur = dsmIcNormalizeCssAnimationTime( durRaw, '1000' ); 1561 var del = dsmIcNormalizeCssAnimationTime( delRaw, '0' ); 1562 void activeTitle.offsetWidth; 1563 activeTitle.style.animationDuration = String( dur ); 1564 activeTitle.style.animationDelay = String( del ); 1565 activeTitle.classList.add( 'animated', anim ); 1566 } 1567 } 1568 1569 if ( showDesc && activeDesc ) { 1570 var dAnim = readData( 1571 swiperHost, 1572 'slideshow-description-animation' 1573 ); 1574 if ( dAnim === undefined || dAnim === null || dAnim === '' ) { 1575 dAnim = 'fadeInUp'; 1576 } 1577 if ( dAnim !== 'none' ) { 1578 var dDur = dsmIcNormalizeCssAnimationTime( 1579 readData( 1580 swiperHost, 1581 'slideshow-description-animation-duration' 1582 ), 1583 '1000' 1584 ); 1585 var dDel = dsmIcNormalizeCssAnimationTime( 1586 readData( 1587 swiperHost, 1588 'slideshow-description-animation-delay' 1589 ), 1590 '0' 1591 ); 1592 void activeDesc.offsetWidth; 1593 activeDesc.style.animationDuration = String( dDur ); 1594 activeDesc.style.animationDelay = String( dDel ); 1595 activeDesc.classList.add( 'animated', dAnim ); 1596 } 1597 } 1598 } 1599 1600 ImageCarouselSwiper.on( 'slideChangeTransitionEnd', function () { 1601 dsmIcApplySlideCaptionAnimations( container, ImageCarouselSwiper ); 1602 } ); 1603 dsmIcApplySlideCaptionAnimations( container, ImageCarouselSwiper ); 1604 1605 st.dsmIcMainSwiper = ImageCarouselSwiper; 1606 st.dsmIcThumbSwiper = slideShowSwiper || null; 1607 1608 if ( lazyOn ) { 1609 var dsmIcRoot = container.closest( '.dsm_image_carousel' ); 1610 if ( ! dsmIcRoot ) { 1611 dsmIcRoot = container.parentElement; 1612 } 1613 if ( dsmIcRoot ) { 1614 dsmIcObserveLazyBackgrounds( dsmIcRoot ); 1615 } 1616 } 1617 1618 if ( readData( container, 'pause-on-hover' ) === true ) { 1619 if ( st._pauseEnter ) { 1620 container.removeEventListener( 'mouseenter', st._pauseEnter ); 1621 container.removeEventListener( 'mouseleave', st._pauseLeave ); 1622 } 1623 st._pauseEnter = function () { 1624 stopCarouselAutoplay( st.dsmIcMainSwiper ); 1625 }; 1626 st._pauseLeave = function () { 1627 startCarouselAutoplay( st.dsmIcMainSwiper ); 1628 }; 1629 container.addEventListener( 'mouseenter', st._pauseEnter ); 1630 container.addEventListener( 'mouseleave', st._pauseLeave ); 1631 } 1632 1633 if ( container.closest( '.et_pb_tabs' ) ) { 1634 var tabLinks = document.querySelectorAll( '.et_pb_tabs a' ); 1635 Array.prototype.forEach.call( tabLinks, function ( a ) { 1636 a.addEventListener( 'click', function icTabClick() { 1637 var sw = st.dsmIcMainSwiper; 1638 if ( sw && typeof sw.slideTo === 'function' ) { 1639 sw.slideTo( sw.realIndex, 0 ); 1640 } 1641 } ); 1642 } ); 1643 } 1644 1645 if ( readData( container, 'autoplay' ) === true ) { 1646 destroyCarouselAutoplayWaypoint( st ); 1647 1648 if ( typeof window.Waypoint === 'undefined' ) { 1649 startCarouselAutoplay( ImageCarouselSwiper ); 1650 } else { 1651 st.dsmIcAutoplayWaypoint = new window.Waypoint( { 1652 element: container, 1653 handler: function () { 1654 startCarouselAutoplay( st.dsmIcMainSwiper ); 1655 this.destroy(); 1656 st.dsmIcAutoplayWaypoint = null; 1657 }, 1658 offset: readData( container, 'autoplay-viewport' ), 1659 } ); 1660 } 1661 } 1662 } 1663 1664 function startCarouselAutoplay( swiper ) { 1665 if ( 1666 ! swiper || 1667 ! swiper.autoplay || 1668 typeof swiper.autoplay.start !== 'function' 1669 ) { 1670 return; 1671 } 1672 1673 swiper.autoplay.start(); 1674 } 1675
1676 function stopCarouselAutoplay( swiper ) { 1677 if ( 1678 ! swiper || 1679 ! swiper.autoplay || 1680 typeof swiper.autoplay.stop !== 'function' 1681 ) { 1682 return; 1683 } 1684 1685 swiper.autoplay.stop(); 1686 } 1687 1688 function destroyCarouselAutoplayWaypoint( st ) { 1689 if ( 1690 st.dsmIcAutoplayWaypoint && 1691 typeof st.dsmIcAutoplayWaypoint.destroy === 'function' 1692 ) { 1693 st.dsmIcAutoplayWaypoint.destroy(); 1694 } 1695 st.dsmIcAutoplayWaypoint = null; 1696 } 1697 1698 function destroyCarouselInstance( container, st ) { 1699 if ( ! st ) { 1700 st = icGet( container ); 1701 } 1702 1703 if ( st.dsmIcTitleOutTimerId ) { 1704 window.clearTimeout( st.dsmIcTitleOutTimerId ); 1705 st.dsmIcTitleOutTimerId = null; 1706 } 1707 st.dsmIcTitleOutBusy = false; 1708 1709 destroyCarouselAutoplayWaypoint( st ); 1710 1711 var thumbSw = st.dsmIcThumbSwiper; 1712 var mainSw = st.dsmIcMainSwiper; 1713 1714 if ( thumbSw && typeof thumbSw.destroy === 'function' ) { 1715 thumbSw.destroy( true, true ); 1716 } 1717 if ( mainSw && typeof mainSw.destroy === 'function' ) { 1718 mainSw.destroy( true, true ); 1719 } 1720 1721 st.dsmIcMainSwiper = null; 1722 st.dsmIcThumbSwiper = null; 1723 } 1724 1725 function refreshOrInitCarouselsInRoot( root ) { 1726 if ( ! root || typeof root.querySelectorAll !== 'function' ) { 1727 return; 1728 } 1729 1730 var containers = root.querySelectorAll( IC_SEL ); 1731 if ( ! containers.length ) { 1732 return; 1733 } 1734 1735 bindLightboxForContainers( containers ); 1736 1737 Array.prototype.forEach.call( containers, function ( c ) { 1738 var st = icGet( c ); 1739 1740 if ( st.dsmIcMainSwiper ) { 1741 destroyCarouselInstance( c, st ); 1742 } 1743 1744 initCarouselInstance( c ); 1745 } ); 1746 } 1747 1748 function run() { 1749 refreshOrInitCarouselsInRoot( document ); 1750 1751 window.addEventListener( 1752 'resize', 1753 dsmIcDebouncedResize( function () { 1754 var all = document.querySelectorAll( IC_SEL ); 1755 Array.prototype.forEach.call( all, function ( c ) { 1756 var st = icGet( c ); 1757 var payload = st.dsmIcPayload; 1758 if ( ! payload ) { 1759 return; 1760 } 1761 var bp = dsmIcGetGalleryBreakpoint(); 1762 if ( bp === st.dsmIcCurrentBp ) { 1763 return; 1764 } 1765 var thumbSw = st.dsmIcThumbSwiper; 1766 var mainSw = st.dsmIcMainSwiper; 1767 if ( st.dsmIcTitleOutTimerId ) { 1768 window.clearTimeout( st.dsmIcTitleOutTimerId ); 1769 st.dsmIcTitleOutTimerId = null; 1770 } 1771 st.dsmIcTitleOutBusy = false; 1772 if ( thumbSw && typeof thumbSw.destroy === 'function' ) { 1773 thumbSw.destroy( true, true ); 1774 } 1775 if ( mainSw && typeof mainSw.destroy === 'function' ) { 1776 mainSw.destroy( true, true ); 1777 } 1778 dsmIcApplyResponsiveGallery( c, payload ); 1779 st.dsmIcCurrentBp = bp; 1780 initCarouselInstance( c, { skipApply: true } ); 1781 } ); 1782 }, 150 ) 1783 ); 1784 } 1785 1786 window.dsmReinitImageCarouselsInRoot = refreshOrInitCarouselsInRoot; 1787 1788 [ 'dsm:reinit-library-modules-in-root', 'dsm:reinit-carousels-in-root' ].forEach( 1789 function ( eventName ) { 1790 window.addEventListener( eventName, function ( event ) { 1791 var root = event && event.detail ? event.detail.root : null; 1792 if ( ! root || typeof root.querySelector !== 'function' ) { 1793 return; 1794 } 1795 if ( ! root.querySelector( IC_ROOT_SEL ) ) { 1796 return; 1797 } 1798 refreshOrInitCarouselsInRoot( root ); 1799 } ); 1800 } 1801 ); 1802 1803 if ( document.readyState === 'loading' ) { 1804 document.addEventListener( 'DOMContentLoaded', run ); 1805 } else { 1806 run(); 1807 } 1808} )();
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.