1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3var __webpack_exports__ = {}; 4 5;// CONCATENATED MODULE: ./assets/js/src/frontend/quantity-table/quantity-table.js 6function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 7function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 9function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 10function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } 11function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 12var QuantityTable = /*#__PURE__*/function () { 13 function QuantityTable(element) { 14 _classCallCheck(this, QuantityTable); 15 this.elementDOM = element; 16 this.table = false; 17 this.productDOM = this.elementDOM.parents(ywdpd_qty_args.column_product_info_class); 18 this.qtyDOM = this.productDOM.find(ywdpd_qty_args.product_qty_classes); 19 this.variationForm = this.productDOM.find(ywdpd_qty_args.variation_form_class); 20 this.qtyDOM.on('change', this.handleChangeQuantity.bind(this)); 21 this.initTable(); 22 this.defaultTable = this.elementDOM.html(); 23 if (this.variationForm) { 24 this.variationForm.on('show_variation', this.showVariationTable.bind(this)); 25 this.variationForm.on('reset_data', this.resetVariationTable.bind(this)); 26 } 27 } 28 _createClass(QuantityTable, [{ 29 key: "initTable", 30 value: function initTable() { 31 this.table = this.elementDOM.find('#ywdpd-quantity-table'); 32 this.table.on('click', 'td', this.handleTdClickEvent.bind(this)); 33 this.selectDefaultQty(); 34 } 35 }, { 36 key: "handleTdClickEvent", 37 value: function handleTdClickEvent(event) { 38 event.preventDefault(); 39 var td = jQuery(event.target); 40 this.selectRightInfo(td); 41 } 42 }, { 43 key: "selectDefaultQty", 44 value: function selectDefaultQty() { 45 if ('yes' === ywdpd_qty_args.is_default_qty_enabled) { 46 var td; 47 if ('yes' === ywdpd_qty_args.show_minimum_price) { 48 td = this.table.find('td.qty-price-info').last(); 49 } else { 50 td = this.table.find('td.qty-price-info').first(); 51 } 52 td.trigger('click'); 53 } 54 } 55 }, { 56 key: "selectRightInfo", 57 value: function selectRightInfo(td) { 58 var updateQty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 59 if (this.table.hasClass('vertical')) { 60 var tr = td.parents('tr'); 61 this.toggleRow(tr, updateQty); 62 } else { 63 var index = td.index(); 64 this.toggleColumn(index, updateQty); 65 } 66 } 67 }, { 68 key: "toggleRow", 69 value: function toggleRow(tr, updateQty) { 70 this.table.find('td').removeClass('ywdpd_active'); 71 tr.find('td').addClass('ywdpd_active'); 72 var tdQty = tr.find('td.qty-info'); 73 if (updateQty) { 74 this.updateQuantityField(tdQty); 75 } 76 this.updatePriceField(tdQty); 77 } 78 }, { 79 key: "toggleColumn", 80 value: function toggleColumn(columnIndex, updateQty) { 81 this.table.find('td').removeClass('ywdpd_active'); 82 this.table.find('tr td:nth-of-type(' + columnIndex + ')').addClass('ywdpd_active'); 83 var td = this.table.find('tr td.qty-info:nth-of-type(' + columnIndex + ')'); 84 if (updateQty) { 85 this.updateQuantityField(td); 86 } 87 this.updatePriceField(td); 88 } 89 }, { 90 key: "handleChangeQuantity", 91 value: function handleChangeQuantity(event) { 92 event.stopImmediatePropagation(); 93 var qty = parseInt(event.target.value); 94 if ('yes' === ywdpd_qty_args.is_change_qty_enabled && qty > 0) { 95 var td = this.table.find('td.qty-info').filter(function () { 96 var max = jQuery(this).data('qtymax'); 97 if (max !== '*') { 98 return jQuery(this).data('qtymin') <= qty && jQuery(this).data('qtymax') >= qty; 99 } 100 return jQuery(this).data('qtymin') <= qty; 101 }); 102 if (td) { 103 this.selectRightInfo(td, false); 104 } 105 } 106 } 107 }, { 108 key: "updateQuantityField", 109 value: function updateQuantityField(tdQuantity) { 110 var newQty = '*' !== tdQuantity.data('qtymax') && !ywdpd_qty_args.select_minimum_quantity ? tdQuantity.data('qtymax') : tdQuantity.data('qtymin'); 111 this.qtyDOM.val(newQty); 112 } 113 }, { 114 key: "updatePriceField", 115 value: function updatePriceField(tdQuantity) { 116 var productType = this.table.data('product_type'); 117 if ('variable' !== productType) { 118 var newPrice = ''; 119 if (tdQuantity.length) { 120 newPrice = tdQuantity.data('formatted_price'); 121 } else { 122 newPrice = this.table.data('price_html'); 123 } 124 var rawPrice = tdQuantity.data('unformatted_price'); 125 this.updatePriceHtml(newPrice, rawPrice); 126 } 127 } 128 }, { 129 key: "updatePriceHtml", 130 value: function updatePriceHtml(newPrice, rawPrice) { 131 var extra_class = ''; 132 if ('' !== newPrice) { 133 if (this.productDOM.parents('.yith-quick-view-content').length) { 134 extra_class = '.yith-quick-view-content '; 135 } 136 var product_container = jQuery(extra_class + ywdpd_qty_args.column_product_info_class);
137 if (!product_container.find('.woocommerce-variation-price').length) { 138 product_container.find(ywdpd_qty_args.product_price_classes).html(newPrice); 139 } else { 140 var variations_price = product_container.find('.woocommerce-variation-price .price'); 141 variations_price.html(newPrice); 142 } 143 jQuery(document).trigger('ywdpd_price_html_updated', [newPrice, rawPrice]); 144 } 145 } 146 }, { 147 key: "showVariationTable", 148 value: function showVariationTable(event, variation) { 149 if (variation.table_price) { 150 var variationTableWrapper = jQuery(variation.table_price); 151 if (variationTableWrapper.find('#ywdpd-quantity-table').length) { 152 this.elementDOM.html(variationTableWrapper.html()); 153 this.elementDOM.show(); 154 if ('yes' !== ywdpd_qty_args.is_default_qty_enabled) { 155 this.updatePriceHtml(variation.price_html, ''); 156 } 157 } else { 158 this.elementDOM.html('').hide(); 159 this.updatePriceHtml(variation.price_html, ''); 160 } 161 this.initTable(); 162 } 163 } 164 }, { 165 key: "resetVariationTable", 166 value: function resetVariationTable() { 167 if ('yes' === ywdpd_qty_args.show_variable_table) { 168 this.elementDOM.html(this.defaultTable); 169 this.initTable(); 170 } else { 171 this.elementDOM.hide(); 172 } 173 } 174 }]); 175 return QuantityTable; 176}(); 177 178;// CONCATENATED MODULE: ./assets/js/src/frontend/product-notices/product-notices.js 179function product_notices_typeof(o) { "@babel/helpers - typeof"; return product_notices_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, product_notices_typeof(o); } 180function product_notices_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 181function product_notices_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, product_notices_toPropertyKey(descriptor.key), descriptor); } } 182function product_notices_createClass(Constructor, protoProps, staticProps) { if (protoProps) product_notices_defineProperties(Constructor.prototype, protoProps); if (staticProps) product_notices_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 183function product_notices_toPropertyKey(arg) { var key = product_notices_toPrimitive(arg, "string"); return product_notices_typeof(key) === "symbol" ? key : String(key); } 184function product_notices_toPrimitive(input, hint) { if (product_notices_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (product_notices_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 185var ProductNotices = /*#__PURE__*/function () { 186 function ProductNotices(element) { 187 product_notices_classCallCheck(this, ProductNotices); 188 this.elementDOM = element; 189 this.productNoticeWrapper = element.html(); 190 this.productDOM = this.elementDOM.parents(ywdpd_qty_args.column_product_info_class); 191 this.variationForm = this.productDOM.find(ywdpd_qty_args.variation_form_class); 192 if (this.variationForm) { 193 this.variationForm.on('show_variation', this.showVariationNotices.bind(this)); 194 this.variationForm.on('reset_data', this.resetVariationNotices.bind(this)); 195 } 196 } 197 product_notices_createClass(ProductNotices, [{ 198 key: "showVariationNotices", 199 value: function showVariationNotices(event, variation) { 200 if (variation.ywdpd_notices) { 201 var newNoticesWrapper = jQuery(variation.ywdpd_notices); 202 if (newNoticesWrapper.length) { 203 this.elementDOM.html(newNoticesWrapper.html()).show(); 204 } else { 205 this.elementDOM.hide(); 206 } 207 } 208 } 209 }, { 210 key: "resetVariationNotices", 211 value: function resetVariationNotices() { 212 this.elementDOM.html(this.productNoticeWrapper).show(); 213 } 214 }]); 215 return ProductNotices; 216}(); 217 218;// CONCATENATED MODULE: ./assets/js/src/frontend/index.js 219 220 221 222 223jQuery(document).ready(function ($) { 224 var tables = $(document).find('.ywdpd-table-discounts-wrapper'); 225 var notices = $(document).find('.ywdpd-notices-wrapper'); 226 tables.each(function () { 227 new QuantityTable($(this)); 228 }); 229 notices.each(function () { 230 new ProductNotices($(this)); 231 }); 232 $(document.body).on('payment_method_selected', function (e) { 233 var selectedPaymentMethod = $('.woocommerce-checkout input[name="payment_method"]:checked').attr('id'); 234 var data = { 235 action: ywdpd_popup_args.actions.valid_rule_in_checkout, 236 security: ywdpd_popup_args.nonces.valid_rule_in_checkout, 237 payment_method: selectedPaymentMethod, 238 context: 'frontend' 239 }; 240 jQuery.ajax({ 241 type: 'POST', 242 url: ywdpd_popup_args.ajax_url, 243 data: data, 244 dataType: 'json', 245 beforeSend: function beforeSend() {}, 246 success: function success(response) { 247 $(document.body).trigger('update_checkout'); 248 }, 249 complete: function complete() {} 250 }); 251 }); 252}); 253/******/ })() 254; 255//# sourceMappingURL=frontend.js.map
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.