1/*global jQuery*/ 2/*global kadence_pg*/ 3/*global Splide*/ 4/*global GLightbox*/ 5jQuery( function( $ ) { 6 var KadenceProductGalleryisMobile = { 7 Android: function() { 8 return navigator.userAgent.match(/Android/i); 9 }, 10 BlackBerry: function() { 11 return navigator.userAgent.match(/BlackBerry/i); 12 }, 13 iOS: function() { 14 return navigator.userAgent.match(/iPhone|iPad|iPod/i); 15 }, 16 Opera: function() { 17 return navigator.userAgent.match(/Opera Mini/i); 18 }, 19 Windows: function() { 20 return navigator.userAgent.match(/IEMobile/i); 21 }, 22 any: function() { 23 return KadenceProductGalleryisMobile.Android() || KadenceProductGalleryisMobile.BlackBerry() || KadenceProductGalleryisMobile.iOS() || KadenceProductGalleryisMobile.Opera() || KadenceProductGalleryisMobile.Windows(); 24 } 25 }; 26 /** 27 * Product gallery class. 28 */ 29 var KadenceProductGallery = function( $gallery ) { 30 this.$gallery = $gallery; 31 var splide_speed = $gallery.data('speed'), 32 product_id = $gallery.data('product-id'), 33 splide_animation = $gallery.data('animation'), 34 splide_animation_speed = $gallery.data('animation-speed'), 35 slick_arrows = $gallery.data('arrows'), 36 layout = $gallery.data('layout'), 37 mdLayout = $gallery.data('md-layout'), 38 smLayout = $gallery.data('sm-layout'), 39 items_count = $gallery.data('gallery-items'), 40 splide_thumbs_show = $gallery.data('thumb-show'), 41 splide_thumbs_tablet_show = $gallery.data('md-thumb-show'), 42 splide_thumbs_mobile_show = $gallery.data('sm-thumb-show'), 43 splide_thumbs_width = $gallery.data('thumb-width'), 44 splide_thumbs_tablet_width = $gallery.data('md-thumb-width'), 45 splide_thumbs_mobile_width = $gallery.data('sm-thumb-width'), 46 splide_thumbs_gap = $gallery.data('thumb-gap'), 47 splide_thumbs_tablet_gap = $gallery.data('md-thumb-gap'), 48 splide_thumbs_mobile_gap = $gallery.data('sm-thumb-gap'), 49 splide_thumbs_center = $gallery.data('thumb-center'), 50 splide_auto = $gallery.data('auto'), 51 splide_auto_height = $gallery.data('auto-height'), 52 visible_captions = $gallery.data('visible-captions'), 53 $zoom = $gallery.data('zoom-active'), 54 $zoom_type = $gallery.data('zoom-type'), 55 splide_thumbs_on_hover = $gallery.data('thumb-hover'), 56 //$items = $gallery.data('gallery-items'), 57 fixedHeight = $gallery.find('.splide__track').height(), 58 pauseonhover = false, 59 thumbnails_have_changed = false, 60 sliderDirection = 'ltr'; 61 var $datathumbs = false; 62 var original_items_count = items_count; 63 if ( $('#pg-extra-' + product_id).length ) { 64 $datathumbs = $('#pg-extra-' + product_id).data('product_variation_images'); 65 if ( $datathumbs['is_ajax'] === false && $datathumbs['has_variation_images'] === false ) { 66 $datathumbs = false; 67 } 68 } 69 if ( $( 'html[dir="rtl"]' ).length ) { 70 sliderDirection = 'rtl'; 71 } 72 if ( $zoom && ! KadenceProductGalleryisMobile.any() && $( window ).width() > 790) { 73 pauseonhover = true; 74 } 75 $gallery.addClass( 'splide-initial' ); 76 var current_layout = layout; 77 var current_thumb_width = splide_thumbs_width; 78 var current_thumbs_show = splide_thumbs_show; 79 if ( $(window).width() < 769 ) { 80 current_layout = smLayout; 81 current_thumb_width = splide_thumbs_mobile_width; 82 current_thumbs_show = splide_thumbs_mobile_show; 83 } else if ( $(window).width() < 1024 ) { 84 current_layout = mdLayout; 85 current_thumb_width = splide_thumbs_tablet_width; 86 current_thumbs_show = splide_thumbs_tablet_show; 87 } 88 if ( current_layout === 'tiles' || current_layout === 'grid' || current_layout === 'list' ) { 89 splide_auto = false; 90 } 91 var splideMain = new Splide( '#pg-main-' + product_id, { 92 type : splide_animation ? 'fade' : 'slide', 93 autoplay : splide_auto === true ? true : false, 94 lazyLoad : 'nearby', 95 rewind : true, 96 pagination : true, 97 arrows : slick_arrows ? true : false, 98 perPage : 1, 99 pauseOnHover : pauseonhover === false ? false : true, 100 direction : sliderDirection, 101 interval : undefined !== splide_speed ? splide_speed : 7000, 102 speed : undefined !== splide_animation_speed ? splide_animation_speed : 400, 103 easing : undefined !== splide_animation_speed && splide_animation_speed > 1000 ? 'linear' : 'cubic-bezier(0.25, 1, 0.5, 1)', 104 } ); 105 splideMain.on( 'mounted', function () { 106 $gallery.addClass('kt-product-gal-loaded'); 107 } ); 108 if ( splide_auto_height === true && ( current_layout === 'above' || current_layout === 'slider' ) ) { 109 var updateSlideHeight = newIndex => { 110 var slide = splideMain.Components.Slides.getAt( typeof( newIndex ) == 'number' ? newIndex : splideMain.index ).slide; 111 slide.parentElement.style.height = slide.firstChild.offsetHeight + 'px'; 112 }; 113 splideMain.on( 'mounted move resize', updateSlideHeight ); 114 var updateSlideHeightRefresh = newIndex => { 115 var slide = splideMain.Components.Slides.getAt( typeof( newIndex ) == 'number' ? newIndex : splideMain.index ).slide; 116 console.log( slide.parentElement ); 117 console.log( slide.firstChild ); 118 console.log( slide.firstChild.offsetHeight + 'px' ); 119 setTimeout(() => { 120 slide.parentElement.style.height = slide.firstChild.offsetHeight + 'px'; 121 }, 100); 122 }; 123 splideMain.on( 'refresh', updateSlideHeightRefresh ); 124 } 125 function kt_thumb_slideHeight() { 126 $('#pg-main-' + product_id ).css('height', 'auto' ); 127 setTimeout(function() { 128 var imageheight = $('#pg-main-' + product_id + ' .splide__track').height(); 129 $('#pg-thumbnails-' + product_id ).css('height', imageheight ); 130 $('#pg-main-' + product_id ).css('height', imageheight ); 131 }
131, 30); 132 } 133 if ( current_layout === 'left' || current_layout === 'right' ) { 134 kt_thumb_slideHeight(); 135 splideMain.on( 'mounted', function () { 136 setTimeout(function() { 137 kt_thumb_slideHeight(); 138 }, 100 ); 139 }); 140 } 141 function clear_slide_layout( the_layout, the_width, the_columns, the_count ) { 142 if ( the_layout === 'left' ) { 143 $('#pg-main-' + product_id).css('margin-left', the_width + '%' ); 144 $('#pg-main-' + product_id).css('margin-right', '' ); 145 setTimeout(function() { 146 $('#pg-thumbnails-' + product_id ).css('width', the_width + '%' ); 147 $('#pg-thumbnails-' + product_id + ' .thumb-wrapper' ).css('maxWidth', '' ); 148 }, 30); 149 kt_thumb_slideHeight(); 150 } else if ( the_layout === 'right' ) { 151 $('#pg-main-' + product_id).css('margin-right', the_width + '%' ); 152 $('#pg-main-' + product_id).css('margin-left', '' ); 153 setTimeout(function() { 154 $('#pg-thumbnails-' + product_id ).css('width', the_width + '%' ); 155 $('#pg-thumbnails-' + product_id + ' .thumb-wrapper' ).css('maxWidth', '' ); 156 }, 30); 157 kt_thumb_slideHeight(); 158 } else { 159 $('#pg-main-' + product_id).css('margin-left', '' ); 160 $('#pg-main-' + product_id).css('margin-right', '' ); 161 $('#pg-main-' + product_id).css('height', '' ); 162 $('#pg-thumbnails-' + product_id ).css('height', '' ); 163 $('#pg-thumbnails-' + product_id ).css('width', '' ); 164 if ( the_count < the_columns ) { 165 $('#pg-thumbnails-' + product_id + ' .thumb-wrapper' ).css('maxWidth', Math.floor( ( 100 / the_columns ) * the_count ) + '%' ); 166 } else { 167 $('#pg-thumbnails-' + product_id + ' .thumb-wrapper' ).css('maxWidth', 'none' ); 168 } 169 } 170 } 171 clear_slide_layout( current_layout, current_thumb_width, current_thumbs_show, items_count ); 172 if ( $('#pg-thumbnails-' + product_id ).length ) { 173 var thumbnails = new Splide( '#pg-thumbnails-' + product_id , { 174 direction: layout === 'left' || layout === 'right' ? 'ttb' : sliderDirection, 175 focus: splide_thumbs_center && ( ( current_layout !== 'left' && current_layout !== 'right' ) || ( items_count > splide_thumbs_show && ( current_layout === 'left' || current_layout === 'right' ) ) ) ? 'center' : undefined, 176 height: '100%', 177 perPage : ( items_count < splide_thumbs_show && layout !== 'left' && layout !== 'right' ? items_count : splide_thumbs_show ), 178 gap : splide_thumbs_gap, 179 rewind : true, 180 pagination : false, 181 isNavigation: true, 182 drag: false, 183 arrows : true, 184 breakpoints : { 185 767: { 186 direction: smLayout === 'left' || smLayout === 'right' ? 'ttb' : sliderDirection, 187 perPage : ( items_count < splide_thumbs_mobile_show && smLayout !== 'left' && smLayout !== 'right' ? items_count : splide_thumbs_mobile_show ), 188 gap : splide_thumbs_mobile_gap, 189 }, 190 1024: { 191 direction: mdLayout === 'left' || mdLayout === 'right' ? 'ttb' : sliderDirection, 192 perPage: ( items_count < splide_thumbs_tablet_show && mdLayout !== 'left' && mdLayout !== 'right' ? items_count : splide_thumbs_tablet_show ), 193 gap : splide_thumbs_tablet_gap, 194 } 195 } 196 } ); 197 198 splideMain.sync( thumbnails ); 199 splideMain.mount(); 200 thumbnails.mount(); 201 } else { 202 splideMain.mount(); 203 } 204 function galleryChangeLayout() { 205 // Mobile. 206 if ( $(window).width() < 769 ) { 207 clear_slide_layout( smLayout, splide_thumbs_mobile_width, splide_thumbs_mobile_show, items_count ); 208 } else if ( $(window).width() < 1024 ) { 209 clear_slide_layout( mdLayout, splide_thumbs_tablet_width, splide_thumbs_tablet_show, items_count ); 210 } else { 211 clear_slide_layout( layout, splide_thumbs_width, splide_thumbs_show, items_count ); 212 } 213 } 214 var galleryLayoutResizeTimer; 215 $(window).on('resize', function(){ 216 clearTimeout( galleryLayoutResizeTimer ); 217 galleryLayoutResizeTimer = setTimeout( galleryChangeLayout(), 100 ); 218 }); 219 function galleryUpdateThumbHover() { 220 var galleryHoverClickTimer; 221 $('#pg-thumbnails-' + product_id ).find( '.splide__slide' ).hover( function() { 222 $thumb = $( this ); 223 clearTimeout( galleryHoverClickTimer ); 224 galleryHoverClickTimer = setTimeout( function() { $thumb.trigger( 'click' ) }, 100 ); 225 } ); 226 } 227 if ( splide_thumbs_on_hover && thumbnails ) { 228 galleryUpdateThumbHover(); 229 } 230 if ( $zoom && !KadenceProductGalleryisMobile.any() && $(window).width() > 790 ) { 231 function init_product_zoom() { 232 233 $('.zoomContainer').remove(); 234 $('#pg-main-' + product_id + ' .is-active img').removeData('elevateZoom'); 235 $('#pg-main-' + product_id + ' .is-active img').removeData('zoomImage'); 236 $('#pg-main-' + product_id + ' .is-active img').elevateZoom({ 237 zoomType: $zoom_type, 238 cursor: "crosshair", 239 zoomWindowFadeIn: 300, 240 zoomWindowFadeOut: 300 241 }); 242 } 243 splideMain.on( 'move', function () { 244 $('.zoomContainer').remove(); 245 } ); 246 splideMain.on( 'moved', function () { 247 setTimeout(function() { 248 init_product_zoom(); 249 }, 100); 250 }); 251 var ktwoozoomresizeTimer; 252 $(window).on('resize', function(){ 253 clearTimeout(ktwoozoomresizeTimer); 254 ktwoozoomresizeTimer = setTimeout(init_product_zoom, 200); 255 }); 256 init_product_zoom(); 257 } 258 function init_product_lightbox() { 259 if ( kadence_pg.lightbox ) { 260 return GLightbox({ 261 selector: '#pg-main-' + product_id + ' .splide__slide a[data-rel^="lightbox"]:not([target="_blank"])', 262 touchNavigation: true, 263 skin: kadence_pg.lightbox_style, 264 loop: true, 265 openEffect: 'fade', 266 closeEffect: 'fade', 267 autoplayVideos: true, 268 plyr: { 269 css: kadence_pg.plyr_css, 270 js: kadence_pg.plyr_js, 271 config: { 272 hideControls: true, 273 } 274 } 275 }); 276 } 277 } 278 var glightbox = init_product_lightbox(); 279 function reload_product_lightbox() { 280 if ( kadence_pg.lightbox ) { 281 if ( glightbox ) { 282 glightbox.reload(); 283 } 284 } 285 } 286 $('.variations_form').find( '.single_variation' ).on( 'show_variation', function( event, variation, purchasable ) { 287 var $product_img_wrap = $('#pg-main-' + product_id).find( '.woocommerce-main-image' ); 288 var $product_img = kadence_pg.lightbox ? $product_img_wrap.find( 'img' ) : $('#pg-main-' + product_id).find( '.woo-main-slide img' ); 289 var $product_thumb_wrap = $('#pg-thumbnails-' + product_id).find( '.woocommerce-main-image-thumb' ); 290 var $product_thumb_img = $product_thumb_wrap.find( 'img' ); 291 // Change zoom image 292 if ( variation && variation.image.src && variation.image.src.length > 1 ) { 293 // See if the gallery has an image with the same original src as the image we want to switch to. 294 var galleryHasImage = $('#pg-main-' + product_id).find( '.splide__slide img[data-o_src="' + variation.image.src + '"]' ).length > 0; 295 // If the gallery has the image, reset the images. We'll scroll to the correct one. 296 if ( galleryHasImage ) { 297 kt_wc_variations_image_reset(); 298 } 299 // See if gallery has a matching image we can slide to.
300 var gal_non_retina = variation.image.gallery_thumbnail_src.replace( variation.image.gallery_thumbnail_src_w + 'x' + variation.image.gallery_thumbnail_src_h, Math.floor( variation.image.gallery_thumbnail_src_w / 2 ) + 'x' + Math.floor( variation.image.gallery_thumbnail_src_h / 2 ) ); 301 var slideToImage = $('#pg-thumbnails-' + product_id ).find( '.splide__slide img[src="' + gal_non_retina + '"]' ); 302 if ( slideToImage.length == 0 ) { 303 slideToImage = $('#pg-thumbnails-' + product_id ).find( '.splide__slide img[src="' + variation.image.gallery_thumbnail_src + '"]' ); 304 } 305 306 if ( slideToImage.length > 0 && ! $datathumbs ) { 307 //var galIndex = slideToImage.parent().data( 'slick-index' ) .trigger( 'click' ); 308 slideToImage.parent().trigger( 'click' ); 309 if ( $('#pg-main-' + product_id).data('zoom-active') && ! KadenceProductGalleryisMobile.any() ) { 310 $('.zoomContainer').remove(); 311 $('#pg-main-' + product_id + ' .is-active img').removeData('elevateZoom'); 312 $('#pg-main-' + product_id + ' .is-active img').removeData('zoomImage'); 313 $('#pg-main-' + product_id + ' .is-active img').elevateZoom({ 314 zoomType: $zoom_type, 315 cursor: "crosshair", 316 zoomWindowFadeIn: 300, 317 zoomWindowFadeOut: 300 318 }); 319 } 320 return; 321 } 322 323 // Go to first slide 324 var slideCount = splideMain.length; 325 if ( 1 < slideCount ) { 326 splideMain.go( 0 ); 327 } 328 $product_img.kt_wc_set_variation_attr( 'data-zoom-image', variation.image.full_src ); 329 $product_img.kt_wc_set_variation_attr( 'src', variation.image.src ); 330 if(variation.image.srcset) { 331 $product_img.kt_wc_set_variation_attr('srcset', variation.image.srcset); 332 } else { 333 $product_img.kt_wc_set_variation_attr('srcset', ''); 334 } 335 if(variation.image.title) { 336 $product_img.kt_wc_set_variation_attr('title', variation.image.title); 337 } else { 338 $product_img.kt_wc_set_variation_attr('title', ''); 339 } 340 if(variation.image.caption) { 341 $product_img.kt_wc_set_variation_attr('data-caption', variation.image.caption); 342 } else { 343 $product_img.kt_wc_set_variation_attr('data-caption', ''); 344 } 345 if ( visible_captions === true ) { 346 if ( variation.image.caption ) { 347 $product_img_wrap.find('.sp-gal-image-caption').html( variation.image.caption ); 348 $product_img_wrap.find('.sp-gal-image-caption').fadeIn(); 349 } else { 350 $product_img_wrap.find('.sp-gal-image-caption').fadeOut(); 351 } 352 } 353 if ( $product_img_wrap.hasClass( 'kt-woo-video-link' ) ) { 354 $product_img_wrap.find( '.kt-woo-play-btn' ).hide(); 355 $product_thumb_wrap.find( '.kt-woo-play-btn' ).hide(); 356 $product_img_wrap.removeClass( 'kt-woo-video-link' ); 357 $product_img_wrap.addClass( 'kt-woo-orig-video-link' ); 358 } 359 $product_img.kt_wc_set_variation_attr('alt', variation.image.alt); 360 $product_img_wrap.kt_wc_set_variation_attr('href', variation.image.full_src); 361 $product_thumb_img.kt_wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src ); 362 if ( variation.image.gallery_thumbnail_srcset ) { 363 $product_thumb_img.kt_wc_set_variation_attr( 'srcset', variation.image.gallery_thumbnail_srcset ); 364 } else { 365 $product_thumb_img.kt_wc_set_variation_attr( 'srcset', '' ); 366 } 367 $product_thumb_img.kt_wc_set_variation_attr('alt', variation.image.alt); 368 if ( $datathumbs ) { 369 if ( $datathumbs['is_ajax'] ) { 370 kt_wc_variations_run_ajax_call( variation.variation_id ); 371 } else { 372 kt_wc_variations_run_thumbnails( variation.variation_id ); 373 } 374 } 375 splideMain.refresh(); 376 if( $('#pg-main-' + product_id).data('zoom-active') && !KadenceProductGalleryisMobile.any()) { 377 $('.zoomContainer').remove(); 378 $('#pg-main-' + product_id + ' .is-active img').removeData('elevateZoom'); 379 $('#pg-main-' + product_id + ' .is-active img').removeData('zoomImage'); 380 $('#pg-main-' + product_id + ' .is-active img').elevateZoom({ 381 zoomType: $zoom_type, 382 cursor: "crosshair", 383 zoomWindowFadeIn: 300, 384 zoomWindowFadeOut: 300 385 }); 386 } 387 reload_product_lightbox(); 388 389 } else { 390 kt_wc_variations_image_reset(); 391 } 392 }); 393 function kt_wc_variations_original_thumbnails() { 394 if ( thumbnails_have_changed ) { 395 splideMain.remove( '.splide__slide:not(.woo-main-slide)' ); 396 splideMain.add( $datathumbs[ 'original' ]['images'] ); 397 items_count = original_items_count; 398 if ( thumbnails ) { 399 thumbnails.remove( '.splide__slide:not(.woocommerce-main-image-thumb)' ); 400 $('#pg-thumbnails-' + product_id ).css('height', 'auto' ); 401 if ( items_count < current_thumbs_show && current_layout !== 'left' && current_layout !== 'right' ) { 402 thumbnails.options.perPage = items_count; 403 } else if ( thumbnails.options.perPage < current_thumbs_show ) { 404 thumbnails.options.perPage = current_thumbs_show; 405 if ( splide_thumbs_center ) { 406 thumbnails.options.focus = ( current_layout !== 'left' && current_layout !== 'right' ) || ( items_count > current_thumbs_show && ( current_layout === 'left' || current_layout === 'right' ) ) ? 'center' : undefined; 407 } 408 } else if ( thumbnails.options.perPage >= current_thumbs_show ) { 409 if ( splide_thumbs_center ) { 410 thumbnails.options.focus = ( current_layout !== 'left' && current_layout !== 'right' ) || ( items_count > current_thumbs_show && ( current_layout === 'left' || current_layout === 'right' ) ) ? 'center' : undefined; 411 } 412 } 413 thumbnails.add( $datathumbs[ 'original' ]['thumbnails'] ); 414 if ( splide_thumbs_on_hover ) { 415 galleryUpdateThumbHover(); 416 } 417 } 418 clear_slide_layout( current_layout, current_thumb_width, current_thumbs_show, original_items_count ); 419 reload_product_lightbox(); 420 thumbnails_have_changed = false;
421 } 422 } 423 function kt_wc_variations_run_thumbnails( variation_id ) { 424 if ( false === $datathumbs[ variation_id ] ) { 425 kt_wc_variations_original_thumbnails(); 426 } else { 427 kt_wc_variations_switch_thumbnails( $datathumbs[ variation_id ] ); 428 } 429 } 430 function kt_wc_variations_switch_thumbnails( thumbnails_data ) { 431 thumbnails_have_changed = true; 432 splideMain.remove( '.splide__slide:not(.woo-main-slide)' ); 433 splideMain.add( thumbnails_data['images'] ); 434 items_count = thumbnails_data['thumbnails'].length + 1; 435 if ( thumbnails ) { 436 thumbnails.remove( '.splide__slide:not(.woocommerce-main-image-thumb)' ); 437 $('#pg-thumbnails-' + product_id ).css('height', 'auto' ); 438 if ( items_count < current_thumbs_show && current_layout !== 'left' && current_layout !== 'right' ) { 439 thumbnails.options.perPage = items_count; 440 } else if ( thumbnails.options.perPage < current_thumbs_show ) { 441 thumbnails.options.perPage = current_thumbs_show; 442 if ( splide_thumbs_center ) { 443 thumbnails.options.focus = ( current_layout !== 'left' && current_layout !== 'right' ) || ( items_count > current_thumbs_show && ( current_layout === 'left' || current_layout === 'right' ) ) ? 'center' : undefined; 444 } 445 } else if ( thumbnails.options.perPage >= current_thumbs_show ) { 446 if ( splide_thumbs_center ) { 447 thumbnails.options.focus = ( current_layout !== 'left' && current_layout !== 'right' ) || ( items_count > current_thumbs_show && ( current_layout === 'left' || current_layout === 'right' ) ) ? 'center' : undefined; 448 } 449 } 450 thumbnails.add( thumbnails_data['thumbnails'] ); 451 if ( splide_thumbs_on_hover ) { 452 galleryUpdateThumbHover(); 453 } 454 } 455 clear_slide_layout( current_layout, current_thumb_width, current_thumbs_show, items_count ); 456 reload_product_lightbox(); 457 } 458 function kt_wc_variations_run_ajax_call( variation_id ) { 459 var $data = { 460 action: 'kadence_variation_images_load_frontend_ajax', 461 ajaxkwsvNonce: kadence_pg.ajax_nonce, 462 variation_id: variation_id, 463 post_id: product_id 464 }; 465 $.post( kadence_pg.ajax_url, $data, function( response ) { 466 if ( response.length ) { 467 response = JSON.parse( response ); 468 // replace with new image set 469 kt_wc_variations_switch_thumbnails( response ); 470 471 } else { 472 // replace with original image set 473 kt_wc_variations_original_thumbnails(); 474 } 475 }); 476 } 477 function kt_wc_variations_image_reset() { 478 var $product_img_wrap = $('#pg-main-' + product_id).find( '.woocommerce-main-image' ); 479 var $product_img = kadence_pg.lightbox ? $product_img_wrap.find( 'img' ) : $('#pg-main-' + product_id).find( '.woo-main-slide img' ); 480 var $product_thumb_wrap = $('#pg-thumbnails-' + product_id).find( '.woocommerce-main-image-thumb' ); 481 var $product_thumb_img = $product_thumb_wrap.find( 'img' ); 482 $product_img.kt_wc_reset_variation_attr( 'src' ); 483 $product_img.kt_wc_reset_variation_attr( 'srcset' ); 484 $product_img.kt_wc_reset_variation_attr('data-caption'); 485 $product_img.kt_wc_reset_variation_attr('alt'); 486 if( visible_captions === true ) { 487 if ( undefined !== $product_img.attr( 'data-o_data-caption' ) ) { 488 $product_img_wrap.find('.sp-gal-image-caption').html($product_img.attr( 'data-o_data-caption' )); 489 $product_img_wrap.find('.sp-gal-image-caption').fadeIn(); 490 } else { 491 $product_img_wrap.find('.sp-gal-image-caption').fadeOut(); 492 } 493 } 494 if ( $product_img_wrap.hasClass( 'kt-woo-orig-video-link' ) ) { 495 $product_img_wrap.addClass( 'kt-woo-video-link' ); 496 $product_img_wrap.find( '.kt-woo-play-btn' ).show(); 497 $product_thumb_wrap.find( '.kt-woo-play-btn' ).show(); 498 $product_img_wrap.removeClass( 'kt-woo-orig-video-link' ); 499 } 500 $product_img.kt_wc_reset_variation_attr('title'); 501 $product_img.kt_wc_reset_variation_attr('data-zoom-image'); 502 $product_thumb_img.kt_wc_reset_variation_attr('src'); 503 $product_thumb_img.kt_wc_reset_variation_attr('srcset'); 504 $product_thumb_img.kt_wc_reset_variation_attr('alt'); 505 $product_img_wrap.kt_wc_reset_variation_attr('href'); 506 kt_wc_variations_original_thumbnails(); 507 if( $('#pg-main-' + product_id).data('zoom-active') && !KadenceProductGalleryisMobile.any()) { 508 var slideCount = splideMain.length; 509 if ( 1 < slideCount ) { 510 splideMain.go( 0 ); 511 } 512 $('.zoomContainer').remove(); 513 $('#pg-main-' + product_id + ' .is-active img').removeData('elevateZoom'); 514 $('#pg-main-' + product_id + ' .is-active img').removeData('zoomImage'); 515 $('#pg-main-' + product_id + ' .is-active img').elevateZoom({ 516 zoomType: $zoom_type, 517 cursor: "crosshair", 518 zoomWindowFadeIn: 300, 519 zoomWindowFadeOut: 300 520 }); 521 } 522 splideMain.refresh(); 523 reload_product_lightbox(); 524 } 525 $.fn.kt_wc_set_variation_attr = function( attr, value ) { 526 if ( undefined === this.attr( 'data-o_' + attr ) ) { 527 this.attr( 'data-o_' + attr, ! this.attr( attr ) ? '' : this.attr( attr ) ); 528 } 529 this.attr( attr, value ); 530 }; 531 $.fn.kt_wc_reset_variation_attr = function( attr ) { 532 if ( undefined !== this.attr( 'data-o_' + attr ) ) { 533 this.attr( attr, this.attr( 'data-o_' + attr ) ); 534 } 535 }; 536 $('.variations_form').on( 'click', '.reset_variations', function() { 537 kt_wc_variations_image_reset(); 538 } ); 539 } 540 /** 541 * Function to call kt_wc_product_gallery on jquery selector. 542 */ 543 $.fn.kt_wc_product_gallery = function() { 544 var gallery = this; 545 if ( typeof Splide === 'function' ) { 546 new KadenceProductGallery( gallery ); 547 } else { 548 // eslint-disable-next-line vars-on-top 549 var initLoadDelay = setInterval( function() { 550 if ( typeof Splide === 'function' ) { 551 new KadenceProductGallery( gallery ); 552 clearInterval( initLoadDelay ); 553 } 554 }, 200 ); 555 } 556 return this; 557 }; 558 // $.extend(true, $.magnificPopup.defaults, { 559 // tClose: '', 560 // tLoading: kadence_pg.loading, // Text that is displayed during loading. Can contain %curr% and %total% keys 561 // gallery: { 562 // tPrev: '', // Alt text on left arrow 563 // tNext: '', // Alt text on right arrow 564 // tCounter: kadence_pg.of // Markup for "1 of 7" counter 565 // }, 566 // image: { 567 // tError: kadence_pg.error, // Error message when image could not be loaded 568 // titleSrc: function(item) { 569 // return item.el.find('img').attr('alt'); 570 // } 571 // } 572 // }); 573 /* 574 * Initialize all galleries on page. 575 */ 576 $( '.kadence-ga-splide-init' ).each( function() { 577 $( this ).kt_wc_product_gallery(); 578 } ); 579});
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.