PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / assets / js / modules / variation-gallery.js

variation-gallery.js in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at assets/js/modules/variation-gallery.js

1 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e,r,t,i,a,n,o,s,l;e=jQuery,r=function(){var e=(window.RTSB||{}).cache,r=(null==e?void 0:e.create("variationGallery"))||null;return{name:"variationGallery",version:"1.0.0",init:function(){return this.run(),r.set("initialized",!0),this},refresh:function(){this.run()},run:function(){t(),s()},destroy:function(){r.clear()}}},t=function(){e(document).on("wc_variation_form",".variations_form",function(e){i(e.currentTarget)})},i=function(r){var t=e(r),i=t.closest(".product"),n=!!t.length,o=i.find(".rtsb-carousel-slider"),s=i.find(".product-vg-gallery"),l=i.find(".rtsb-vs-thumb-slider"),d=i.find(".rtsb-vg-main-slider-wrapper"),g=[],c=t.data("product_id"),v=l.data("options")||{},f=parseInt((null==v?void 0:v.slidesPerView)||4,10),u=i.find(".rtsb-vg-image-grid-view"),p=s.length<1&&u.length>0,m=function(e){t.trigger("rtsb_vg_before_gallery_image_loaded");var r=e.length>1;if(p){var i=wp.template("vg-grid-view-template");u.html(i(e))}else{var a=wp.template("vg-slider-template");if(s.find(".swiper-wrapper").html(a(e)),r){s.find(".swiper-nav").removeClass("rtsb-vg-swiper-nav-hide");var n=wp.template("vg-thumbnail-template");l.find(".swiper-wrapper").html(n(e))}else l.find(".swiper-wrapper").html(""),s.find(".swiper-nav").addClass("rtsb-vg-swiper-nav-hide");r&&e.length>f?l.find(".swiper-nav").removeClass("rtsb-vg-swiper-nav-hide"):l.find(".swiper-nav").addClass("rtsb-vg-swiper-nav-hide")}t.trigger("rtsb_vg_after_gallery_image_loaded")};n&&!g.length&&wp.ajax.send("rtsb_vg_get_default_gallery_images",{data:{product_id:c,__rtsb_wpnonce:rtsbVgParams.__rtsb_wpnonce},success:function(e){g=e,t.trigger("rtsb_vg_default_gallery_image_loaded")},error:function(){g=[],t.trigger("rtsb_vg_default_gallery_image_loaded")}}),t.on("click.wc-variation-form",".reset_variations",function(e){m(g)}),t.on("show_variation.rtsv_vg",function(e,r){m(r.variation_gallery_images)}),t.on("rtsb_vg_before_gallery_image_loaded",function(){d.hasClass("rtsb-content-loading")||d.addClass("rtsb-content-loading")}),t.on("rtsb_vg_after_gallery_image_loaded",function(){var e,r=o.rtsb_slider();null===(e=r.swiperSlider)||void 0===e||e.update(),r&&r.swiperSlider&&"function"==typeof r.swiperSlider.slideTo&&setTimeout(function(){r.swiperSlider.slideTo(0,0)},10),a(),setTimeout(function(){d.removeClass("rtsb-content-loading")},400)})},a=function(){var r=e(".rtsb-vg-main-slider-wrapper"),t=r.find(".rtsb-carousel-slider"),i=r.hasClass("rtsb-vg-grid-wrapper"),a=r.data("image-zoom"),n=t.length<1&&i;if(a&&e.fn.zoom){var o,s=(o=n?r.find(".rtsb-vg-grid-item"):t.find(".swiper-slide")).width(),l=e.extend({touch:!0},wc_single_product_params.zoom_options);"ontouchstart"in document.documentElement&&(l.on="click"),e(o).each(function(r,t){var i=e(t).find("img");if(!parseInt(i.data("large_image_width"))>s)return!1;e(t).trigger("zoom.destroy"),e(t).zoom(l)})}},n=function(r){e(r).find("iframe, video").each(function(){var r=e(this).prop("tagName").toLowerCase();if("iframe"===r){var t=e(this).attr("src");e(this).attr("src",t)}"video"===r&&e(this)[0].pause()})},o=function(r){var t;r.preventDefault();var i=e(".rtsb-vg-main-slider-wrapper"),a=i.find(".rtsb-carousel-slider"),o=i.hasClass("rtsb-vg-image-grid-view"),s=a.length<1&&o;if("undefined"==typeof PhotoSwipe)return!1;var l=e(".pswp")[0],d=function(){var r=e(".rtsb-vg-main-slider-wrapper"),t=[],i=r.find(".swiper-slide,.rtsb-vg-grid-item");return i.length>0&&i.each(function(r,i){var a=e(i).find("img, iframe, video"),n=void 0;switch(e(a).prop("tagName").toLowerCase()){case"img":n={src:a.attr("data-large_image"),w:a.attr("data-large_image_width"),h:a.attr("data-large_image_height"),title:a.attr("data-caption")?a.attr("data-caption"):a.attr("title")};break;case"iframe":n={html:'<iframe class="rtwpvg-lightbox-iframe" src="'+a.attr("src")+'" style="width: 100%; height: 100%; margin: 0;padding: 0; background-color: #000000" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'};break;case"video":n={html:'<video class="rtwpvg-lightbox-video" controls controlsList="nodownload" src="'+a.attr("src")+'" style="width: 100%; height: 100%; margin: 0;padding: 0; background-color: #000000"></video>'}}t.push(n)}),t}(),g=null===(t=a.rtsb_slider().swiperSlider)||void 0===t?void 0:t.activeIndex,c=e.extend({index:g},wc_single_product_params.photoswipe_options);if(s){var v=e(r.target).parents(".rtsb-vg-grid-item").find("img").data("src"),f=d.findIndex(function(e){return console.log(e.src,v),e.src===v});c.index=f}var u=new PhotoSwipe(l,PhotoSwipeUI_Default,d,c);u.listen("close",function(){n(l)}),u.listen("afterChange",function(){n(l)}),u.init()},s=function(){var r=e(".product").find(".rtsb-vg-main-slider-wrapper");e(document).off("click",".rtsb-vg-trigger"),e(document).on("click",".rtsb-vg-trigger",function(e){e.preventDefault(),o(e)}),setTimeout(function(){a()},10),setTimeout(function(){r&&r.removeClass("rtsb-content-loading")},400)},(l=function(){if(window.RTSB&&window.RTSB._initialized){var e;null===(e=RTSB.modules.register("variationGallery",r))||void 0===e||e.init()}else{var t=r();window.rtsbVariationGallery=t.run,window.rtsbVariationGallery()}})(),e(document).on("rtsbQv.success",function(){l()})})();