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