1"use strict"; 2 3var spsgqcv_ids = [], 4 spsgqcv_products = []; 5 6function isMobileDevice() { 7 return window.matchMedia("(max-width: 767px)").matches; 8} 9 10(function ($) { 11 $(function () { 12 if (isMobileDevice() && !spsgqcv_vars.enable_in_mobile) { 13 $(".spsgqcv-btn").each(function () { 14 $(this).remove(); 15 }); 16 } 17 }); 18 $(function () { 19 $(".spsgqcv-btn, .spsgqcv-link").each(function () { 20 var id = $(this).attr("data-id"); 21 var pid = $(this).attr("data-pid"); 22 var product_id = $(this).attr("data-product_id"); 23 if (typeof pid !== typeof undefined && pid !== false) { 24 id = pid; 25 } 26 27 if (typeof product_id !== typeof undefined && product_id !== false) { 28 id = product_id; 29 } 30 31 if (-1 === $.inArray(id, spsgqcv_ids)) { 32 spsgqcv_ids.push(id); 33 spsgqcv_products.push({ 34 src: spsgqcv_vars.ajax_url + "?product_id=" + id, 35 }); 36 } 37 }); 38 // quick view 39 if (spsgqcv_vars.quick_view > 0) { 40 setTimeout(function () { 41 spsgqcv_open(spsgqcv_vars.quick_view); 42 }, 1000); 43 } 44 }); 45 46 $(document).on("click touch", '[href*="#spsgqcv-"]', function (e) { 47 var $this = $(this); 48 var href = $this.attr("href"); 49 var reg = /#spsgqcv-([0-9]+)/g; 50 var match = reg.exec(href); 51 52 if (match[1] !== undefined) { 53 var id = match[1]; 54 var effect = $this.attr("data-effect"); 55 var context = $this.attr("data-context"); 56 spsgqcv_open(id, effect, context); 57 e.preventDefault(); 58 } 59 }); 60 61 $(document).on("click touch", ".spsgqcv-btn, .spsgqcv-link", function (e) { 62 e.preventDefault(); 63 64 var $this = $(this); 65 var id = $this.attr("data-id"); 66 var pid = $this.attr("data-pid"); 67 var product_id = $this.attr("data-product_id"); 68 var effect = $this.attr("data-effect"); 69 var context = $this.attr("data-context"); 70 71 if (typeof pid !== typeof undefined && pid !== false) { 72 id = pid; 73 } 74 75 if (typeof product_id !== typeof undefined && product_id !== false) { 76 id = product_id; 77 } 78 79 spsgqcv_open(id, effect, context); 80 }); 81 82 $(document).on("spsgqcv_loaded", function () { 83 var form_variation = $("#spsgqcv-popup").find(".variations_form"); 84 85 form_variation.each(function () { 86 $(this).wc_variation_form(); 87 }); 88 89 spsgqcv_init_content("loaded"); 90 91 // add redirect 92 if (!$("#spsgqcv-popup .spsgqcv-redirect").length) { 93 if ( 94 spsgqcv_vars.cart_redirect !== "shop-page-redirection" && 95 spsgqcv_vars.cart_url !== "" 96 ) { 97 $("#spsgqcv-popup form").prepend( 98 '<input class="spsgqcv-redirect" name="spsgqcv-redirect" type="hidden" value="' + 99 spsgqcv_vars.cart_url + 100 '"/>' 101 ); 102 } else { 103 $("#spsgqcv-popup form").prepend( 104 '<input class="spsgqcv-redirect" name="spsgqcv-redirect" type="hidden" value="' + 105 window.location.href + 106 '"/>' 107 ); 108 } 109 } 110 }); 111 112 $(window).on("resize", function () { 113 spsgqcv_init_content("resize"); 114 }); 115 116 $(document).on("found_variation", function (e, t) { 117 if ( 118 !$(e["target"]).closest(".woosb-product").length && 119 !$(e["target"]).closest(".woosg-product").length && 120 !$(e["target"]).closest(".woobt-product").length && 121 !$(e["target"]).closest(".woofs-product").length && 122 $(e["target"]).closest("#spsgqcv-popup").length 123 ) { 124 if (t["image_id"] !== undefined) { 125 if ($("#spsgqcv-popup .thumbnails .thumbnail").length > 1) { 126 var $thumb = $( 127 '.thumbnail:not(.slick-cloned)[data-id="' + t["image_id"] + '"]' 128 ); 129 130 if ($thumb.length) { 131 var pos = $("#spsgqcv-popup .thumbnails .thumbnail").index($thumb); 132 var $images = $("#spsgqcv-popup .thumbnails .images"); 133 134 if (pos > 0 && $images.hasClass("slick-initialized")) { 135 setTimeout(function () { 136 $images.slick("slickGoTo", pos - 1); 137 }, 100); 138 } 139 } 140 } 141 } 142 } 143 }); 144 145 $(document).on("reset_data", function (e) {
146 if ($(e["target"]).closest("#spsgqcv-popup").length) { 147 if ( 148 $("#spsgqcv-popup .thumbnails .thumbnail").length > 1 && 149 $("#spsgqcv-popup .thumbnails .images").hasClass("slick-initialized") 150 ) { 151 $("#spsgqcv-popup .thumbnails .images").slick("slickGoTo", 0); 152 } 153 } 154 }); 155 156 if (spsgqcv_vars.hashchange === "yes") { 157 $(window).on("hashchange", function () { 158 if (location.href.indexOf("#spsgqcv") < 0) { 159 if (spsgqcv_vars.view === "popup") { 160 $.magnificPopup.close(); 161 } 162 163 spsgqcv_close(); 164 } 165 }); 166 } 167 168 $(document).on( 169 "click touch", 170 ".spsgqcv-overlay, .spsgqcv-close", 171 function () { 172 spsgqcv_close(); 173 } 174 ); 175})(jQuery); 176 177function spsgqcv_open(id, effect, context) { 178 jQuery("body").addClass("spsgqcv-open"); 179 180 if (spsgqcv_vars.view === "sidebar") { 181 // sidebar 182 spsgqcv_loading(); 183 184 var data = { 185 action: "spsgqcv_quickview", 186 product_id: id, 187 nonce: spsgqcv_vars.nonce, 188 }; 189 190 jQuery.post(spsgqcv_vars.ajax_url, data, function (response) { 191 jQuery(".spsgqcv-sidebar").html(response); 192 spsgqcv_loaded(); 193 jQuery(document.body).trigger("spsgqcv_loaded", [id]); 194 }); 195 } else { 196 // popup 197 if (-1 === jQuery.inArray(id, spsgqcv_ids)) { 198 spsgqcv_ids.push(id); 199 spsgqcv_products.push({ 200 src: spsgqcv_vars.ajax_url + "?product_id=" + id, 201 }); 202 } 203 204 var index = spsgqcv_get_key( 205 spsgqcv_products, 206 "src", 207 spsgqcv_vars.ajax_url + "?product_id=" + id 208 ); 209 var main_class = "mfp-spsgqcv"; 210 211 if (typeof context !== typeof undefined && context !== false) { 212 main_class = main_class + " mfp-spsgqcv-" + context; 213 } 214 215 if (typeof effect !== typeof undefined && effect !== false) { 216 main_class = main_class + " " + effect; 217 } else { 218 main_class = main_class + " " + spsgqcv_vars.effect; 219 } 220 221 jQuery.magnificPopup.open( 222 { 223 items: spsgqcv_products, 224 type: "ajax", 225 mainClass: main_class, 226 removalDelay: 160, 227 overflowY: "scroll", 228 fixedContentPos: true, 229 tClose: spsgqcv_vars.close, 230 showCloseBtn: spsgqcv_vars?.enable_close_button, 231 gallery: { 232 tPrev: spsgqcv_vars.prev, 233 tNext: spsgqcv_vars.next, 234 enabled: spsgqcv_vars.next_prev === "yes", 235 }, 236 ajax: { 237 settings: { 238 type: "GET", 239 data: { 240 action: "spsgqcv_quickview", 241 nonce: spsgqcv_vars.nonce, 242 }, 243 }, 244 }, 245 callbacks: { 246 open: function () { 247 if (spsgqcv_vars.hashchange === "yes") { 248 location.href = location.href.split("#")[0] + "#spsgqcv"; 249 } 250 }, 251 ajaxContentAdded: function () { 252 jQuery(document.body).trigger("spsgqcv_loaded", [id]); 253 }, 254 close: function () { 255 if (spsgqcv_vars.hashchange === "yes") { 256 if (location.hash) history.go(-1); 257 } 258 }, 259 afterClose: function () { 260 jQuery(document.body).trigger("spsgqcv_close", [id]); 261 }, 262 }, 263 }, 264 index 265 ); 266 } 267 268 jQuery(document.body).trigger("spsgqcv_open", [id]); 269} 270 271function spsgqcv_close() { 272 jQuery("body").removeClass("spsgqcv-open"); 273 jQuery(document.body).trigger("spsgqcv_close"); 274} 275 276function spsgqcv_loading() { 277 jQuery(".spsgqcv-sidebar").addClass("spsgqcv-loading"); 278} 279 280function spsgqcv_loaded() { 281 jQuery(".spsgqcv-sidebar").removeClass("spsgqcv-loading"); 282} 283 284function isFunctionDefined(func) { 285 return typeof func === "function"; 286} 287 288function isFunctionDefined(func) { 289 return typeof func === "function"; 290} 291 292function callIfDefined(func) { 293 if (isFunctionDefined(func)) { 294 try { 295 func(); 296 } catch (error) { 297 return; 298 } 299 } 300} 301 302function spsgqcv_init_content(context) { 303 if (context === "loaded") { 304 // Call other methods even if they may not be defined initially 305 306 spsgqcv_thumbnails_zoom(); 307 spsgqcv_thumbnails_slick(); 308 spsgqcv_related_slick(); 309 310 if (spsgqcv_vars.cart_redirect === "add-to-cart-ajax") { 311 if (typeof spsgqcv_add_to_cart_ajax_handler === "function") { 312 callIfDefined(spsgqcv_add_to_cart_ajax_handler); 313 } 314 } 315 316 if (typeof spsgDirectChecoutQuick !== "undefined") { 317 spsgDirectChecoutQuick.init(); 318 } 319 if (typeof spsg_countdown_timer_methods === "function") { 320 callIfDefined(spsg_countdown_timer_methods); 321 } 322 323 if (typeof spsg_stockbar_jqmeter === "function") { 324 callIfDefined(spsg_stockbar_jqmeter); 325 } 326 } 327} 328
329function spsgqcv_get_key(array, key, value) { 330 for (var i = 0; i < array.length; i++) { 331 if (array[i][key] === value) { 332 return i; 333 } 334 } 335 336 return -1; 337} 338 339function spsgqcv_thumbnails_zoom() { 340 if (spsgqcv_vars.thumbnails_effect) { 341 jQuery("#spsgqcv-popup .thumbnails .images .thumbnail").each(function () { 342 var $this = jQuery(this); 343 var zoom_params = JSON.parse(spsgqcv_vars.thumbnails_zoom_params); 344 345 zoom_params.url = $this.find("img").attr("data-src"); 346 347 // destroy first 348 $this.trigger("zoom.destroy"); 349 $this.zoom(zoom_params); 350 }); 351 } 352} 353 354function spsgqcv_thumbnails_slick() { 355 if (jQuery("#spsgqcv-popup .thumbnails .images .thumbnail").length > 1) { 356 if ( 357 jQuery("#spsgqcv-popup .thumbnails .images").hasClass("slick-initialized") 358 ) { 359 // unslick first 360 jQuery("#spsgqcv-popup .thumbnails .images").slick("unslick"); 361 } 362 363 jQuery("#spsgqcv-popup .thumbnails .images").slick( 364 JSON.parse(spsgqcv_vars.thumbnails_slick_params) 365 ); 366 } 367} 368 369function spsgqcv_related_slick() { 370 if (jQuery(".spsgqcv-related-products").hasClass("slick-initialized")) { 371 // unslick first 372 jQuery(".spsgqcv-related-products").slick("unslick"); 373 } 374 375 if (jQuery(".spsgqcv-related-product").length > 1) { 376 jQuery(".spsgqcv-related-products").slick( 377 JSON.parse(spsgqcv_vars.related_slick_params) 378 ); 379 } 380}
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.