Created
December 6, 2019 09:11
-
-
Save Longkt/ce920d5b458fd292283d77bffcf65c2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(e){var t=function(t,i){this.$target=e(t);var o=(i=e.extend({},Customify_Pro_JS.wc_product_gallery,i)).enable_slider;i.slider=e.extend({},Customify_Pro_JS.wc_product_gallery.slider,i.slider),i.thumbs=e.extend({},Customify_Pro_JS.wc_product_gallery.thumbs,i.thumbs);var r=e(".woocommerce-product-gallery__wrapper",this.$target),c=".woocommerce-product-gallery__image",n=e(c,r);n.length||(n=e(c=".wc-gallery-item",r));var a=r.clone(),l=i.show_thumbs;if(n.length<=1&&(l=!1),o){var s=i.vertical;l&&(a.removeClass("woocommerce-product-gallery__wrapper").addClass("wc-nav-thumbs"),e(".woocommerce-product-gallery__image img",a).unwrap(),a.insertAfter(r),s&&this.$target.addClass("wc-gallery-vertical")),s||this.$target.addClass("wc-gallery-horizontal")}var u=function(t){if(!i.enable_zoom)return!1;var o=r.width(),c=!1;e(t).each(function(t,i){if(e(i).find("img").data("large_image_width")>o)return c=!0,!1}),c&&(zoom_options={touch:!1},"ontouchstart"in document.documentElement&&(zoom_options.on="click"),t.trigger("zoom.destroy"),t.zoom(zoom_options))},d=function(t,i){t.preventDefault();var o=e(".pswp")[0],c=function(){var t=n,i=[];return t.length>0&&t.each(function(t,o){var r=e(o).find("img");if(r.length){var c={src:r.attr("data-large_image"),w:r.attr("data-large_image_width"),h:r.attr("data-large_image_height"),title:r.attr("data-caption")?r.attr("data-caption"):r.attr("title")};i.push(c)}}),i}();void 0===i&&(i=r.slick("slickCurrentSlide"));var a=e.extend({index:i},wc_single_product_params?wc_single_product_params.photoswipe_options:{});new PhotoSwipe(o,PhotoSwipeUI_Default,c,a).init()},_=function(){if(!i.enable_lightbox)return!1;o?n.length>0?(r.prepend('<a href="#" class="woocommerce-product-gallery__trigger"><i class="wcicon-expand"></i></a>'),r.on("click",".woocommerce-product-gallery__trigger",d),r.on("click",".slick-slide",function(e){d(e)})):r.on("click",".woocommerce-product-gallery__image a",d):r.on("click",c,function(t){d(t,e(this).index())})};try{r.length&&r.slick("unslick"),a.length&&a.slick("unslick")}catch(e){}var g=e.extend({asNavFor:r,vertical:!1,autoplay:!0,autoplaySpeed:2e3},i.thumbs);if(o){function m(t){if(i.auto_resize&&a.length){a.removeAttr("style");g.slidesToShow>n.length?n.length:g.slidesToShow;var o=80*g.slidesToShow;t?(o>=r.height()-20&&(o=""),a.css("min-height",o)):(o>=e(window).width()-20&&(o=""),a.css("width",o))}}r.bind("afterChange init",function(e,t,i,o){}),r.bind("init",function(t){e(document.body).trigger("wc_single_slider_init_done"),e(".slick-list .slick-slide",r).each(function(){u(e(this).find(".woocommerce-product-gallery__image"))}),_()}),m(s),a.bind("init reInit breakpoint afterChange",function(e){}),n.length&&r.slick(e.extend({asNavFor:!!l&&a},i.slider)),l&&a.slick(g);var h=this;if(l&&s){var w=function(){a.css("width",""),a.css("max-width",""),e(window).width()<=568?(h.$target.removeClass("wc-gallery-vertical"),a.slick("unslick"),m(!1),a.slick(e.extend(g,{vertical:!1}))):(h.$target.addClass("wc-gallery-vertical"),a.slick("unslick"),m(s),a.slick(e.extend(g,{vertical:!0})))};e(window).resize(function(){w()}),w()}}else e(c,r).each(function(){u(e(this))}),_();e(document).on("after_auto_render_css",function(e,t,i){r.find(".slick-list").height("auto"),o&&setTimeout(function(){r.slick("resize"),l&&a.slick("resize")},250)}),e(window).resize(function(){o&&setTimeout(function(){r.slick("resize"),l&&a.slick("resize")},250)})};e.fn.customify_wc_product_gallery=function(e){return new t(this,e),this},void 0!==Customify_Pro_JS.wc_product_gallery&&(e(".woocommerce-product-gallery").each(function(){e(this).customify_wc_product_gallery()}),e(document).on("customify_quickview_product_init",function(t,i){setTimeout(function(){e(".woocommerce-product-gallery",i).each(function(){Customify_Pro_JS.wc_product_gallery_quick_view.enable_slider=!0,e(this).customify_wc_product_gallery(Customify_Pro_JS.wc_product_gallery_quick_view)})},500)}))}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment