PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.10.0
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.10.0
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / assets / js / modules / payment-logos / admin / preview.js

preview.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 1.10.0, at assets/js/modules/payment-logos/admin/preview.js

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 ;
4 (function ($) {
5 'use strict';
6
7 var $widthInput = $('input[name="merchant[image-max-width]');
8 var $heightInput = $('input[name="merchant[image-max-height]');
9
10 // On page load
11 var imageDimensionPrev = {
12 width: $widthInput.val(),
13 height: $heightInput.val()
14 };
15 $(document).on('save.merchant', function (e, module) {
16 if (module === 'payment-logos') {
17 var logosStr = $('input[name="merchant[logos]"]').val();
18 var logosArr = logosStr.split(',');
19 regenerate_images(logosArr);
20 }
21 });
22 function regenerate_images(attachments) {
23 var _merchant, _merchant2;
24 var imageDimensionNext = {
25 width: $widthInput.val(),
26 height: $heightInput.val()
27 };
28
29 // Check if image dimensions have changed
30 var isDimensionChanged = imageDimensionPrev.width !== imageDimensionNext.width || imageDimensionPrev.height !== imageDimensionNext.height;
31
32 // Update previous dimensions for the next comparison
33 if (isDimensionChanged) {
34 imageDimensionPrev.height = imageDimensionNext.height;
35 imageDimensionPrev.width = imageDimensionNext.width;
36 }
37 $.ajax({
38 type: 'POST',
39 url: (_merchant = merchant) === null || _merchant === void 0 ? void 0 : _merchant.ajax_url,
40 data: {
41 action: 'merchant_regenerate_images',
42 nonce: (_merchant2 = merchant) === null || _merchant2 === void 0 ? void 0 : _merchant2.nonce,
43 is_dimension_changed: isDimensionChanged,
44 attachments: attachments
45 },
46 beforeSend: function beforeSend(r) {
47 if (isDimensionChanged) {
48 //$('<span>Regenerating...</span>').insertAfter( $( '.merchant-gallery-button' ) );
49 }
50 },
51 success: function success(response) {
52 if (!response || !response.data) {
53 return;
54 }
55 // Do something
56 },
57 error: function error(_error) {
58 console.log(_error);
59 }
60 });
61 }
62 })(jQuery);