1//**All js for woocommerce of theme 2 3(function ($) { 4 'use strict'; 5 $(document).ready(function () { 6 //Sidebar control 7 $(document).on('click', '.zoo-sidebar-control', function (e) { 8 e.preventDefault(); 9 $(this).toggleClass('active'); 10 $('.product-sidebar').toggleClass('active'); 11 if (!$(this).closest('.top-sidebar-layout')[0] || $(window).width() < 992) { 12 $('.zoo-mask-close').addClass('sidebar-active active'); 13 } 14 if ($(this).closest('.top-sidebar-layout')[0] && $(window).width() > 992) { 15 $('.zoo-top-sidebar.product-sidebar').slideToggle("slow"); 16 } 17 }); 18 $(document).on('click', '.sidebar-active.active, .close-btn.close-sidebar', function (e) { 19 e.preventDefault(); 20 $('.product-sidebar, .zoo-sidebar-control').removeClass('active'); 21 $('.zoo-mask-close').removeClass('sidebar-active active'); 22 }); 23 24 $(document).on('click', '.heading-toggle-block', function () { 25 $(this).zoo_toggleBlock(); 26 }); 27 //Toggle Shop Layout 28 $(document).on('click', '.toggle-products-layout-button:not(.active)', function (e) { 29 e.preventDefault(); 30 $('.toggle-products-layout-button.active').removeClass('active'); 31 $(this).addClass('active'); 32 if ($(this).data('layout') == 'list') { 33 setCookie('zoo_product_layout', 'list'); 34 $('.zoo-products-shop-loop .products').addClass('list-layout'); 35 $('.zoo-products-shop-loop .products').removeClass('grid-layout'); 36 } else { 37 deleteCookie('zoo_product_layout'); 38 $('.zoo-products-shop-loop .products').removeClass('list-layout'); 39 $('.zoo-products-shop-loop .products').addClass('grid-layout'); 40 } 41 }); 42 //Scroll effect for Review link when click. 43 $(document).on('click', '.woocommerce-review-link', function (e) { 44 if ($('.zoo-product-data-tabs.accordion-layout')[0]) { 45 if ($('#tab-reviews').closest('.zoo-group-accordion:not(.accordion-active)')[0]) { 46 $('.zoo-group-accordion.accordion-active .wc-tab').hide(); 47 } 48 $('#tab-reviews').closest('.zoo-group-accordion:not(.accordion-active)').find('.tab-heading').trigger('click'); 49 $('html, body').animate({ 50 scrollTop: $('#tab-reviews').offset().top - $('.site-header').height() 51 }, 500); 52 } 53 }); 54 55 //Product qty control 56 $(document).zoo_CartQuantity('.quantity .qty-nav'); 57 //Sticky product layout 58 zoo_product_sticky_layout(); 59 //Product Gallery 60 zoo_product_gallery(); 61 //Gallery light box 62 zoo_gallery_light_box(); 63 //Product tabs 64 zoo_product_tabs_block(); 65 //Products carousel 66 zoo_products_carousel(); 67 //Product variation 68 zoo_product_variable(); 69 //Alternative image, change to alt image when hover to product. 70 zoo_alternate_image(); 71 //Js control display form login/register 72 zoo_toggle_myacount_form(); 73 //Coupon code for cart page 74 zoo_add_coupon_cart(); 75 //Sticky add to cart button 76 zoo_sticky_add_to_cart(); 77 //Clever Swatches extend function for theme 78 zoo_cleverswatches_function(); 79 //Count down to end of day 80 zoo_countdown_end_day(); 81 //Extend cart info lightbox. 82 zoo_extend_cart_info(); 83 // Call back count down timer for variable product 84 zoo_call_back_countdown(); 85 }); 86 // Call back count down timer for variable product 87 function zoo_call_back_countdown(){ 88 $(document).on( "show_variation",".variations_form:not(.cw-form-data)",function () { 89 console.log('form change'); 90 var $this = $('.variations_form [data-countdown="countdown"]'); 91 if($this[0]){ 92 var $date = $this.data('date').split("-"); 93 $this.lofCountDown({ 94 TargetDate:$date[0]+"/"+$date[1]+"/"+$date[2]+" "+$date[3]+":"+$date[4]+":"+$date[5], 95 DisplayFormat:"<div class=\"countdown-times\"><div class=\"day\">%%D%% Days </div><div class=\"hours\">%%H%% Hours </div><div class=\"minutes\">%%M%% Mins </div><div class=\"seconds\">%%S%% Secs </div></div>", 96 FinishMessage: "Expired" 97 }); 98 } 99 } ); 100 } 101 //Binding Ajax for Ajax event cart and check out 102 $(document).on('updated_checkout updated_cart_totals zoo_single_product_cart_added added_to_cart wc_fragment_refresh', function () { 103 setTimeout(function () { 104 $('.lazy-img').zoo_lazyImg(); 105 }, 100); 106 }); 107 //Binding Ajax for CLN 108 $(document).on('zoo_ln_after_filter', function (event, response) { 109 $('.grid-layout.products').zoo_WooSmartLayout(); 110 setTimeout(function () { 111 $('.product-sidebar, .zoo-sidebar-control').removeClass('active'); 112 $('.zoo-mask-close').removeClass('sidebar-active active'); 113 }, 100); 114 setTimeout(function () { 115 //Ajax change layout 116 if (typeof $.fn.isotope != 'undefined') 117 $('.grid-layout.products.highlight-featured').isotope('reloadItems'); 118 }, 350); 119 if ($(window).width() > 992) { 120 $('.zoo-top-sidebar.product-sidebar').slideToggle("slow"); 121 } else { 122 $('html, body').animate({ 123 scrollTop: $('.zoo-products-shop-loop .products').offset().top 124 }, 500); 125 } 126 }); 127 128 //After all resource loaded 129 $(window).load(function () { 130 $('.products.highlight-featured .product.featured img').attr('sizes', ''); 131 var current_width = 0; 132 $(window).resize(function () { 133 if (current_width != $(window).width()) { 134 current_width = $(window).width(); 135 setTimeout(function () { 136 $('.grid-layout.products').zoo_WooSmartLayout(); 137 $('.cvca-products-wrap.advanced-filter .grid-layout.products').zoo_WooSmartLayout(); 138 }, 300); 139 140 if ($(window).width() < 769) { 141 let this_to_top = 0; 142 $('#site-header .sticker:visible').each(function () { 143 if (!!$(this).data('sticky-height')) { 144 this_to_top = $(this).data('sticky-height') + this_to_top; 145 } else { 146 this_to_top = $(this).height() + this_to_top; 147 } 148 }); 149 $('.wrap-top-shop-loop').stick_in_parent({ 150 bottoming: false, 151 sticky_class: 'is-sticky', 152 offset_top: this_to_top 153 }); 154 } else { 155 $('.wrap-top-shop-loop').trigger("sticky_kit:detach"); 156 } 157 } 158 }).resize(); 159 //360 product view 160 zoo_product_360_view(); 161 }); 162 163 //After screen resize 164 $(window).on('resize', function () { 165 if ($(window).width() > 769) { 166 if ($('.sticky.zoo-single-product')[0] || $('.images-center.zoo-single-product')[0]) { 167 var offset = 0; 168 if ($('#site-header .sticky-wrapper')[0]) { 169 offset = $('#site-header .sticky-wrapper').height() + 30; 170 } 171 $('.wrap-right-single-product').stick_in_parent({offset_top: offset}); 172 $('.images-center.zoo-single-product .zoo-woo-tabs.zoo-accordion').stick_in_parent(); 173 } 174 } 175 }).resize(); 176 177 /** 178 * Set a cookie 179 * @param {String} cname, cookie name, {String} cookie value 180 */ 181 function setCookie(cname, cvalue) { 182 document.cookie = cname + "=" + cvalue + "; "; 183 } 184 185 /** 186 * Delete a cookie 187 * @param {String} cname, cookie name 188 */ 189 function deleteCookie(cname) { 190 var d = new Date(); //Create an date object 191 d.setTime(d.getTime() - (1000 * 60 * 60 * 24)); //Set the time to the past. 1000 milliseonds = 1 second 192 var expires = "expires=" + d.toGMTString(); //Compose the expirartion date 193 window.document.cookie = cname + "=" + "; " + expires;//Set the cookie with name and the expiration date 194 195 } 196 197 function getCookie(cname) { 198 var name = cname + "="; 199 var ca = document.cookie.split(';'); 200 for (var i = 0; i < ca.length; i++) { 201 var c = ca[i]; 202 while (c.charAt(0) == ' ') { 203 c = c.substring(1); 204 } 205 if (c.indexOf(name) == 0) { 206 return c.substring(name.length, c.length); 207 } 208 } 209 return ""; 210 } 211 212 213 214 //Clever Swatches extend Function 215 function zoo_cleverswatches_function() { 216 $(document).on('cleverswatch_button_select_option', function (event, response) { 217 var add_to_cart_button = response.selector; 218 add_to_cart_button.closest('.variations_form').find('.zoo-buy-now').addClass('disabled'); 219 }); 220 //Bind for button if button is Add to Cart 221 $(document).on('cleverswatch_button_add_cart', function (event, response) { 222 var add_to_cart_button = response.selector; 223 add_to_cart_button.closest('.variations_form').find('.zoo-buy-now').removeClass('disabled'); 224 }); 225 //Bind for button if button is Out of stock 226 $(document).on('cleverswatch_button_out_stock', function (event, response) { 227 var add_to_cart_button = response.selector; 228 add_to_cart_button.closest('.variations_form').find('.zoo-buy-now').addClass('disabled'); 229 }); 230 231 $(document).on('cleverswatch_update_gallery', function (event, response) { 232 if (!$('#zoo-quickview-lb')[0]){ 233 zoo_product_gallery(); 234 } 235 var $this = $('.variations_form [data-countdown="countdown"]'); 236 if($this[0]){ 237 var $date = $this.data('date').split("-"); 238 $this.lofCountDown({ 239 TargetDate:$date[0]+"/"+$date[1]+"/"+$date[2]+" "+$date[3]+":"+$date[4]+":"+$date[5], 240 DisplayFormat:"<div class=\"countdown-times\"><div class=\"day\">%%D%% Days </div><div class=\"hours\">%%H%% Hours </div><div class=\"minutes\">%%M%% Mins </div><div class=\"seconds\">%%S%% Secs </div></div>", 241 FinishMessage: "Expired" 242 }); 243 } 244 }); 245 $(window).resize(function () { 246 if ($(window).width() > 769 && $('.zoo-cw-is-desktop')[0]) { 247 $(document).on('mouseenter mouseleave click', '.variations_form .zoo-cw-attribute-option', 248 function(){ 249 var $this = $('.variations_form [data-countdown="countdown"]'); 250 if($this[0]){ 251 var $date = $this.data('date').split("-"); 252 $this.lofCountDown({ 253 TargetDate:$date[0]+"/"+$date[1]+"/"+$date[2]+" "+$date[3]+":"+$date[4]+":"+$date[5], 254 DisplayFormat:"<div class=\"countdown-times\"><div class=\"day\">%%D%% Days </div><div class=\"hours\">%%H%% Hours </div><div class=\"minutes\">%%M%% Mins </div><div class=\"seconds\">%%S%% Secs </div></div>", 255 FinishMessage: "Expired" 256 }); 257 } 258 }); 259 } 260 }).resize(); 261 } 262 263 //Sticky product layout 264 function zoo_product_sticky_layout() { 265 $(window).load(function () { 266 if (typeof $.fn.stick_in_parent != 'undefined') { 267 var window_width = ''; 268 $(window).resize(function () { 269 if (window_width != $(window).width()) { 270 window_width = $(window).width(); 271 let $stick_content = $('.sticky-content-layout .wrap-single-product-images, .sticky-content-layout .product .wrap-sticky-content-block>.summary'); 272 if (window_width > 992) { 273 $stick_content.stick_in_parent({offset_top: $('.
273site-header').height()}); 274 } else { 275 $stick_content.trigger('sticky_kit:detach'); 276 } 277 } 278 }).resize(); 279 } 280 }); 281 } 282 283 /** 284 * Variable product Form control gallery 285 * Apply for case CW not active. 286 * */ 287 function zoo_product_variable() { 288 var orginal_image = ''; 289 var orginal_large_image = ''; 290 jQuery(document).on("show_variation", "form.variations_form", function (event, variation) { 291 if (!$('.zoo-cw-page')[0]) { 292 orginal_image = $('.wrap-main-product-gallery .slick-current img').attr('src'); 293 orginal_large_image = $('.wrap-main-product-gallery .slick-current img').data('src'); 294 if (variation.image.full_src != '') { 295 var newimg = variation.image.src; 296 var newurl = variation.image.url; 297 zoo_product_variable_gallery(newimg,newurl); 298 } 299 } 300 }); 301 jQuery(".reset_variations").on("click", function (event) { 302 if (!$('.zoo-cw-page')[0]) { 303 event.preventDefault(); 304 zoo_product_variable_gallery(orginal_image,orginal_large_image); 305 }else{ 306 return; 307 } 308 }); 309 } 310 /** 311 * Variable product gallery 312 * Apply for case CW not active. 313 * Call back when form change. 314 * */ 315 function zoo_product_variable_gallery(orginal_image,orginal_large_image) { 316 $('.zoo-product-gallery .slick-current img:not(.zoomImg)').attr('src', orginal_image); 317 $('.zoo-product-gallery .slick-current img:not(.zoomImg)').attr('data-src', orginal_image); 318 $('.zoo-product-gallery .slick-current img.zoomImg').attr('src', orginal_large_image); 319 $('.zoo-product-gallery .slick-current img:not(.zoomImg)').attr('srcset', orginal_image); 320 $('.zoo-product-gallery .slick-current a').attr('href', orginal_large_image); 321 322 if (typeof $.fn.zoom != 'undefined') { 323 $('.wrap-main-product-gallery .woocommerce-product-gallery__image a').trigger('zoom.destroy'); 324 if ($(window).width() > 768) { 325 $('.wrap-main-product-gallery .woocommerce-product-gallery__image a').zoom(); 326 } 327 } 328 } 329 //Product carousel 330 function zoo_products_carousel() { 331 $('.products.carousel').each(function () { 332 let data = $(this).data('zoo-config'); 333 if (!!data) { 334 let cols = data.cols; 335 $(this).slick({ 336 slidesToShow: cols, 337 slidesToScroll: 1, 338 rows: 0, 339 rtl: $('body.rtl')[0] ? true : false, 340 swipe: true, 341 prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 342 nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>', 343 responsive: [ 344 { 345 breakpoint: 768, 346 settings: { 347 slidesToShow: cols > 3 ? 3 : cols 348 } 349 }, 350 { 351 breakpoint: 576, 352 settings: { 353 slidesToShow: cols > 2 ? 2 : cols 354 } 355 } 356 , 357 { 358 breakpoint: 480, 359 settings: { 360 slidesToShow:1 361 } 362 } 363 ] 364 }) 365 } 366 }) 367 } 368 369 //Product tabs 370 function zoo_product_tabs_block() { 371 $('.zoo-product-data-tabs .accordion-active .wc-tab').show(); 372 $(document).on('click', '.tabs li a', function () { 373 $('.zoo-group-accordion.accordion-active').removeClass('accordion-active'); 374 $($(this).attr('href')).closest('.zoo-group-accordion').addClass('accordion-active'); 375 }); 376 $(document).on('click', '.zoo-group-accordion .tab-heading', function () { 377 let tab_is_activated = $(this).closest('.accordion-active')[0]; 378 $('.zoo-product-data-tabs .accordion-active .wc-tab').slideUp(); 379 $('.zoo-product-data-tabs .accordion-active').removeClass('accordion-active'); 380 if (!tab_is_activated) { 381 $(this).closest('.zoo-group-accordion').toggleClass('accordion-active'); 382 $(this).next('.wc-tab').slideToggle(); 383 384 if ($('.zoo-product-data-tabs .tabs.wc-tabs')[0]) { 385 let id = $(this).next('.wc-tab').attr('id'); 386 $('.zoo-product-data-tabs .tabs.wc-tabs .active').removeClass('active'); 387 $('.zoo-product-data-tabs .tabs.wc-tabs a[href="#' + id + '"]').parent().addClass('active'); 388 } 389 } 390 }); 391 } 392 393 //Gallery js 394 function zoo_product_gallery() { 395 //Product gallery slider 396 if (typeof $.fn.slick != 'undefined') { 397 let thumb_num = $('.zoo-product-gallery.images').data('columns'); 398 var window_width = ''; 399 $(window).resize(function () { 400 if (window_width != $(window).width()) { 401 if ($('.zoo-product-gallery:not(.none-slider) .wrap-main-product-gallery:not(.slick-slider)')[0]) { 402 $('.zoo-product-gallery:not(.none-slider) .wrap-main-product-gallery').slick({ 403 slidesToShow: 1, 404 slidesToScroll: 1, 405 rows: 0, 406 rtl: $('body.rtl')[0] ? true : false, 407 swipe: true, 408 asNavFor: $('.wrap-list-thumbnail')[0] ? '.zoo-product-gallery .wrap-l
408ist-thumbnail' : '', 409 prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 410 nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>', 411 }); 412 } 413 $('.zoo-product-gallery:not(.none-slider) .wrap-list-thumbnail.slick-slider').slick('unslick'); 414 415 if ($(window).width() > 576) { 416 $('.zoo-product-gallery:not(.none-slider) .wrap-list-thumbnail:not(.slick-slider)').slick({ 417 slidesToShow: thumb_num, 418 rows: 0, 419 slidesToScroll: 1, 420 vertical: $('.zoo-product-gallery.vertical-gallery')[0] ? true : false, 421 verticalSwiping: $('.zoo-product-gallery.vertical-gallery')[0] ? true : false, 422 focusOnSelect: true, 423 rtl: $('body.rtl')[0] ? true : false, 424 asNavFor: '.zoo-product-gallery .wrap-main-product-gallery', 425 prevArrow: $('.zoo-product-gallery.vertical-gallery')[0] ? '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-up"></i></span>' : '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 426 nextArrow: $('.zoo-product-gallery.vertical-gallery')[0] ? '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-down"></i></span>' : '<span class="zoo-carousel-btn next-item"><i class="zoo-icon-arrow-right"></i></span>', 427 }); 428 } else { 429 $('.zoo-product-gallery:not(.none-slider) .wrap-list-thumbnail:not(.slick-slider)').slick({ 430 slidesToShow: thumb_num, 431 rows: 0, 432 slidesToScroll: 1, 433 focusOnSelect: true, 434 rtl: $('body.rtl')[0] ? true : false, 435 asNavFor: '.zoo-product-gallery .wrap-main-product-gallery', 436 prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 437 nextArrow: '<span class="zoo-carousel-btn next-item"><i class="zoo-icon-arrow-right"></i></span>', 438 }); 439 } 440 441 if ($(window).width() > 992) { 442 if ($('.zoo-product-gallery.none-slider .wrap-main-product-gallery.slick-initialized')[0]) { 443 $('.zoo-product-gallery.none-slider .wrap-main-product-gallery.slick-initialized').slick('unslick'); 444 $('.zoo-product-gallery.none-slider .wrap-list-thumbnail.slick-initialized').slick('unslick'); 445 } 446 } else { 447 $('.zoo-product-gallery.none-slider .wrap-main-product-gallery:not(.slick-slider)').slick({ 448 slidesToShow: 1, 449 slidesToScroll: 1, 450 rows: 0, 451 rtl: $('body.rtl')[0] ? true : false, 452 swipe: true, 453 asNavFor: $('.wrap-list-thumbnail')[0] ? '.zoo-product-gallery.none-slider .wrap-list-thumbnail' : '', 454 prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 455 nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>', 456 }); 457 $('.zoo-product-gallery.none-slider .wrap-list-thumbnail:not(.slick-slider)').slick({ 458 slidesToShow: thumb_num, 459 rows: 0, 460 slidesToScroll: 1, 461 focusOnSelect: true, 462 rtl: $('body.rtl')[0] ? true : false, 463 asNavFor: '.zoo-product-gallery.none-slider .wrap-main-product-gallery', 464 prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>', 465 nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>', 466 }); 467 } 468 469 window_width = $(window).width(); 470 } 471 }).resize();
472 $(document).on('click', '.wrap-list-thumbnail a', function (e) { 473 e.preventDefault(); 474 }); 475 $('.zoo-product-gallery.slider-gallery .wrap-main-product-gallery').slick('slickSetOption', 'slidesToShow', thumb_num, false); 476 let responsive = [{breakpoint: 768, settings: {slidesToShow: 2}}, { 477 breakpoint: 576, 478 settings: {slidesToShow: 1} 479 }]; 480 $('.zoo-product-gallery.slider-gallery .wrap-main-product-gallery').slick('slickSetOption', 'responsive', responsive, true); 481 } 482 //Gallery Zoom 483 var w_width = ''; 484 $(window).resize(function () { 485 if (w_width != $(window).width()) { 486 if (typeof $.fn.zoom != 'undefined') { 487 $('.wrap-main-product-gallery .woocommerce-product-gallery__image a').trigger('zoom.destroy'); 488 if ($(window).width() > 768) { 489 $('.wrap-main-product-gallery .woocommerce-product-gallery__image a').zoom(); 490 } 491 } 492 w_width = $(window).width(); 493 } 494 }).resize(); 495 } 496 497 //Gallery light box 498 function zoo_gallery_light_box() { 499 $(document).on('click', '.wrap-main-product-gallery .woocommerce-product-gallery__image a', function (e) { 500 e.preventDefault(); 501 if (typeof PhotoSwipe != 'undefined') { 502 var pswpElement = $('.pswp')[0], 503 items = $(this).zooGetGalleryItems(), 504 c_index = $(this).parent().index(); 505 if ($(this).closest('.slick-slide')[0]) { 506 if ($('.carousel.zoo-single-product')[0]) { 507 var total_sl_active = $('.wrap-single-image .slick-active').length; 508 if (total_sl_active == 0) { 509 c_index = $(this).closest('.slick-slide').index(); 510 } 511 else { 512 c_index = $(this).closest('.slick-slide').index() - total_sl_active - 1; 513 } 514 } 515 else { 516 c_index = $(this).closest('.slick-slide').index() - 1; 517 } 518 519 } 520 var options = { 521 index: c_index, 522 shareEl: false, 523 closeOnScroll: false, 524 history: false, 525 hideAnimationDuration: 0, 526 showAnimationDuration: 0 527 }; 528 // Initializes and opens PhotoSwipe. 529 var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 530 photoswipe.init(); 531 } 532 }); 533 } 534 535 //Alternative Image 536 function zoo_alternate_image() { 537 $(document).on('hover', '.products .product', function () { 538 let $this = $(this).find('.sec-img'); 539 if (!!$this.data('src') && $this.attr('src') != $this.data('src')) { 540 $this.attr('src', $this.data('src')); 541 $this.attr('srcset', $this.data('srcset')); 542 } 543 }); 544 } 545 546 //Toggle display my aocount form 547 function zoo_toggle_myacount_form() { 548 $(document).on('click', '.toggle-register-form, .toggle-form-button.toggle-register', function (e) { 549 e.preventDefault(); 550 $('#customer_login .u-column2').slideDown(); 551 $('#customer_login .u-column1').slideUp(); 552 $('.toggle-form-block-register').slideUp(); 553 $('.toggle-form-block-login').slideDown(); 554 }); 555 $(document).on('click', '.toggle-login-form, .toggle-form-button.toggle-login', function (e) { 556 e.preventDefault(); 557 $('#customer_login .u-column2').slideUp(); 558 $('#customer_login .u-column1').slideDown(); 559 $('.toggle-form-block-register').slideDown(); 560 $('.toggle-form-block-login').slideUp(); 561 }); 562 563 } 564 565 //Coupon code for cart page 566 function zoo_add_coupon_cart() { 567 $(document).on('click', '.content-toggle-block .button.apply-coupon', function () { 568 $('.woocommerce-cart-form #coupon_code').attr('value', $('.content-toggle-block input[name*=coupon_code]').val()); 569 $('.woocommerce-cart-form .button[name*=apply_coupon]').trigger('click'); 570 }); 571 } 572 573 //Stick add to cart button 574 function zoo_sticky_add_to_cart() { 575 $(window).load(function () { 576 if ($('.zoo-sticky-add-to-cart')[0] && $('.summary form.cart')[0]) { 577 jQuery(window).on("scroll", function () { 578 if ($(window).scrollTop() > $('.summary form.cart').height() + $('.summary form.cart').offset().top && $(window).scrollTop() + $(window).height() < $('footer.site-footer').offset().top) { 579 $('.zoo-sticky-add-to-cart:not(.active)').addClass('active') 580 } else { 581 $('.zoo-sticky-add-to-cart.active').removeClass('active') 582 } 583 }); 584 $(document).on('click', '.zoo-sticky-add-to-cart .button-sticky-add-to-cart', function (e) { 585 e.preventDefault(); 586 $('html, body').animate({
587 scrollTop: $('.summary').offset().top 588 }, 700); 589 }); 590 } 591 }); 592 } 593 594 //360 product view 595 function zoo_product_360_view() { 596 if ($('.product-image-360-view')[0]) { 597 let $wrap = $('.product-image-360-view .zoo-wrap-img-360-view'); 598 let width = $wrap.find('.zoo-wrap-content-view').width(); 599 let height = $wrap.find('.zoo-wrap-content-view').height(); 600 601 if (parseInt(width) > $wrap.find('.zoo-wrap-content-view').width()) { 602 let res = parseInt(width / height); 603 width = $(this).find('.zoo-wrap-img-360-view').width(); 604 height = parseInt(parseInt(width) / res); 605 } 606 $(document).on('click', '.product-360-view-control', function () { 607 $('.product-image-360-view, .product-extended-button').toggleClass('active'); 608 }); 609 $(document).on('click', '.mask-product-360-view', function () { 610 $('.product-image-360-view, .product-extended-button').removeClass('active'); 611 }); 612 $wrap.find('.zoo-wrap-content-view').spritespin({ 613 // path to the source images. 614 source: $('.product-image-360-view').attr('data-zoo-config').split(','), 615 width: width, // width in pixels of the window/frame 616 height: height, // height in pixels of the window/frame 617 animate: false 618 }); 619 620 var api = $wrap.find('.zoo-wrap-content-view').spritespin("api"); 621 // call function next/previous frame when click to button next/previous 622 $wrap.find('.zoo-control-view:not(.zoo-center)').on('click', function () { 623 if ($wrap.hasClass('zoo-prev-item')) { 624 api.prevFrame(); 625 } else { 626 api.nextFrame(); 627 } 628 }); 629 } 630 } 631 632 function zoo_countdown_end_day() { 633 if ($('.zoo-get-order-notice .end-of-day')[0]) { 634 let d = new Date(), 635 duration = 60 * (60 - d.getMinutes()); 636 let timer = duration, minutes; 637 let hours = (24 - d.getHours()); 638 hours = hours < 10 ? '0' + hours : hours; 639 let label_h = $('.zoo-get-order-notice .end-of-day').data('hours'); 640 let label_m = $('.zoo-get-order-notice .end-of-day').data('minutes'); 641 setInterval(function () { 642 minutes = parseInt(timer / 60, 10); 643 minutes = minutes < 10 ? "0" + minutes : minutes; 644 $('.zoo-get-order-notice .end-of-day').text(hours + ' ' + label_h + ' ' + minutes + ' ' + label_m); 645 if (--timer < 0) { 646 timer = duration; 647 } 648 }, 1000); 649 } 650 } 651 652 //Extend cart info lightbox 653 function zoo_extend_cart_info() { 654 if ($('.summary>.product_title').text() != '') { 655 $('.content-popup-page .wpcf7-hidden[name="product"]').val($('.summary>.product_title').text()); 656 } 657 658 $(document).on('click', '.zoo-extend-cart-info-item >a', function (e) { 659 e.preventDefault(); 660 $('.wrap-content-popup-page').addClass('active'); 661 $('.close-zoo-extend-cart-info').addClass('active'); 662 $('.' + $(this).data('target')).addClass('active'); 663 }); 664 $(document).on('click', '.close-zoo-extend-cart-info, .wrap-content-popup-page .close-popup-page', function () { 665 $('.wrap-content-popup-page.active').removeClass('active'); 666 $('.close-zoo-extend-cart-info.active').removeClass('active'); 667 $('.content-popup-page.active').removeClass('active'); 668 }); 669 } 670 671 jQuery.fn.extend({ 672 zoo_WooSmartLayout: function (default_cols) { 673 if (jQuery(this)[0]) { 674 jQuery(this).each(function () { 675 if (!!$(this).data('zoo-config')) { 676 //Prepare all default config; 677 var $this = $(this); 678 var data, cols, table_cols, mobile_cols, active_featured, wrap_width, res, product_width, img_w; 679 data = $this.data('zoo-config'); 680 cols = parseInt(data.cols); 681 active_featured = parseInt(!!data.highlight_featured ? data.highlight_featured : 0); 682 if (!!cols && !!active_featured) { 683 wrap_width = Math.floor($this.width()); 684 if (!!default_cols) { 685 cols = default_cols; 686 } else { 687 table_cols = parseInt(!!data.tablet ? data.tablet : 2); 688 mobile_cols = parseInt(!!data.mobile ? data.mobile : 1); 689 //*End Prepare all default config; 690 //Reset column layout and control grid follow screen size 691 if ($(window).width() <= 577) { 692 cols = mobile_cols; 693 } else if ($(window).width() < 993 && $(window).width() > 577) { 694 cols = table_cols; 695 } 696 } 697 //* End Reset column layout and control grid follow screen size 698 product_width = Math.floor(wrap_width / cols
698); 699 700 if (cols > 1) { 701 $this.find('.product.featured').outerWidth(product_width * 2); 702 $this.find('.product:not(.featured)').outerWidth(product_width); 703 } 704 setTimeout(function () { 705 if (cols > 1) { 706 var height = 0; 707 $this.find('.product:not(.featured)').each(function () { 708 if ($(this).outerHeight(true) > height) { 709 height = $(this).outerHeight(true); 710 } 711 }); 712 $this.find('.product:not(.featured)').outerHeight(height); 713 if ($(window).width() > 768) { 714 $this.find('.product.featured').outerHeight(height * 2); 715 } else { 716 $this.find('.product.featured').outerHeight('auto'); 717 } 718 $this.isotope({ 719 layoutMode: 'masonry', 720 itemSelector: '.product', 721 percentPosition: true, 722 masonry: { 723 columnWidth: '.product:not(.featured)' 724 } 725 }); 726 } 727 }, 700); 728 } 729 } 730 }); 731 } 732 }, 733 zoo_toggleBlock: function () { 734 $(this).next('.content-toggle-block').slideToggle(); 735 }, 736 //Product Qty 737 zoo_CartQuantity: function (target) { 738 if ($(this)[0]) { 739 $(this).on("click", target, function () { 740 let qty = jQuery(this).parents('.quantity').find('input.qty'); 741 let current_qty=qty.val(); 742 current_qty=!!current_qty?current_qty:0; 743 let val = parseInt(current_qty); 744 if ($(this).hasClass('increase')) { 745 qty.val(val + 1); 746 } 747 else { 748 if ($(this).closest('.woocommerce-grouped-product-list')[0]) { 749 if (val > 0) { 750 qty.val(val - 1); 751 } 752 } else { 753 if (val > 1) { 754 qty.val(val - 1); 755 } 756 } 757 } 758 qty.trigger('change'); 759 }); 760 } 761 }, 762 //Push product images to list 763 zooGetGalleryItems: function () { 764 var $slides, items = []; 765 if ($('.zoo-product-gallery.none-slider')[0]) { 766 $slides = this.parents('.wrap-main-product-gallery').find('.woocommerce-product-gallery__image'); 767 } 768 else { 769 $slides = this.parents('.wrap-main-product-gallery').find('.slick-slide:not(.slick-cloned)'); 770 } 771 if ($slides.length > 0) { 772 $slides.each(function (i, el) { 773 var img = $(el).find('img'), 774 large_image_src = img.attr('data-large_image'), 775 large_image_w = img.attr('data-large_image_width'), 776 large_image_h = img.attr('data-large_image_height'), 777 item = { 778 src: large_image_src, 779 w: large_image_w, 780 h: large_image_h, 781 title: img.attr('title') 782 }; 783 items.push(item); 784 }); 785 } 786 return items; 787 } 788 }); 789}) 790(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.