1/******/ (() => { // webpackBootstrap 2let __webpack_exports__ = {}; 3/*global wc_gzd_add_to_cart_variation_params */ 4; 5(function ($, window, document, undefined) { 6 /** 7 * VariationForm class which handles variation forms and attributes. 8 */ 9 var GermanizedVariationForm = function ($form) { 10 var self = this; 11 self.params = wc_gzd_add_to_cart_variation_params; 12 self.$form = $form; 13 self.$wrapper = $form.closest(self.params.wrapper); 14 self.$product = $form.closest('.product'); 15 self.variationData = $form.data('product_variations'); 16 self.$singleVariation = $form.find('.single_variation'); 17 self.$singleVariationWrap = $form.find('.single_variation_wrap'); 18 self.$resetVariations = $form.find('.reset_variations'); 19 self.$button = $form.find('.single_add_to_cart_button'); 20 self.$form.addClass('has-gzd-variation-form'); 21 self.$form.off('.wc-gzd-variation-form'); 22 if (self.$wrapper.length <= 0) { 23 self.$wrapper = self.$product; 24 } 25 self.showOrHideTabs(self); 26 var $priceElement = self.getPriceElement(self); 27 self.isBlockLayout = self.$wrapper.find('.wp-block-woocommerce-product-price').length > 0; 28 self.replacePrice = self.$wrapper.hasClass('bundled_product') ? false : self.params.replace_price; 29 30 /** 31 * Some themes/page builders may not render the from-to price 32 */ 33 if ($priceElement.length <= 0) { 34 self.replacePrice = false; 35 } 36 $form.on('click.wc-gzd-variation-form', '.reset_variations', { 37 GermanizedvariationForm: self 38 }, self.onReset); 39 $form.on('reset_data.wc-gzd-variation-form', { 40 GermanizedvariationForm: self 41 }, self.onReset); 42 $form.on('show_variation.wc-gzd-variation-form', { 43 GermanizedvariationForm: self 44 }, self.onShowVariation); 45 if (self.replacePrice) { 46 self.$form.addClass('wc-gzd-replace-price'); 47 } 48 self.$wrapper.find('' + '.woocommerce-product-attributes-item--food_description, ' + '.woocommerce-product-attributes-item--alcohol_content, ' + '.woocommerce-product-attributes-item--net_filling_quantity, ' + '.woocommerce-product-attributes-item--drained_weight, ' + '.woocommerce-product-attributes-item--food_place_of_origin, ' + '.woocommerce-product-attributes-item--nutri_score, ' + '.woocommerce-product-attributes-item--food_distributor').each(function () { 49 var $tr = $(this); 50 if ($tr.find('.woocommerce-product-attributes-item__value').is(':empty') || $tr.find('.woocommerce-product-attributes-item__value .wc-gzd-additional-info-placeholder').is(':empty')) { 51 $tr.attr('aria-hidden', 'true').addClass('wc-gzd-additional-info-placeholder'); 52 } 53 }); 54 }; 55 GermanizedVariationForm.prototype.showOrHideTabs = function (self, has_product_safety_information = undefined) { 56 /** 57 * Block-based themes have the global post/product classes attached to body instead of the product group wrapper. 58 */ 59 var $defaultWrapper = $('body').hasClass('type-product') ? $('body') : self.$product; 60 var $safetyTab = self.$product.find('.product_safety_tab'); 61 has_product_safety_information = undefined === has_product_safety_information ? $defaultWrapper.hasClass('has-product-safety-information') : has_product_safety_information; 62 if (has_product_safety_information) { 63 if ($safetyTab.is('div')) { 64 $safetyTab.show(); 65 } else { 66 $safetyTab.show().css('display', 'inline-block'); 67 } 68 $safetyTab.addClass('product-safety-tab-visible'); 69 } else { 70 $safetyTab.hide(); 71 $safetyTab.removeClass('product-safety-tab-visible'); 72 } 73 }; 74 GermanizedVariationForm.prototype.getPriceElement = function (self) { 75 var $wrapper = self.$wrapper; 76 77 /** 78 * Ignore the price wrapper inside the variation form to make sure the right 79 * price is being replaced even if the price element is located beneath the form. 80 */ 81 return $wrapper.find(self.params.price_selector + ':not(.price-unit):visible').not('.variations_form .single_variation .price').first(); 82 }; 83 84 /** 85 * Reset all fields. 86 */ 87 GermanizedVariationForm.prototype.onReset = function (event) { 88 var form = event.data.GermanizedvariationForm, 89 $wrapper = form.$wrapper; 90 $wrapper.find('.variation_gzd_modified').each(function () { 91 $(this).wc_gzd_reset_content(); 92 }); 93 $wrapper.find('.variation_gzd_modified').remove(); 94 form.showOrHideTabs(form); 95 event.data.GermanizedvariationForm.$form.trigger('germanized_reset_data'); 96 }; 97 GermanizedVariationForm.prototype.getElementOrBlock = function (self, element, innerElement) { 98 var $wrapper = self.$wrapper; 99 var blockSearch = '.wp-block-woocommerce-gzd-product-' + element + '[data-is-descendent-of-single-product-template]'; 100 if ($wrapper.find(blockSearch).length > 0) { 101 return $wrapper.find(blockSearch + ' ' + innerElement); 102 } else { 103 return $wrapper.find(innerElement); 104 } 105 }; 106 GermanizedVariationForm.prototype.onUpdate = function (event) { 107 setTimeout(function () { 108 if (typeof event.data === 'undefined' || !event.data.hasOwnProperty('GermanizedvariationForm')) { 109 return; 110 } else if (typeof event.data.GermanizedvariationForm === 'undefined') { 111 return; 112 } 113
114 // If the button is diabled (or has disabled class) no variation can be added to the cart - reset has been triggered 115 if (event.data.GermanizedvariationForm.$button.is('[disabled]') || event.data.GermanizedvariationForm.$button.hasClass('disabled')) { 116 event.data.GermanizedvariationForm.onReset(event); 117 } 118 }, 250); 119 }; 120 GermanizedVariationForm.prototype.onShowVariation = function (event, variation, purchasable) { 121 var form = event.data.GermanizedvariationForm, 122 $wrapper = form.$wrapper, 123 hasCustomPrice = variation.price_html && variation.price_html !== '' ? true : false, 124 hasDisplayPrice = variation.display_price && variation.display_price !== '' ? true : false; 125 if (hasCustomPrice && form.replacePrice) { 126 var $priceElement = form.getPriceElement(form); 127 form.$singleVariation.find('.price').hide(); 128 $priceElement.wc_gzd_set_content(variation.price_html); 129 $priceElement.find('.price').contents().unwrap(); 130 } 131 form.getElementOrBlock(form, 'delivery-time', '.delivery-time-info').wc_gzd_
131set_content(variation.delivery_time); 132 form.getElementOrBlock(form, 'defect-description', '.defect-description').wc_gzd_set_content(variation.defect_description); 133 form.getElementOrBlock(form, 'tax-info', '.tax-info').wc_gzd_set_content(hasDisplayPrice ? variation.tax_info : ''); 134 form.getElementOrBlock(form, 'manufacturer', '.manufacturer').wc_gzd_set_content(variation.manufacturer); 135 form.getElementOrBlock(form, 'manufacturer-heading', '.wc-gzd-product-manufacturer-heading').wc_gzd_set_content(variation.manufacturer_heading); 136 form.getElementOrBlock(form, 'product_safety_attachments', '.product-safety-attachments').wc_gzd_set_content(variation.product_safety_attachments); 137 form.getElementOrBlock(form, 'product-safety-attachments-heading', '.wc-gzd-product-safety-attachments-heading').wc_gzd_set_content(variation.product_safety_attachments_heading); 138 form.getElementOrBlock(form, 'safety_instructions', '.safety-instructions').wc_gzd_set_content(variation.safety_instructions); 139 form.getElementOrBlock(form, 'safety-instructions-heading', '.wc-gzd-product-safety-instructions-heading').wc_gzd_set_content(variation.safety_instructions_heading); 140 form.getElementOrBlock(form, 'power_supply', '.wc-gzd-power-supply').wc_gzd_set_content(variation.power_supply); 141 form.getElementOrBlock(form, 'legal_guarantee', '.wc-gzd-legal-guarantee').wc_gzd_set_content(variation.legal_guarantee); 142 form.getElementOrBlock(form, 'garan_label', '.wc-gzd-garan-label').wc_gzd_set_content(variation.garan_label); 143 form.getElementOrBlock(form, 'deposit', '.deposit-amount').wc_gzd_set_content(hasDisplayPrice ? variation.deposit_amount : ''); 144 form.getElementOrBlock(form, 'deposit-packaging-type', '.deposit-packaging-type').wc_gzd_set_content(hasDisplayPrice ? variation.deposit_packaging_type : ''); 145 form.getElementOrBlock(form, 'food-description', '.wc-gzd-food-description').wc_gzd_
145set_content(variation.food_description); 146 form.getElementOrBlock(form, 'nutri-score', '.wc-gzd-nutri-score').wc_gzd_set_content(variation.nutri_score); 147 form.getElementOrBlock(form, 'food-distributor', '.wc-gzd-food-distributor').wc_gzd_set_content(variation.food_distributor); 148 form.getElementOrBlock(form, 'food-place-of-origin', '.wc-gzd-food-place-of-origin').wc_gzd_set_content(variation.food_place_of_origin); 149 form.getElementOrBlock(form, 'net-filling-quantity', '.wc-gzd-net-filling-quantity').wc_gzd_set_content(variation.net_filling_quantity); 150 form.getElementOrBlock(form, 'drained-weight', '.wc-gzd-drained-weight').wc_gzd_set_content(variation.drained_weight); 151 form.getElementOrBlock(form, 'alcohol-content', '.wc-gzd-alcohol-content').wc_gzd_set_content('no' === variation.includes_alcohol ? '' : variation.alcohol_content); 152 form.getElementOrBlock(form, 'nutrients', '.wc-gzd-nutrients').wc_gzd_set_content(variation.nutrients); 153 form.getElementOrBlock(form, 'nutrients-heading', '.wc-gzd-nutrients-heading').wc_gzd_set_content(variation.nutrients_heading); 154 form.getElementOrBlock(form, 'ingredients', '.wc-gzd-ingredients').wc_gzd_set_content(variation.ingredients); 155 form.getElementOrBlock(form, 'ingredients-heading', '.wc-gzd-ingredients-heading').wc_gzd_set_content(variation.ingredients_heading); 156 form.getElementOrBlock(form, 'allergenic', '.wc-gzd-allergenic').wc_gzd_
156set_content(variation.allergenic); 157 form.getElementOrBlock(form, 'allergenic-heading', '.wc-gzd-allergenic-heading').wc_gzd_set_content(variation.allergenic_heading); 158 form.getElementOrBlock(form, 'shipping-costs-info', '.shipping-costs-info').wc_gzd_set_content(hasDisplayPrice ? variation.shipping_costs_info : ''); 159 form.getElementOrBlock(form, 'unit-price', '.price-unit').wc_gzd_set_content(hasDisplayPrice ? variation.unit_price : ''); 160 form.getElementOrBlock(form, 'unit-product', '.product-units').wc_gzd_set_content(hasDisplayPrice ? variation.product_units : ''); 161 form.showOrHideTabs(form, variation.has_product_safety_information); 162 form.$form.trigger('germanized_variation_data', variation, $wrapper); 163 }; 164 165 /** 166 * Function to call wc_gzd_variation_form on jquery selector. 167 */ 168 $.fn.wc_germanized_variation_form = function () { 169 new GermanizedVariationForm(this); 170 return this; 171 }; 172 173 /** 174 * Stores the default text for an element so it can be reset later 175 */ 176 $.fn.wc_gzd_set_content = function (content) { 177 /** 178 * Explicitly exclude loop wrappers to prevent information 179 * to be replaced within the main product wrapper (e.g. cross-sells). 180 */ 181 var $this = this.not('.wc-gzd-additional-info-loop'); 182 content = undefined === content ? '' : content; 183 if (undefined === $this.attr('data-o_content')) { 184 $this.attr('data-o_content', $this.html()); 185 } 186 $this.html(content); 187 $this.addClass('variation_modified variation_gzd_modified').attr('aria-hidden', 'false').removeClass('wc-gzd-additional-info-placeholder').show(); 188 if ($this.is(':empty')) { 189 $this.attr('aria-hidden', 'true').hide(); 190 if ($this.parents('.wp-block-woocommerce-gzd-product-price-label').length > 0) { 191 $this.parents('.wp-block-woocommerce-gzd-product-price-label').attr('aria-hidden', 'true').addClass('wp-block-woocommerce-gzd-product-is-empty'); 192 } 193 if ($this.parents('.woocommerce-product-attributes-item').length > 0) { 194 $this.parents('.woocommerce-product-attributes-item').attr('aria-hidden', 'true').hide(); 195 } 196 } else { 197 if ($this.parents('.wp-block-woocommerce-gzd-product-price-label').length > 0) { 198 $this.parents('.wp-block-woocommerce-gzd-product-price-label').attr('aria-hidden', 'false').removeClass('wp-block-woocommerce-gzd-product-is-empty'); 199 } 200 if ($this.parents('.woocommerce-product-attributes-item').length > 0) { 201 $this.parents('.woocommerce-product-attributes-item').attr('aria-hidden', 'false').show(); 202 } 203 } 204 }; 205 206 /** 207 * Stores the default text for an element so it can be reset later 208 */ 209 $.fn.wc_gzd_reset_content = function () { 210 var $this = this.not('.wc-gzd-additional-info-loop'); 211 if (undefined !== $this.attr('data-o_content')) { 212 $this.html($this.attr('data-o_content')); 213 $this.removeClass('variation_modified variation_gzd_modified').show(); 214 } 215 if ($this.is(':empty')) { 216 $this.addClass('wc-gzd-additional-info-placeholder').attr('aria-hidden', 'true').hide(); 217 if ($this.parents('.wp-block-woocommerce-gzd-product-price-label').length > 0) { 218 $this.parents('.wp-block-woocommerce-gzd-product-price-label').addClass('wp-block-woocommerce-gzd-product-is-empty').attr('aria-hidden', 'true'); 219 } 220 if ($this.parents('.woocommerce-product-attributes-item').length > 0) { 221 $this.parents('.woocommerce-product-attributes-item').hide(); 222 } 223 } else { 224 if ($this.parents('.wp-block-woocommerce-gzd-product-price-label').length > 0) { 225 $this.parents('.wp-block-woocommerce-gzd-product-price-label').removeClass('wp-block-woocommerce-gzd-product-is-empty').attr('aria-hidden', 'false'); 226 } 227 if ($this.parents('.woocommerce-product-attributes-item').length > 0) { 228 $this.parents('.woocommerce-product-attributes-item').show(); 229 } 230 } 231 }; 232 $(function () { 233 if (typeof wc_gzd_add_to_cart_variation_params !== 'undefined') { 234 $('.variations_form').each(function () { 235 $(this).wc_germanized_variation_form(); 236 }); 237 238 /**
239 * Improve compatibility with custom implementations which might 240 * manually construct wc_variation_form() (e.g. quick view). 241 */ 242 $(document.body).on('wc_variation_form', function (e, variationForm) { 243 var $form; 244 if (typeof variationForm === 'undefined') { 245 $form = $(e.target); 246 } else { 247 $form = $(variationForm.$form); 248 } 249 if ($form.length > 0) { 250 if (!$form.hasClass('has-gzd-variation-form')) { 251 $form.wc_germanized_variation_form(); 252 // Make sure to reload variation to apply our logic 253 $form.trigger('check_variations'); 254 } 255 } 256 }); 257 } 258 }); 259})(jQuery, window, document); 260((window.germanized = window.germanized || {})["static"] = window.germanized["static"] || {})["add-to-cart-variation"] = __webpack_exports__; 261/******/ })() 262;
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.