1/**handles:modulet-single-product-init**/ 2/* global jssor_options */ 3 4jQuery( function( $ ) { 5 6 $.fn.productImgPreload = function() { 7 this.each( function() { 8 $( '<img/>' )[0].src = this; 9 } ); 10 }; 11 12 var $productWrapper = $( '.single_product_wrapper' ), 13 $easyzoom = $( '.images .easyzoom', $productWrapper ).easyZoom(), 14 easyZoomApi = $easyzoom.data( 'easyZoom' ), 15 items = [], 16 index, 17 thumb = $( '.images .thumbnails .thumbnail', $productWrapper ), 18 enlarge = $( '.images .enlarge', $productWrapper ), 19 zoom_enabled = true; 20 21 if ( thumb[0] ) { 22 var preloadHref = [], 23 thumb_0 = thumb.eq( 0 ); 24 25 thumb_0.addClass( 'selected' ); 26 preloadHref[0] = thumb_0.data( 'href' ); 27 28 if ( thumb.eq( 1 ) ) { 29 var thumb_1 = thumb.eq( 1 ); 30 31 preloadHref[1] = thumb_1.data( 'thumb' ); 32 preloadHref[2] = thumb_1.data( 'href' ); 33 } 34 35 $( preloadHref ).productImgPreload(); 36 37 thumb.each( function() { 38 items.push( { 39 src: $( this ).data( 'href' ) 40 } ); 41 } ); 42 43 thumb.on( 'click', thumbClickHandler ); 44 } 45 46 function thumbClickHandler() { 47 var $this = $( this ), 48 $mainImageWrap = $( '.woocommerce-main-image' ), 49 $mainImage = $( 'img', $mainImageWrap ), 50 $thumbImage = $( 'img', $this ); 51 52 thumb.removeClass( 'selected' ); 53 $this.addClass( 'selected' ); 54 55 if ( easyZoomApi ) { 56 easyZoomApi.teardown(); 57 } 58 59 zoom_enabled = false; 60 61 $mainImageWrap.attr( { 62 href: $this.data( 'href' ) 63 } ); 64 65 $mainImage.attr( { 66 src: $this.data( 'thumb' ), 67 srcset: $thumbImage.attr( 'srcset' ), 68 title: $thumbImage.attr( 'title' ), 69 alt: $thumbImage.attr( 'alt' ) 70 } ); 71 72 zoom(); 73 index = $this.index(); 74 open_popup( index ); 75 preloadHref = []; 76 preloadHref[0] = $this.data( 'href' ); 77 78 if ( $this.next().length ) { 79 preloadHref[1] = $this.next().data( 'thumb' ); 80 preloadHref[2] = $this.next().data( 'href' ); 81 } 82 else if ( $this.prev().length ) { 83 preloadHref[1] = $this.prev().data( 'thumb' ); 84 preloadHref[2] = $this.prev().data( 'href' ); 85 } 86 87 $( preloadHref ).productImgPreload(); 88 } 89 90 function open_popup( index ) { 91 enlarge.on( 'click', function() { 92 93 $.magnificPopup.open( { 94 items: items, 95 gallery: { 96 enabled: true, 97 preload: [1, 1] 98 }, 99 type: 'image' 100 }, index ); 101 102 } ); 103 } 104 105 open_popup( 0 ); 106 107 function zoom() { 108 109 if ( 768 > Math.min( $( window ).width(), screen.width ) ) { 110 if ( true === zoom_enabled && easyZoomApi ) { 111 easyZoomApi.teardown(); 112 zoom_enabled = false; 113 } 114 } else { 115 if ( false === zoom_enabled && easyZoomApi ) { 116 easyZoomApi._init(); 117 zoom_enabled = true; 118 } 119 } 120 } 121 122 zoom(); 123 $( window ).on( 'resize orientationchange', zoom ); 124 125} );
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.