1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
$(document).on('click', '.page-id-1926 .product .btn-quick-view', function (e) {
e.preventDefault();
$('.zoo-mask-close').addClass('loading active mask-quick-view');
var load_product_id = $(this).attr('data-productid');
var data = {action: 'zoo_quick_view', product_id: load_product_id};
$(this).parent().addClass('loading');
var $this = $(this);
$.ajax({
url: ajaxurl,
data: data,
type: "POST",
success: function (response) {
$('body').append(response);
$this.parent().removeClass('loading');
// Variation Form
var form_variation = $(document).find('#zoo-quickview-lb .variations_form');
form_variation.wc_variation_form();
form_variation.trigger('check_variations');
zoo_quick_view_gal();
//Sync button compare/wishlist quickview load.
if ($('#zoo-quickview-lb .zoo-wishlist-button')[0]) {
if (window.zooWishlist.model.exists($('#zoo-quickview-lb .zoo-wishlist-button').data('id'))) {
window.zooWishlist.view.renderBrowseButton($('#zoo-quickview-lb .zoo-wishlist-button'));
}
}
if ($('#zoo-quickview-lb .zoo-compare-button')[0]) {
if (window.zooProductsCompare.model.exists($('#zoo-quickview-lb .zoo-compare-button').data('id'))) {
window.zooProductsCompare.view.renderBrowseButton($('#zoo-quickview-lb .zoo-compare-button'));
}
}
$('.lazy-img:not(.loaded)').zoo_lazyImg();
setTimeout(function () {
$('#zoo-quickview-lb').css('opacity', '1');
$('#zoo-quickview-lb').css('top', '50%');
}, 100);
}
});
});
$(document).on('click', '.close-quickview, .zoo-mask-close.mask-quick-view', function (e) {
e.preventDefault();
zoo_close_quick_view();
});
//Close Quickview when click to compare/wish list.
$(document).on('zoo_browse_wishlist', function () {
zoo_close_quick_view();
});
$(document).on('zoo_browse_compare', function () {
zoo_close_quick_view();
});
//Swatches gallery for quick view
$(document).on('cleverswatch_update_gallery', function (event, response) {
if ($('#zoo-quickview-lb')[0])
zoo_quick_view_gal();
});
//Close Quickview;
function zoo_close_quick_view() {
$('.zoo-mask-close').removeClass('loading active mask-quick-view');
$('#zoo-quickview-lb').css({'top': 'calc(50% + 150px)', 'opacity': '0'});
setTimeout(function () {
$('#zoo-quickview-lb').remove();
}, 500)
}
//Quickview gallery
function zoo_quick_view_gal() {
if ($('.zoo-product-quick-view .wrap-main-product-gallery')[0]) {
let thumb_num = $('.zoo-product-gallery.images').data('columns');
if (typeof $.fn.slick != 'undefined') {
$('.zoo-product-quick-view .wrap-main-product-gallery').slick({
slidesToShow: 1,
rows: 0,
slidesToScroll: 1,
focusOnSelect: true,
rtl: $('body.rtl')[0] ? true : false,
asNavFor: $('.wrap-list-thumbnail')[0] ? '.zoo-product-quick-view .wrap-list-thumbnail' : '',
prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>',
nextArrow: '<span class="zoo-carousel-btn next-item"><i class="zoo-icon-arrow-right"></i></span>',
});
$('.zoo-product-quick-view .wrap-list-thumbnail').slick({
slidesToShow: thumb_num,
rows: 0,
slidesToScroll: 1,
focusOnSelect: true,
rtl: $('body.rtl')[0] ? true : false,
asNavFor: '.zoo-product-quick-view .wrap-main-product-gallery',
prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>',
nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>',
});
}
}
}
/* End Quick view js */
//Normally Ajax url, for multi language
function normally_url_cart(url, parameterName, parameterValue, atStart) {
var replaceDuplicates = true;
var urlhash = '';
var cl = url.length;
if (url.indexOf('#') > 0) {
cl = url.indexOf('#');
urlhash = url.substring(url.indexOf('#'), url.length);
}
var sourceUrl = url.substring(0, cl);
var urlParts = sourceUrl.split("?");
var newQueryString = "";
if (urlParts.length > 1) {
var parameters = urlParts[1].split("&");
for (var i = 0; (i < parameters.length); i++) {
var parameterParts = parameters[i].split("=");
if (!(replaceDuplicates && parameterParts[0] == parameterName)) {
if (newQueryString == "")
newQueryString = "?";
else
newQueryString += "&";
newQueryString += parameterParts[0] + "=" + (parameterParts[1] ? parameterParts[1] : '');
}
}
}
if (newQueryString == "")
newQueryString = "?";
if (atStart) {
newQueryString = '?' + parameterName + "=" + parameterValue + (newQueryString.length > 1 ? '&' + newQueryString.substring(1) : '');
} else {
if (newQueryString !== "" && newQueryString != '?')
newQueryString += "&";
newQueryString += parameterName + "=" + (parameterValue ? parameterValue : '');
}
return urlParts[0] + newQueryString + urlhash;
} |
Partager