1/* global woodmart_settings */ 2(function($) { 3 $.each([ 4 'frontend/element_ready/wd_products.default', 5 'frontend/element_ready/wd_products_tabs.default' 6 ], function(index, value) { 7 woodmartThemeModule.wdElementorAddAction(value, function() { 8 woodmartThemeModule.quickShop(); 9 }); 10 }); 11 12 woodmartThemeModule.quickShop = function() { 13 if ('no' === woodmart_settings.quick_shop) { 14 return; 15 } 16 17 var btnSelector = '.product-grid-item.product-type-variable .add_to_cart_button'; 18 19 woodmartThemeModule.$document.on('click', btnSelector, function(e) { 20 e.preventDefault(); 21 22 var $this = $(this), 23 $product = $this.parents('.product').first(), 24 $content = $product.find('.wd-quick-shop'), 25 id = $product.data('id'), 26 loadingClass = 'btn-loading'; 27 28 if ($this.hasClass(loadingClass)) { 29 return; 30 } 31 32 // Simply show quick shop form if it is already loaded with AJAX previously 33 if ($product.hasClass('quick-shop-loaded')) { 34 $product.addClass('quick-shop-shown'); 35 woodmartThemeModule.$body.trigger('woodmart-quick-view-displayed'); 36 return; 37 } 38 39 $this.addClass(loadingClass); 40 $product.addClass('wd-loading-quick-shop'); 41 42 $.ajax({ 43 url : woodmart_settings.ajaxurl, 44 data : { 45 action: 'woodmart_quick_shop', 46 id : id 47 }, 48 method : 'get', 49 success : function(data) { 50 woodmartThemeModule.removeDuplicatedStylesFromHTML(data, function(html) { 51 $content.append(html); 52 53 initVariationForm($product); 54 woodmartThemeModule.$document.trigger('wdQuickShopSuccess'); 55 56 $this.removeClass(loadingClass); 57 $product.removeClass('wd-loading-quick-shop'); 58 $product.addClass('quick-shop-shown quick-shop-loaded'); 59 woodmartThemeModule.$body.trigger('woodmart-quick-view-displayed'); 60 }); 61 }, 62 }); 63 }) 64 .on('click', '.quick-shop-close', function(e) { 65 e.preventDefault(); 66 67 var $this = $(this), 68 $product = $this.parents('.product'); 69 70 $product.removeClass('quick-shop-shown'); 71 }); 72 73 woodmartThemeModule.$body.on('added_to_cart', function() { 74 $('.product').removeClass('quick-shop-shown'); 75 }); 76 77 function initVariationForm($product) { 78 $product.find('.variations_form').wc_variation_form().find('.variations select:eq(0)').trigger('change'); 79 $product.find('.variations_form').trigger('wc_variation_form'); 80 } 81 }; 82 83 $(document).ready(function() { 84 woodmartThemeModule.quickShop(); 85 }); 86})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.