1(function (document, window, $) { 2 "use strict"; 3 4 var main_image_swiper = wooswipe_data["product_main_slider"]; 5 var add_slick_slide_class = main_image_swiper ? ".slick-slide" : " "; 6 7 function getAttachmentIdFromThumb($el) { 8 return String($el.attr("data-attachment_id") || "").replace(/^main_image_/, ""); 9 } 10 11 /** 12 * Find the thumbnail that matches a WooCommerce variation image. 13 * Prefer image_id (reliable); fall back to comparing known image URLs. 14 */ 15 function findThumbForVariation(variation) { 16 var $match = $(); 17 var imageId = 18 (variation && variation.image_id) || 19 (variation && variation.image && variation.image.id) || 20 ""; 21 22 if (imageId) { 23 $("div.thumb[data-slide]").each(function () { 24 if (String(imageId) === getAttachmentIdFromThumb($(this))) { 25 $match = $(this); 26 return false; 27 } 28 }); 29 } 30 31 if ($match.length) { 32 return $match; 33 } 34 35 var urls = []; 36 if (variation && variation.image) { 37 ["url", "src", "full_src", "gallery_thumbnail_src", "thumb_src"].forEach(function (key) { 38 if (variation.image[key]) { 39 urls.push(variation.image[key]); 40 } 41 }); 42 } 43 44 if (!urls.length) { 45 return $match; 46 } 47 48 $("div.thumb[data-slide]").each(function () { 49 var $thumb = $(this); 50 var med = $thumb.attr("data-med"); 51 var hq = $thumb.attr("data-hq"); 52 if (urls.indexOf(med) !== -1 || urls.indexOf(hq) !== -1) { 53 $match = $thumb; 54 return false; 55 } 56 }); 57 58 return $match; 59 } 60 61 (function productThumbnails() { 62 var plugin_path = wooswipe_wp_plugin_path.templateUrl + "/"; 63 var addPintrest = wooswipe_data["addpin"]; 64 var firstUrl; 65 var alt; 66 67 if ($(".single-product-main-image img").length > 0) { 68 firstUrl = $(".single-product-main-image img").attr("src"); 69 alt = $(".single-product-main-image img").attr("alt"); 70 } else if ($(".wooswipe-placeholder").length > 0) { 71 firstUrl = $(".wooswipe-placeholder").attr("src"); 72 alt = $(".wooswipe-placeholder").attr("alt"); 73 } 74 var link = window.location.href; 75 76 function pinit(url) { 77 if (!url) { 78 return; 79 } 80 $(".wooswipe-pinit").attr( 81 "href", 82 "https://www.pinterest.com/pin/create/button/?media=" + 83 url + 84 "&url=" + 85 link + 86 "&description=" + 87 encodeURI(alt || "") 88 ); 89 } 90 91 if (addPintrest) { 92 if ($(".single-product-main-image").length !== 0) { 93 $("#wooswipe").prepend( 94 '<a class="wooswipe-pinit" target="_blank" rel="noreferrer noopener" href="https://www.pinterest.com/pin/create/button/?media=' + 95 firstUrl + 96 "&url=" + 97 link + 98 "&description=" + 99 encodeURI(alt || "") + 100 '"><img src="' + 101 plugin_path + 102 'public/pinit/pinterest.svg" alt="Pinterest" /></a>' 103 ); 104 } 105 if ($(".wooswipe-placeholder").length !== 0) { 106 $("#wooswipe").prepend( 107 '<a class="wooswipe-pinit" target="_blank" rel="noreferrer noopener" href="https://www.pinterest.com/pin/create/button/?media=' + 108 firstUrl + 109 "&url=" + 110 link + 111 "&description=" + 112 encodeURI(alt || "") + 113 '"><img src="' + 114 plugin_path + 115 'public/pinit/pinterest.svg" alt="Pinterest" /></a>' 116 ); 117 } 118 $(".wooswipe-pinit").click(function (e) { 119 e.preventDefault(); 120 var popitHref = $(this).attr("href"); 121 window.open( 122 popitHref, 123 "popUpWindow", 124 "height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes" 125 ); 126 return false; 127 }); 128 } 129 130 function setup_full_screen_image_url(url) { 131 $(".wooswipe-popup").attr("href", url); 132 } 133 134 $(".thumbnail-nav").slick({ 135 variableWidth: false, 136 dots: false, 137 focusOnSelect: false, 138 infinite: false, 139 slidesToShow: 5, 140 slidesToScroll: 1, 141 respondTo: "slider", 142 prevArrow: 143 '<button class="wooswipe-prev slick-arrow slick-disabled" aria-label="Previous" type="button"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 80 80"><g id="left" transform="translate(-977 -529)"><circle xmlns="http://www.w3.org/2000/svg" id="Ellipse_1" data-name="Ellipse 1" cx="40" cy="40" r="40" transform="translate(977 529)" fill="' + 144 wooswipe_data["icon_bg_color"] + 145 '"/><path id="Icon_awesome-chevron-left" data-name="Icon awesome-chevron-left" d="M2.6,21.735,21.021,3.314a2.275,2.275,0,0,1,3.217,0l2.149,2.149a2.275,2.275,0,0,1,0,3.213l-14.6,14.667,14.6,14.668a2.274,2.274,0,0,1,0,3.213l-2.149,2.149a2.275,2.275,0,0,1-3.217,0L2.6,24.952A2.275,2.275,0,0,1,2.6,21.735Z" transform="translate(1003.067 545.352)" fill="' + 146 wooswipe_data["icon_stroke_color"] + 147 '"/></g></svg></button>', 148 nextArrow: 149 '<button class="wooswipe-next slick-arrow" aria-label="Next" type="button"><svg xmlns="http://www.w3.org/2000/svg" id="right" width="20" height="20" viewBox="0 0 80 80"><circle id="Ellipse_1" data-name="Ellipse 1" cx="40" cy="40" r="40" fill="' + 150 wooswipe_data["icon_bg_color"] + 151 '" /><path id="Icon_awesome-chevron-left" data-name="Icon awesome-chevron-left" d="M26.387,21.735,7.965,3.314a2.275,2.275,0,0,0-3.217,0L2.6,5.463a2.275,2.275,0,0,0,0,3.213L17.2,23.344,2.6,38.012a2.274,2.274,0,0,0,0,3.213l2.149,2.149a2.275,2.275,0,0,0,3.217,0L26.387,24.952A2.275,2.275,0,0,0,26.387,21.735Z" transform="translate(24.947 16.352)" fill="' + 152 wooswipe_data["icon_stroke_color"] + 153 '"/></svg></button>', 154 responsive: [ 155 { breakpoint: 680, settings: { slidesToShow: 5 } }, 156 { breakpoint: 520, settings: { slidesToShow: 4 } }, 157 { breakpoint: 420, settings: { slidesToShow: 3 } } 158 ] 159 }); 160 161 $(".thumbnails .thumb").click(function (e) { 162 e.preventDefault(); 163 var med = replace_mainimage_thumb_change($(this)); 164 if (addPintrest) { 165 pinit(med); 166 } 167 }); 168 169 function replace_mainimage_thumb_change($this) { 170 var med = $this.attr("data-med"); 171 var title = $this.attr("data-title"); 172 var width = $this.attr("data-medw"); 173 var height = $this.attr("data-medh"); 174 var hq = $this.attr("data-hq"); 175 var hqw = $this.attr("data-w"); 176 var hqh = $this.attr("data-h"); 177 var atid = $this.attr("data-attachment_id"); 178 var ind = $this.parent().index(); 179 var mainImage = $(".single-product-main-image img"); 180 181 mainImage 182 .attr("data-ind", ind) 183 .attr("src", med) 184 .attr("srcset", med) 185 .attr("width", width) 186 .attr("height", height) 187 .attr("data-hq", hq) 188 .attr("data-w", hqw) 189 .attr("data-h", hqh) 190 .attr("data-attachment_id", atid) 191 .attr("alt", title) 192 .attr("title", title); 193 return med; 194 } 195 196 var mainImage = $(".single-product-main-image img");
197 if (mainImage.length && !mainImage.closest("a.woocommerce-main-image").length) { 198 mainImage.wrap('<a class="woocommerce-main-image zoom" href="#"></a>'); 199 if (!mainImage.closest(".single-product-main-image").length) { 200 $(".woocommerce-main-image").wrap('<div class="single-product-main-image"></div>'); 201 } 202 if (addPintrest) { 203 pinit(mainImage[0].src); 204 } 205 } 206 207 var placeholderImage = $(".wooswipe-placeholder"); 208 if (placeholderImage.length && !placeholderImage.closest("a.woocommerce-main-image").length) { 209 placeholderImage.wrap('<a class="woocommerce-main-image zoom" href="#"></a>'); 210 if (!placeholderImage.closest(".single-product-main-image").length) { 211 placeholderImage.closest("a.woocommerce-main-image").wrap('<div class="single-product-main-image"></div>'); 212 } 213 if (addPintrest) { 214 pinit(placeholderImage[0].src); 215 } 216 } 217 218 $(".single_variation_wrap").on("show_variation", function (event, variation) { 219 var $thumb = findThumbForVariation(variation); 220 if (!$thumb.length) { 221 return; 222 } 223 var med = replace_mainimage_thumb_change($thumb); 224 if (addPintrest) { 225 pinit(med); 226 setup_full_screen_image_url(med); 227 } 228 }); 229 })(); 230 231 (function photoSwipe() { 232 var pswpElement = document.querySelectorAll(".pswp")[0]; 233 var items = []; 234 235 function openPswp(index) { 236 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, { 237 index: index, 238 shareEl: false 239 }); 240 gallery.init(); 241 } 242 243 function pushItem(image) { 244 if (!image || !image.attributes || !image.attributes["data-hq"]) { 245 return; 246 } 247 items.push({ 248 src: image.attributes["data-hq"].value, 249 w: image.attributes["data-w"].value, 250 h: image.attributes["data-h"].value, 251 title: image.attributes["data-title"] 252 ? image.attributes["data-title"].value 253 : "" 254 }); 255 } 256 257 if ($(".thumbnails .thumb").length > 0) { 258 var $thumbs = $(".thumbnails .thumb"); 259 for (var i = 0; i < $thumbs.length; i++) { 260 var thumbAlt = $($thumbs[i]).find("img").attr("title"); 261 $($thumbs[i]).attr("data-title", thumbAlt); 262 pushItem($thumbs[i]); 263 } 264 } else if ($(".single-product-main-image").length > 0) { 265 var singleImg = $(".single-product-main-image img"); 266 for (var j = 0; j < singleImg.length; j++) { 267 var singleImgAlt = $(singleImg[j]).attr("title"); 268 $(singleImg[j]).attr("data-title", singleImgAlt); 269 pushItem(singleImg[j]); 270 } 271 } 272 273 if ($(".single-product-main-image " + add_slick_slide_class + " img").length > 0) { 274 $(".single-product-main-image " + add_slick_slide_class + " img").click(function (e) { 275 if (e.which == 2 || e.ctrlKey || e.altKey) { 276 return; 277 } 278 e.preventDefault(); 279 var ind = $(this).attr("data-ind"); 280 openPswp(ind ? parseInt(ind, 10) : 0); 281 }); 282 } 283 })(); 284})(document, window, jQuery);
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.