1jQuery(document).ready(function () { 2 3 if (jQuery('.single-product .sb_woo_product_image').length) { 4 5 sb_woo_gen_hidden_images(); 6 7 jQuery('.single-product .sb_woo_product_image').each(function () { 8 var large_url = jQuery(this).children('img').attr('src'); 9 10 if (!jQuery(this).hasClass('sb_woo_image_disable_zoom')) { 11 jQuery(this).zoom({ 12 callback: function () { 13 if (!jQuery(this).hasClass('sb_woo_image_disable_lightbox')) { 14 15 jQuery('.wli-clone').prepend(jQuery('<a href="' + large_url + '"></a>')) 16 17 jQuery(this).click(function () { 18 jQuery('.wli-clone a').colorbox({ 19 rel: 'wli-clone', 20 open: true, 21 maxWidth: '95%', 22 maxHeight: '95%', 23 onClosed: function () { 24 sb_woo_cbox_close(); 25 } 26 }); 27 }); 28 //jQuery(this).colorbox({ href: large_url }); 29 } 30 } 31 }); 32 } else { 33 if (!jQuery(this).hasClass('sb_woo_image_disable_lightbox')) { 34 35 jQuery('.wli-clone').prepend(jQuery('<a href="' + large_url + '"></a>')) 36 37 jQuery(this).click(function () { 38 jQuery('.wli-clone a').colorbox({ 39 rel: 'wli-clone', 40 open: true, 41 maxWidth: '95%', 42 maxHeight: '95%', 43 onClosed: function () { 44 sb_woo_cbox_close(); 45 } 46 }); 47 }); 48 //jQuery(this).colorbox({ href: large_url }); 49 } 50 } 51 }); 52 } 53 54 if (jQuery('.single-product .cart.variations_form')) {
55 //////////////////////////////////////////////// 56 jQuery('.single-product .cart.variations_form .variations .value select').each(function (index, attr) { 57 jQuery(this).change(function () { 58 sb_woo_variation_image(); 59 }); 60 }); 61 //////////////////////////////////////////////// 62 } 63 64 if (jQuery('.woocommerce-remove-coupon').length) { 65 jQuery('.et_pb_woo_checkout_coupon').slideUp(); 66 } 67 68 //to handle removing items from the cart with a blank response. Note to edit this if no empty cart layout specified 69 //jQuery(document.body).on('wc_fragments_refreshed', function () { 70 //if (jQuery('body.woocommerce-cart').length && (!jQuery('.woocommerce-cart-form').length && !jQuery('.sb_et_woo_li_cart_empty').length)) { 71 //console.log('Woo Injector Refreshing Cart'); 72 //location.reload(); //refresh the page 73 //} 74 //}); 75 76 //to recalculate the product count in cart 77 jQuery(document.body).on('wc_fragments_loaded', function () { 78 wli_refresh_cart_count(); 79 }); 80 81 //to recalculate the product count in cart 82 jQuery(document.body).on('wc_fragments_refreshed', function () { 83 wli_refresh_cart_count(); 84 }); 85 86 if (jQuery('body').hasClass('wli_injected')) { 87 88 if (jQuery('.wpcf7').length > 0) { 89 var wli_post_id, matches = document.body.className.match(/(^|\s)postid-(\d+)(\s|$)/); 90 if (matches) { 91 jQuery("input[name='_wpcf7_container_post']").val(matches[2]); 92 jQuery(".wpcf7-submit").addClass('button'); 93 jQuery(".wpcf7-form > p").addClass('form-row'); 94 jQuery(".wpcf7-form > p .wpcf7-form-control-wrap input").addClass('input-text'); 95 } 96 } 97 98 //to add class of button to thr add to cart ajax function for consistency 99 jQuery(document.body).on('added_to_cart', function () { 100 setTimeout(function () { 101 jQuery('.added_to_cart').addClass('button'); 102 }, 50); 103 }); 104 105 //to handle showing the coupon system in a lightbox 106 jQuery(document.body).on("checkout_error", function () { 107 108 if (jQuery('.woocommerce-NoticeGroup').length) { 109 sb_woo_popup_notice(jQuery('.woocommerce-NoticeGroup').html()); 110 setTimeout(function () { 111 jQuery('.woocommerce-NoticeGroup').remove(); 112 }, 250); 113 } 114 }); 115 116 //to handle showing the coupon system in a lightbox 117 jQuery(document.body).on("updated_wc_div", function () { 118 119 if (jQuery('.woocommerce .woocommerce-error').length) { 120 sb_woo_popup_notice(jQuery('.woocommerce .woocommerce-error')); 121 jQuery('.entry-content .woocommerce .woocommerce-error').remove(); 122 } 123 if (jQuery('.woocommerce .woocommerce-message').length) { 124 sb_woo_popup_notice(jQuery('.woocommerce .woocommerce-message').clone().wrap("<div />")); 125 jQuery('.entry-content .woocommerce .woocommerce-message').remove(); 126 }
127 if (jQuery('.cart-empty').length > 0) { 128 jQuery('.et_pb_woo_cart_totals').remove(); 129 } 130 }); 131 132 //to handle showing the coupon system in a lightbox 133 jQuery(document.body).on("applied_coupon", function () { 134 135 if (jQuery('.woocommerce .woocommerce-error').length) { 136 sb_woo_popup_notice(jQuery('.woocommerce .woocommerce-error')); 137 jQuery('.entry-content .woocommerce .woocommerce-error').remove(); 138 } 139 }); 140 141 //to handle showing the coupon removed in a lightbox 142 jQuery(document.body).on("removed_coupon", function () { 143 144 if (jQuery('.woocommerce .woocommerce-message').length) { 145 sb_woo_popup_notice(jQuery('.woocommerce .woocommerce-message').clone().wrap("<div />")); 146 jQuery('.entry-content .woocommerce .woocommerce-message').remove(); 147 } 148 }); 149 150 //to handle showing the coupon system in a lightbox 151 jQuery(document.body).on("update_checkout", function () { 152 153 if (jQuery('.wli_wrapper_checkout-form-coupon .woocommerce-error').length) { 154 sb_woo_popup_notice(jQuery('.wli_wrapper_checkout-form-coupon .woocommerce-error').clone().wrap("<div />")); 155 jQuery('.et_pb_woo_checkout_coupon').slideDown(); 156 157 } else if (jQuery('.wli_wrapper_checkout-form-coupon .woocommerce-message').length) { 158 sb_woo_popup_notice(jQuery('.wli_wrapper_checkout-form-coupon .woocommerce-message').clone().wrap("<div />")); 159 jQuery('.coupon-module').val(''); 160 161 if (jQuery('.woocommerce-remove-coupon').length) { 162 jQuery('.et_pb_woo_checkout_coupon').slideDown(); 163 } else { 164 jQuery('.et_pb_woo_checkout_coupon').slideUp(); 165 } 166 167 } else if (jQuery('.woocommerce .woocommerce-message').length) { 168 sb_woo_popup_notice(jQuery('.woocommerce .woocommerce-message').clone().wrap("<div />")); 169 setTimeout(function () { 170 jQuery('.entry-content > .woocommerce > .woocommerce-message').remove(); 171 }, 250); 172 173 } 174 175 }); 176 } 177 178}); 179 180function wli_refresh_cart_count() { 181 var wli_new_count = 0; 182 183 if (jQuery('.sb_woo_mini_cart ul li').length) { 184 jQuery('.sb_woo_mini_cart ul li').each(function () { 185 var wli_quantity = jQuery(this).children('.quantity').text(); 186 var wli_quantity_nums = wli_quantity.split(' '); 187 var wli_quantity_num = parseInt(wli_quantity_nums[0]); 188 189 wli_new_count += wli_quantity_num; 190 }); 191 } 192 193 if (wli_new_count <= 0) { 194 wli_new_count = ''; 195 } 196 197 jQuery('.sb_woo_prod_cart_container .et-cart-info span').text(wli_new_count); 198} 199 200function sb_woo_popup_notice(popup_object) { 201 jQuery('html, body').scrollTop(0); 202 203 jQuery.colorbox({ 204 html: popup_object, 205 width: "50%", 206 className: "woocommerce" 207 }); 208} 209 210function sb_woo_maybe_submit_checkout_coupon() { 211 jQuery(this).keypress(function (e) { 212 if (e.which == 13) { 213 sb_woo_submit_checkout_coupon(); 214 } 215 }); 216} 217 218function sb_woo_submit_checkout_coupon() { 219 if (jQuery('.coupon-module').length) { 220 jQuery('.coupon-module').parent().removeClass('woocommerce-invalid').removeClass('woocommerce-validated'); 221 222 var coupon = jQuery('.coupon-module').val(); 223 224 if (coupon != '') { 225 jQuery('#coupon_code').val(coupon); 226 jQuery('.checkout_coupon').submit(); 227 } else { 228 jQuery('.coupon-module').parent().addClass('woocommerce-invalid').removeClass('woocommerce-validated'); 229 } 230 } 231 232 return false; 233} 234 235function sb_woo_variation_image() { 236 //get variation data and store in sb_woo_attr_data 237 var sb_woo_attr_data = jQuery('.single-product .cart.variations_form').data('product_variations'); 238 var sb_woo_attr_val = ''; 239 var sb_woo_attr_id = ''; 240 var sb_woo_attr_name = ''; 241 var sb_woo_attr_set = []; 242 var sb_woo_attr_set_l = 0; 243 var sb_woo_attr_set_matched = 0; 244 var sb_woo_found_set = []; 245 var sb_woo_large_image = ''; 246
247 //////////////////////////////////////////////////// 248 249 //cache current variation choices in "sb_woo_attr_set" 250 jQuery('.single-product .cart.variations_form .variations .value select').each(function (index2, attr2) { 251 sb_woo_attr_val = jQuery(this).val(); 252 sb_woo_attr_id = jQuery(this).attr('id'); 253 sb_woo_attr_name = 'attribute_' + sb_woo_attr_id; 254 255 if (sb_woo_attr_val) { 256 sb_woo_attr_set.push([sb_woo_attr_name, sb_woo_attr_val]); 257 sb_woo_attr_set_l++; 258 } 259 }); 260 261 //////////////////////////////////////////////////// 262 263 if (sb_woo_attr_set_l > 0) { //foreach of the stored attribute variables 264 jQuery(sb_woo_attr_data).each(function (index3, attr3) { //loop variation prices 265 var sb_woo_attrs = attr3.attributes; 266 sb_woo_attr_set_matched = 0; //reset to 0 267 268 //loop attributes linked to this attribute set 269 jQuery(sb_woo_attrs).each(function (index4, attr4) { 270 jQuery(attr4).each(function (index4, attr4) { 271 jQuery(sb_woo_attr_set).each(function (index5, attr5) { 272 if (attr4[attr5[0]] == attr5[1] || attr4[attr5[0]] == "") { 273 sb_woo_attr_set_matched++; 274 } 275 }); 276 }); 277 }); 278 279 if (sb_woo_attr_set_matched >= sb_woo_attr_set_l) { 280 sb_woo_found_set = attr3; //we found a matching set... store it! 281 } 282 }); 283 284 if (typeof sb_woo_found_set.image !== 'undefined') { 285 sb_woo_large_image = sb_woo_found_set.image.full_src; 286 } else { 287 sb_woo_large_image = jQuery('.sb_woo_product_thumb_col_num_1 a').data('large_image'); 288 } 289 290 if (jQuery('.sb_woo_product_image_container').length) { 291 sb_woo_product_thumb_replace_by_url(sb_woo_large_image, jQuery('.sb_woo_product_image_container:first')); //we aren't selecting the same element here so just grab the image directly 292 } 293 294 } 295 296} 297 298function sb_woo_cbox_close() { 299 //jQuery('a.wli-core').remove(); 300 //jQuery('a.wli-added').remove(); 301} 302 303function sb_woo_gen_hidden_images() { 304 //var $gallery = jQuery('<div>').appendTo('body'); 305 var $gallery = jQuery('<div class="wli-clone">').hide().appendTo('body'); 306 var arr = jQuery('a.sb-woo-images'); 307 var large_image = ''; 308 309 jQuery.each(arr, function (i) { 310 311 if (large_image = jQuery(this).data('large_image')) { 312 jQuery('<a class="wli-core wli-img-' + i + '" href="' + large_image + '"></a>').appendTo($gallery); 313 } 314 }); 315 316 //$gallery.find('a').colorbox({rel: 'wli-clone', open: true}); 317} 318 319function sb_woo_product_thumb_replace_by_url(large_image, image_object) { 320 if (jQuery('.single-product .sb_woo_product_image img').attr('src') == large_image) { 321 return; 322 } 323 324 var parent_object = image_object.closest('.sb_woo_product_image_container'); 325 326 if (parent_object.length == 0) { 327 var parent_object = jQuery('.sb_woo_product_image_container'); 328 } 329 330 if (parent_object.length == 0) { 331 var parent_object = jQuery('.et_pb_woo_thumbs:first-child'); 332 } 333 334 if (parent_object.length) { 335 336 parent_object.find('.sb_woo_product_image img').trigger('zoom.destroy'); // remove zoom 337 parent_object.find('.sb_woo_product_image img.zoomImg').remove(); //remove old zoom image 338 339 var image_height = parent_object.find('.sb_woo_product_image img').height(); 340 341 parent_object.find('.sb_woo_product_image').css('height', image_height + 'px'); 342 343 parent_object.find('.sb_woo_product_image img').fadeOut(400, function () { 344 parent_object.find('.sb_woo_product_image img').attr('src', large_image); 345 346 parent_object.find('.sb_woo_product_image').imagesLoaded(function () { 347 var image_height = parent_object.find('.sb_woo_product_image img').height(); 348 349 parent_object.find('.sb_woo_product_image').css('height', image_height + 'px'); 350 351 parent_object.find('.sb_woo_product_image img').fadeIn(400, function () { 352 if (!parent_object.find('.sb_woo_product_image').hasClass('sb_woo_image_disable_zoom')) { 353 parent_object.find('.sb_woo_product_image').zoom({ 354 callback: function () { 355 if (!parent_object.find('.sb_woo_product_image').hasClass('sb_woo_image_disable_lightbox')) { 356 357 jQuery.each(jQuery('.wli-clone a'), function () { 358 if (jQuery(this).attr('href') == parent_object.find('.sb_woo_product_image img').attr('src')) { 359 jQuery(this).remove(); 360 } 361 }); 362 363 jQuery('.wli-clone').prepend(jQuery('<a class="wli-added" href="' + parent_object.find('.sb_woo_product_image img').attr('src') + '"></a>')); 364 365 parent_object.find('.sb_woo_product_image').click(function () { 366 jQuery('.wli-clone a').colorbox({ 367 rel: 'wli-clone', 368 open: true, 369 maxWidth: '95%', 370 maxHeight: '95%', 371 onClosed: function () { 372 sb_woo_cbox_close(); 373 } 374 }); 375 }); 376 } 377 } 378 }); 379 } else { 380 if (!parent_object.find('.sb_woo_product_image').hasClass('sb_woo_image_disable_lightbox')) { 381 382 jQuery.each(jQuery('.wli-clone a'), function () { 383 if (jQuery(this).attr('href') == parent_object.find('.sb_woo_product_image img').attr('src')) { 384 jQuery(this).remove(); 385 } 386 }); 387 388 jQuery('.wli-clone').prepend(jQuery('<a class="wli-added" href="' + parent_object.find('.sb_woo_product_image img').attr('src') + '"></a>')) 389 390 parent_object.find('.sb_woo_product_image').click(function () { 391 jQuery('.wli-clone a').colorbox({ 392 rel: 'wli-clone', 393 open: true, 394 maxWidth: '95%', 395 maxHeight: '95%', 396 onClosed: function () { 397 sb_woo_cbox_close(); 398 } 399 }); 400 }); 401 402 //jQuery('.sb_woo_product_image').colorbox({ href: parent_object.find('.sb_woo_product_image img').attr('src') }); 403 } 404 } 405 }); 406 }); 407 }); 408 } else { 409 jQuery.colorbox({ 410 href: large_image 411 }); 412 } 413} 414 415function sb_woo_product_thumb_replace(image_object) { 416 var large_image = image_object.data('large_image'); 417 418 sb_woo_product_thumb_replace_by_url(large_image, image_object); 419}
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.