woocommerce/assets/js/frontend/single-product.min.js

1 line
5.2 KiB
JavaScript
Raw Normal View History

2017-04-14 16:34:05 +00:00
jQuery(function(e){if("undefined"==typeof wc_single_product_params)return!1;e("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){e(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var t=window.location.hash,i=window.location.href,o=e(this).find(".wc-tabs, ul.tabs").first();t.toLowerCase().indexOf("comment-")>=0||"#reviews"===t||"#tab-reviews"===t?o.find("li.reviews_tab a").click():i.indexOf("comment-page-")>0||i.indexOf("cpage=")>0?o.find("li.reviews_tab a").click():o.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(t){t.preventDefault();var i=e(this),o=i.closest(".wc-tabs-wrapper, .woocommerce-tabs"),s=o.find(".wc-tabs, ul.tabs");s.find("li").removeClass("active"),o.find(".wc-tab, .panel:not(.panel .panel)").hide(),i.closest("li").addClass("active"),o.find(i.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return e(".reviews_tab a").click(),!0}).on("init","#rating",function(){e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var t=e(this),i=e(this).closest("#respond").find("#rating"),o=e(this).closest(".stars");return i.val(t.text()),t.siblings("a").removeClass("active"),t.addClass("active"),o.addClass("selected"),!1}).on("click","#respond #submit",function(){var t=e(this).closest("#respond").find("#rating"),i=t.val();return t.length>0&&!i&&"yes"===wc_single_product_params.review_rating_required?(window.alert(wc_single_product_params.i18n_required_rating_text),!1):void 0}),e(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var t=function(t,i){return this.$target=t,this.$images=e(".woocommerce-product-gallery__image",t),0===this.$images.length?void this.$target.css("opacity",1):(t.data("product_gallery",this),this.flexslider_enabled=e.isFunction(e.fn.flexslider)&&wc_single_product_params.flexslider_enabled,this.zoom_enabled=e.isFunction(e.fn.zoom)&&wc_single_product_params.zoom_enabled,this.photoswipe_enabled="undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled,i&&(this.flexslider_enabled=!1===i.flexslider_enabled?!1:this.flexslider_enabled,this.zoom_enabled=!1===i.zoom_enabled?!1:this.zoom_enabled,this.photoswipe_enabled=!1===i.photoswipe_enabled?!1:this.photoswipe_enabled),this.initFlexslider=this.initFlexslider.bind(this),this.initZoom=this.initZoom.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(),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)),void(this.photoswipe_enabled&&this.initPhotoswipe()))};t.prototype.initFlexslider=function(){var t=this.$images,i=this.$target;i.flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:wc_single_product_params.flexslider.animationLoop,start:function(){i.css("opacity",1);var o=0;t.each(function(){var t=e(this).height();t>o&&(o=t)}),t.each(function(){e(this).css("min-height",o)})}})},t.prototype.initZoom=function(){var t=this.$images,i=this.$target.width(),o=!1;if(this.flexslider_enabled||(t=t.first()),e(t).each(function(t,s){var a=e(s).find("img");return a.data("large_image_width")>i?(o=!0,!1):void 0}),o){var s={touch:!1};"ontouchstart"in window&&(s.on="click"),t.tri