PageSourceSearch

https://www.azioonline.com/wp-content/plugins/wpc-force-sells/assets/js/frontend.js?ver=4.6.3

js azioonline.com collected 2026-10-06 17:50:35 UTC 19,019 bytes, 588 lines download raw bytes

1'use strict';
2
3(function($) {
4  $(function() {
5    if (!$('.woofs-wrap').length) {
6      return;
7    }
8
9    $('.woofs-wrap').each(function() {
10      woofs_init($(this));
11    });
12  });
13
14  $(document).on('woosq_loaded', function() {
15    if ($('#woosq-popup').find('.woofs-wrap').length) {
16      woofs_init($('#woosq-popup').find('.woofs-wrap'));
17    }
18  });
19
20  $(document).on('woovr_selected', function(e, selected, variations) {
21    var $wrap = variations.closest('.woofs-wrap');
22    var $product = variations.closest('.woofs-product');
23    var $products = variations.closest('.woofs-products');
24    var purchasable = selected.attr('data-purchasable');
25    var price = selected.attr('data-price');
26    var regular_price = selected.attr('data-regular-price');
27    var id = selected.attr('data-id');
28    var sku = selected.attr('data-sku');
29    var weight = selected.attr('data-weight');
30    var dimensions = selected.attr('data-dimensions');
31    var image_src = selected.attr('data-imagesrc');
32
33    if ($product.length) {
34      if (purchasable === 'yes') {
35        $product.attr('data-id', id);
36        $product.attr('data-price-ori', price);
37        $product.attr('data-regular-price', regular_price);
38
39        // change image
40        if (image_src !== undefined && image_src !== '') {
41          $product.find('.woofs-thumb-ori').hide();
42          $product.find('.woofs-thumb-new').
43              html('<img src="' + image_src + '"/>').
44              show();
45        }
46
47        // change price
48        var new_price = $product.attr('data-price');
49
50        if (isNaN(new_price)) {
51          new_price = price * parseFloat(new_price) / 100;
52        }
53
54        $product.find('.woofs-price-ori').hide();
55        $product.find('.woofs-price-new').
56            html(woofs_price_html(price, new_price)).
57            show();
58
59        // change attributes
60        var attrs = {};
61
62        $product.find('select[name^="attribute_"]').each(function() {
63          var attr_name = $(this).attr('name');
64
65          attrs[attr_name] = $(this).val();
66        });
67
68        $product.attr('data-attrs', JSON.stringify(attrs));
69      } else {
70        // reset data
71        $product.attr('data-id', 0);
72        $product.attr('data-attrs', '');
73        $product.attr('data-price-ori', 0);
74        $product.attr('data-regular-price', 0);
75
76        // reset image
77        $product.find('.woofs-thumb-ori').show();
78        $product.find('.woofs-thumb-new').html('').hide();
79
80        // reset price
81        $product.find('.woofs-price-ori').show();
82        $product.find('.woofs-price-new').html('').hide();
83      }
84
85      // prevent changing SKU / weight / dimensions
86      $('.product_meta .sku').html($products.attr('data-product-sku'));
87      $('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value').
88          html($products.attr('data-product-weight'));
89      $('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value').
90          html($products.attr('data-product-dimensions'));
91    } else {
92      var pid = variations.closest('.variations_form').attr('data-product_id');
93
94      $wrap = $('.woofs-wrap-' + pid);
95      $products = $wrap.find('.woofs-products');
96
97      if ($products.length &&
98          !variations.closest('.woosb-product').length &&
99          !variations.closest('.woobt-product').length &&
100          !variations.closest('.woosg-product').length) {
101        if (id > 0) {
102          $products.attr('data-product-price', price);
103          $products.attr('data-product-regular-price', regular_price);
104          $products.attr('data-product-sku', sku);
105          $products.attr('data-product-weight', weight);
106          $products.attr('data-product-dimensions', dimensions);
107        } else {
108          // reset
109          $products.attr('data-product-price', 0);
110          $products.attr('data-product-regular-price', 0);
111          $products.attr('data-product-sku',
112              $products.attr('data-product-o_sku'));
113          $products.attr('data-product-weight',
114              $products.attr('data-product-o_weight'));
115          $products.attr('data-product-dimensions',
116              $products.attr('data-product-o_dimensions'));
117        }
118      }
119    }
120
121    if ($wrap.length) {
122      woofs_init($wrap);
123    }
124  });
125
126  $(document).on('found_variation', function(e, t) {
127    var $wrap = $(e['target']).closest('.woofs-wrap');
128    var $product = $(e['target']).closest('.woofs-product');
129    var $products = $(e['target']).closest('.woofs-products');
130
131    if ($product.length) {
132      var _price = $product.attr('data-price');
133
134      if (isNaN(_price)) {
135        _price = t['display_price'] *
136            parseInt($product.attr('data-price')) / 100;
137      }
138
139      $product.find('.woofs-price-ori').hide();
140      $product.find('.woofs-price-new').
141          html(woofs_format_price(_price)).
142          show();
143
144      $product.attr('data-price-ori', t['display_price']);
145      $product.attr('data-regular-price', t['display_regular_price']);
146
147      if (t['is_purchasable'] && t['is_in_stock']) {
148        $product.attr('data-id', t['variation_id']);
149
150        // change attributes
151        var attrs = {};
152
153        $product.find('select[name^="attribute_"]').each(function() {
154          var attr_name = $(this).attr('name');
155
156          attrs[attr_name] = $(this).val();
157        });
158
159        $product.attr('data-attrs', JSON.stringify(attrs));
160      } else {
161        $product.attr('data-id', 0);
162        $product.attr('data-attrs', '');
163      }
164
165      // change availability
166      if (t['availability_html'] && t['availability_html'] !== '') {
167        $product.find('.woofs-availability').
168            html(t['availability_html']).
169            show();
170      } else {
171        $product.find('.woofs-availability').html('').hide();
172      }
173
174      if (t['image']['url'] && t['image']['srcset']) {
175        // change image
176        $product.find('.woofs-thumb-ori').hide();
177        $product.find('.woofs-thumb-new').
178            html('<img src="' + t['image']['url'] + '" srcset="' +
179                t['image']['srcset'] + '"/>').
180            show();
181      }
182
183      if (woofs_vars.change_image === 'no') {
184        // prevent changing the main image
185        $(e['target']).
186            closest('.variations_form').
187            trigger('reset_image');
188      }
189
190      // prevent changing SKU / weight / dimensions
191      $('.product_meta .sku').html($products.attr('data-product-sku'));
192      $('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value').
193          html($products.attr('data-product-weight'));
194      $('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value').
195          html($products.attr('data-product-dimensions'));
196    } else {
197      var pid = $(e['target']).
198          closest('.variations_form').
199          attr('data-product_id');
200
201      $wrap = $('.woofs-wrap-' + pid);
202      $products = $wrap.find('.woofs-products');
203
204      if ($products.length &&
205          !$(e['target']).closest('.woosb-product').length &&
206          !$(e['target']).closest('.woobt-product').length &&
207          !$(e['target']).closest('.woosg-product').length) {
208        $products.attr('data-product-price', t['display_price']);
209        $products.attr('data-product-regular-price',
210            t['display_regular_price']);
211
212        $products.attr('data-product-sku', t['sku']);
213        $products.attr('data-product-weight', t['weight_html']);
214        $products.attr('data-product-dimensions', t['dimensions_html']);
215      }
216    }
217
218    if ($wrap.length) {
219      woofs_init($wrap);
220    }
221  });
222
223  $(document).on('reset_data', function(e) {
224    var $wrap = $(e['target']).closest('.woofs-wrap');
225    var $product = $(e['target']).closest('.woofs-product');
226    var $products = $(e['target']).closest('.woofs-products');
227
228    if ($product.length) {
229      $product.attr('data-id', 0);
230      $product.attr('data-attrs', '');
231      $product.attr('data-price-ori', 0);
232      $product.attr('data-regular-price', 0);
233
234      // reset availability
235      $product.find('.woofs-availability').html('').hide();
236
237      // reset thumb
238      $product.find('.woofs-thumb-new').hide();
239      $product.find('.woofs-thumb-ori').show();
240
241      // reset SKU / weight / dimensions
242      $('.product_meta .sku').html($products.attr('data-product-sku'));
243      $('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value').
244          html($products.attr('data-product-weight'));
245      $('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value').
246          html($products.attr('data-product-dimensions'));
247    } else {
248      var pid = $(e['target']).
249          closest('.variations_form').
250          attr('data-product_id');
251
252      $wrap = $('.woofs-wrap-' + pid);
253      $products = $wrap.find('.woofs-products');
254
255      if ($products.length &&
256          !$(e['target']).closest('.woosb-product').length &&
257          !$(e['target']).closest('.woobt-product').length &&
258          !$(e['target']).closest('.woosg-product').length) {
259        $products.attr('data-product-price', 0);
260        $products.attr('data-product-regular-price', 0);
261        $products.attr('data-product-sku',
262            $products.attr('data-product-o_sku'));
263        $products.attr('data-product-weight',
264            $products.attr('data-product-o_weight'));
265        $products.attr('data-product-dimensions',
266            $products.attr('data-product-o_dimensions'));
267      }
268    }
269
270    if ($wrap.length) {
271      woofs_init($wrap);
272    }
273  });
274
275  $(document).on('change', 'form.cart input[name="quantity"]', function() {
276    var $this = $(this);
277    var qty = $this.val();
278
279    if ($this.closest('form.cart').find('input[name="woofs_ids"]').length) {
280      var wid = $this.closest('form.cart').
281          find('input[name="woofs_ids"]').
282          attr('data-id');
283      var $wrap = $('.woofs-wrap-' + wid);
284      var sync_quantity = $wrap.find('.woofs-products').
285          attr('data-sync-quantity');
286
287      if (sync_quantity === 'on') {
288        $wrap.find('.woofs-product').each(function() {
289          var $product = $(this);
290          var sync_qty = $product.attr('data-qty-ori') * qty;
291
292          $product.attr('data-qty', sync_qty);
293          $product.find('.woofs-qty-num').html(sync_qty);
294        });
295
296        woofs_init($wrap);
297      }
298    }
299  });
300
301  $(document).on('click touch', '.single_add_to_cart_button', function(e) {
302    if ($(this).hasClass('woofs-disabled')) {
303      e.preventDefault();
304    }
305  });
306})(jQuery);
307
308function woofs_init($wrap) {
309  var wid = $wrap.attr('data-id');
310  var $products = $wrap.find('.woofs-products');
311  var $ids = jQuery('.woofs-ids-' + wid);
312
313  if ((woofs_vars.position === 'before') &&
314      ($products.attr('data-product-type') === 'variable') &&
315      (($products.attr('data-variables') === 'no') ||
316          (woofs_vars.variations_selector === 'wpc_radio') ||
317          (woofs_vars.variations_selector === 'woovr'))) {
318    $wrap.insertAfter($ids);
319  }
320
321  woofs_check_ready($wrap);
322  woofs_calc_price($wrap);
323  woofs_save_ids($wrap);
324
325  jQuery(document).trigger('woofs_init', [$wrap]);
326}
327
328function woofs_check_ready($wrap) {
329  var wid = $wrap.attr('data-id');
330  var ready = true;
331  var is_selection = false;
332  var selection_name = '';
333  var $alert = $wrap.find('.woofs-alert');
334  var $btn = jQuery('.woofs-ids-' + wid).
335      closest('form.cart').
336      find('.single_add_to_cart_button');
337
338  $wrap.find('.woofs-product').each(function() {
339    var $this = jQuery(this);
340
341    if (parseFloat($this.attr('data-qty')) === 0) {
342      $this.addClass('woofs-hide');
343    } else {
344      $this.removeClass('woofs-hide');
345    }
346
347    if ((
348        parseFloat($this.attr('data-qty')) > 0
349    ) && (
350        parseInt($this.attr('data-id')) === 0
351    )) {
352      is_selection = true;
353
354      if (selection_name === '') {
355        selection_name = $this.attr('data-name');
356      }
357    }
358  });
359
360  if (is_selection) {
361    ready = false;
362    $btn.addClass('woofs-disabled');
363    $alert.html(woofs_vars.alert_selection.replace('[name]',
364        '<strong>' + selection_name + '</strong>')).slideDown();
365  } else {
366    $alert.html('').slideUp();
367    $btn.removeClass('woofs-disabled');
368  }
369
370  jQuery(document).trigger('woofs_check_ready', [ready, is_selection, $wrap]);
371}
372
373function woofs_calc_price($wrap) {
374  var wid = $wrap.attr('data-id');
375  var $products = $wrap.find('.woofs-products');
376  var separately = $products.attr('data-separately');
377  var $additional = $wrap.find('.woofs-additional');
378  var $total = $wrap.find('.woofs-total');
379  var $ids = jQuery('.woofs-ids-' + wid);
380  var $price = jQuery('.woofs-price-' + wid);
381  var $woobt = jQuery('.woobt-wrap-' + wid);
382  var additional = 0, additional_regular = 0, total = 0, total_regular = 0;
383  var additional_html = '', total_html = '';
384  var price = parseFloat($products.attr('data-product-price'));
385  var regular_price = parseFloat($products.attr('data-product-regular-price'));
386  var qty = parseInt($ids.closest('form.cart').find('input.qty').val());
387
388  $wrap.find('.woofs-product').each(function() {
389    var $this = jQuery(this);
390    var _price = 0;
391    var _regular_price = 0;
392
393    if (parseFloat($this.attr('data-qty')) > 0 &&
394        parseInt($this.attr('data-id')) > 0) {
395      _regular_price = parseFloat($this.attr('data-regular-price')) *
396          parseFloat($this.attr('data-qty'));
397
398      if (separately === 'on') {
399        _price = parseFloat($this.attr('data-price-ori')) *
400            parseFloat($this.attr('data-qty'));
401      } else {
402        if (isNaN($this.attr('data-price'))) {
403          // is percentage
404          _price = (
405              parseFloat($this.attr('data-price-ori')) *
406              parseInt($this.attr('data-price')) / 100
407          ) * parseFloat($this.attr('data-qty'));
408        } else {
409          _price = parseFloat($this.attr('data-price')) *
410              parseFloat($this.attr('data-qty'));
411        }
412      }
413
414      if (woofs_vars.show_price === 'total') {
415        $this.find('.woofs-price-ori').hide();
416        $this.find('.woofs-price-new').
417            html(woofs_price_html(_regular_price, _price)).
418            show();
419      }
420
421      // calc total
422      additional += _price;
423      additional_regular += _regular_price;
424    } else {
425      $this.find('.woofs-price-new').html('').hide();
426      $this.find('.woofs-price-ori').show();
427    }
428  });
429
430  total = price * qty;
431  total_regular = regular_price * qty;
432
433  if (additional > 0) {
434    total += additional;
435    total_regular += additional_regular;
436  }
437
438  additional_html = woofs_price_html(additional_regular, additional);
439  total_html = woofs_price_html(total_regular, total);
440
441  if (additional > 0) {
442    // additional
443    $additional.html(woofs_vars.additional_text + ' ' + additional_html).
444        slideDown();
445
446    // total
447    $total.html(woofs_vars.total_text + ' ' + total_html).
448        slideDown();
449  } else {
450    $additional.html('').slideUp();
451    $total.html('').slideUp();
452  }
453
454  // change the main price
455  if (woofs_vars.change_price !== 'no') {
456    if ((woofs_vars.change_price === 'yes_custom') &&
457        (woofs_vars.price_selector != null) &&
458        (woofs_vars.price_selector !== '')) {
459      $price = jQuery(woofs_vars.price_selector);
460    }
461
462    $price.html(total_html);
463  }
464
465  if ($woobt.length) {
466    $woobt.find('.woobt-products').
467        attr('data-product-price-html', total_html);
468    $woobt.find('.woobt-product-this').
469        attr('data-price', total).
470        attr('data-regular-price', total_regular);
471
472    woobt_init($woobt);
473  }
474
475  jQuery(document).
476      trigger('woofs_calc_price',
477          [additional, additional_html, total, total_html, $wrap]);
478}
479
480function woofs_save_ids($wrap) {
481  var wid = $wrap.attr('data-id');
482  var $ids = jQuery('.woofs-ids-' + wid);
483  var ids = [];
484
485  $wrap.find('.woofs-product').each(function() {
486    var $this = jQuery(this);
487    var id = parseInt($this.attr('data-id'));
488    var price = jQuery(this).attr('data-price');
489    var qty = parseFloat($this.attr('data-qty-ori'));
490    var attrs = $this.attr('data-attrs');
491
492    if ((id > 0) && (qty > 0)) {
493      if (attrs !== undefined) {
494        attrs = encodeURIComponent(attrs);
495      } else {
496        attrs = '';
497      }
498
499      ids.push(id + '/' + price + '/' + qty + '/' + attrs);
500    }
501  });
502
503  if (ids.length > 0) {
504    $ids.val(ids.join(','));
505  } else {
506    $ids.val('');
507  }
508
509  jQuery(document).trigger('woofs_save_ids', [ids, $wrap]);
510}
511
512function woofs_format_money(number, places, symbol, thousand, decimal) {
513  number = number || 0;
514  places = !isNaN(places = Math.abs(places)) ? places : 2;
515  symbol = symbol !== undefined ? symbol : '$';
516  thousand = thousand || ',';
517  decimal = decimal || '.';
518  var negative = number < 0 ? '-' : '',
519      i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) +
520          '',
521      j = 0;
522  if (i.length > 3) {
523    j = i.length % 3;
524  }
525  return symbol + negative + (
526      j ? i.substr(0, j) + thousand : ''
527  ) + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand) + (
528      places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : ''
529  );
530}
531
532function woofs_format_price(total, prefix) {
533  var total_html = '<span class="woocommerce-Price-amount amount">';
534  var total_formatted = woofs_format_money(total, woofs_vars.price_decimals,
535      '', woofs_vars.price_thousand_separator,
536      woofs_vars.price_decimal_separator);
537
538  switch (woofs_vars.price_format) {
539    case '%1$s%2$s':
540      //left
541      total_html += '<span class="woocommerce-Price-currencySymbol">' +
542          woofs_vars.currency_symbol + '</span>' + total_formatted;
543      break;
544    case '%1$s %2$s':
545      //left with space
546      total_html += '<span class="woocommerce-Price-currencySymbol">' +
547          woofs_vars.currency_symbol + '</span> ' + total_formatted;
548      break;
549    case '%2$s%1$s':
550      //right
551      total_html += total_formatted +
552          '<span class="woocommerce-Price-currencySymbol">' +
553          woofs_vars.currency_symbol + '</span>';
554      break;
555    case '%2$s %1$s':
556      //right with space
557      total_html += total_formatted +
558          ' <span class="woocommerce-Price-currencySymbol">' +
559          woofs_vars.currency_symbol + '</span>';
560      break;
561    default:
562      //default
563      total_html += '<span class="woocommerce-Price-currencySymbol">' +
564          woofs_vars.currency_symbol + '</span> ' + total_formatted;
565  }
566
567  total_html += '</span>';
568
569  if (prefix != null) {
570    return prefix + total_html;
571  }
572
573  return total_html;
574}
575
576function woofs_price_html(regular_price, sale_price) {
577  var price_html = '';
578
579  if (sale_price < regular_price) {
580    price_html = '<del>' + woofs_format_price(regular_price) +
581        '</del> <ins>' +
582        woofs_format_price(sale_price) + '</ins>';
583  } else {
584    price_html = woofs_format_price(regular_price);
585  }
586
587  return price_html;
588}

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.