1 line
6.2 KiB
JavaScript
1 line
6.2 KiB
JavaScript
|
jQuery(function(s){if("undefined"==typeof wc_single_product_params)return!1;s("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){s(this).find(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var t=window.location.hash,e=window.location.href,i=s(this).find(".wc-tabs, ul.tabs").first();(0<=t.toLowerCase().indexOf("comment-")||"#reviews"===t||"#tab-reviews"===t||0<e.indexOf("comment-page-")||0<e.indexOf("cpage=")?i.find("li.reviews_tab a"):"#tab-additional_information"===t?i.find("li.additional_information_tab a"):i.find("li:first a")).trigger("click")}).on("click",".wc-tabs li a, ul.tabs li a",function(t){t.preventDefault();var e=s(this),t=e.closest(".wc-tabs-wrapper, .woocommerce-tabs");t.find(".wc-tabs, ul.tabs").find("li").removeClass("active"),t.find(".wc-tab, .panel:not(.panel .panel)").hide(),e.closest("li").addClass("active"),t.find(e.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return s(".reviews_tab a").trigger("click"),!0}).on("init","#rating",function(){s("#rating").hide().before('<p class="stars">\t\t\t\t\t\t<span>\t\t\t\t\t\t\t<a class="star-1" href="#">1</a>\t\t\t\t\t\t\t<a class="star-2" href="#">2</a>\t\t\t\t\t\t\t<a class="star-3" href="#">3</a>\t\t\t\t\t\t\t<a class="star-4" href="#">4</a>\t\t\t\t\t\t\t<a class="star-5" href="#">5</a>\t\t\t\t\t\t</span>\t\t\t\t\t</p>')}).on("click","#respond p.stars a",function(){var t=s(this),e=s(this).closest("#respond").find("#rating"),i=s(this).closest(".stars");return e.val(t.text()),t.siblings("a").removeClass("active"),t.addClass("active"),i.addClass("selected"),!1}).on("click","#respond #submit",function(){var t=s(this).closest("#respond").find("#rating"),e=t.val();if(0<t.length&&!e&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}),s(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var e=function(t,e){this.$target=t,this.$images=s(".woocommerce-product-gallery__image",t),0!==this.$images.length?(t.data("product_gallery",this),this.flexslider_enabled="function"==typeof s.fn.flexslider&&wc_single_product_params.flexslider_enabled,this.zoom_enabled="function"==typeof s.fn.zoom&&wc_single_product_params.zoom_enabled,this.photoswipe_enabled="undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled,e&&(this.flexslider_enabled=!1!==e.flexslider_enabled&&this.flexslider_enabled,this.zoom_enabled=!1!==e.zoom_enabled&&this.zoom_enabled,this.photoswipe_enabled=!1!==e.photoswipe_enabled&&this.photoswipe_enabled),1===this.$images.length&&(this.flexslider_enabled=!1),this.initFlexslider=this.initFlexslider.bind(this),this.initZoom=this.initZoom.bind(this),this.initZoomForTarget=this.initZoomForTarget.bind(this),this.initPhotoswipe=this.initPhotoswipe.bind(this),this.onResetSlidePosition=this.onResetSlidePosition.bind(this),this.getGalleryItems=this.getGalleryItems.bind(this),this.openPhotoswipe=this.openPhotoswipe.bind(this),this.flexslider_enabled?(this.initFlexslider(e.flexslider),t.on("woocommerce_gallery_reset_slide_position",this.onResetSlidePosition)):this.$target.css("opacity",1),this.zoom_enabled&&(this.initZoom(),t.on("woocommerce_gallery_init_zoom",this.initZoom)),this.photoswipe_enabled&&this.initPhotoswipe()):this.$target.css("opacity",1)};e.prototype.initFlexslider=function(t){var e=this.$target,i=this,t=s.extend({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",start:function(){e.css("opacity",1)},after:function(t){i.initZoomForTarget(i.$images.eq(t.currentSlide))}},t);e.flexslider(t),s(".woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0) .wp-post-image").one("load",function(){var i=s(this);i&&setTimeout(function(){var t=i.closest(".woocommerce-product-gallery__image").height(),e=i.closest(".flex-viewport");t&&e&&e.height(t)},100)}).each(function(){this.complete&&s(this).trigger("load")})},e.prototype.initZoom=function(){this.initZoomForTarget(this.$images.first())},e.prototype.initZoomForTarget=function(t){if(!this.zoom_enabl
|