PluginProbe
MailerLite – WooCommerce integration / 2.0
MailerLite – WooCommerce integration v2.0
3.1.25 3.1.26 3.1.24 3.1.23 3.1.22 3.1.21 3.1.20 3.1.19 3.1.18 3.1.17 3.1.16 3.1.15 1.8.7 1.8.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 All 147 releases
woo-mailerlite / public / js / admin.min.js

admin.min.js in MailerLite – WooCommerce integration 2.0, at public/js/admin.min.js

173 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function(a) {
2 function b() {
3 h -= i, k = 100 * (g - h) / g;
4 var a = j.find("div");
5 a.css("width", k + "%");
6 }
7 var c = a("#woocommerce_mailerlite_group");
8 if (0 !== c.length) {
9 var d = c.next(".select2-container");
10 a('<span id="woo-ml-refresh-groups" class="woo-ml-icon-refresh" data-woo-ml-refresh-groups="true"></span>').insertAfter(d);
11 }
12 var e = !1;
13 a(document).on("click", "[data-woo-ml-refresh-groups]", function(b) {
14 if (b.preventDefault(), !e) {
15 var c = a(this);
16 c.removeClass("error"), c.addClass("running"), e = !0, jQuery.ajax({
17 url: woo_ml_post.ajax_url,
18 type: "post",
19 data: {
20 action: "post_woo_ml_refresh_groups"
21 },
22 success: function(a) {
23 a.indexOf("success") >= 0 && c.removeClass("running"), a ? location.reload() : c.addClass("error"),
24 e = !1;
25 }
26 });
27 }
28 });
29
30 a(document).on('click', '[data-woo-ml-reset-orders-sync]', function(event) {
31
32 event.preventDefault();
33
34 jQuery(this).prop('disabled', true);
35 jQuery(this).text("Please wait. Do not close this window until the reset finishes.");
36
37 resetOrdersSync();
38 });
39
40 var resetOrdersSync = function() {
41
42 jQuery.ajax({
43 url: woo_ml_post.ajax_url,
44 type: 'post',
45 data: {
46 action: 'post_woo_ml_reset_orders_sync'
47 },
48 async: true,
49 success: function (responseStr) {
50
51 var response = JSON.parse(responseStr);
52
53 if (response.allDone) {
54
55 window.location.reload();
56 } else {
57
58 resetOrdersSync();
59 }
60 }
61 });
62 }
63
64 var f = !1, g = 0, h = 0, i = 0, j = a("#woo-ml-sync-untracked-orders-progress-bar"), k = 0;
65 a(document).on("click", "[data-woo-ml-sync-untracked-orders]", function(c) {
66
67 c.preventDefault();
68
69 syncOrders(this);
70 });
71
72 var syncOrders = function(el) {
73
74 var d = a(el);
75 orders_tracked = d.data("woo-ml-untracked-orders-count");
76 all_untracked_orders_left = d.data("woo-ml-untracked-orders-left");
77 i = d.data("woo-ml-untracked-orders-cycle");
78 fail = a('#woo-ml-sync-untracked-orders-fail');
79 success = a("#woo-ml-sync-untracked-orders-success");
80 r = 0;
81 console.log("inside the loop!");
82 jQuery.ajax({
83 url: woo_ml_post.ajax_url,
84 type: "post",
85 beforeSend: function() {
86 d.prop("disabled", !0);
87 j.show();
88 r++;
89 },
90 data: {
91 action: "post_woo_ml_sync_untracked_orders"
92 },
93 async:1,
94 success: function(data) {
95
96 var response = JSON.parse(data);
97
98 if (response.allDone) {
99
100 console.log("done!");
101 console.log("Response: True");
102 d.hide();
103 j.hide();
104 fail.hide();
105 success.show();
106 } else if (response.error) {
107
108 d.prop('disabled', 0);
109 fail.show();
110 } else {
111
112 syncOrders(el);
113 }
114 }
115 });
116 };
117
118 var field = a("#woocommerce_mailerlite_api_key");
119 a('<button id="woo-ml-validate-key" class="button-primary">Validate Key</button>').insertAfter(field);
120 a(document).on("click", "#woo-ml-validate-key", function(b) {
121 if (b.preventDefault(), !e) {
122 var key = a("#woocommerce_mailerlite_api_key").val();
123 jQuery.ajax({
124 url: woo_ml_post.ajax_url,
125 type:"post",
126 data: {
127 action: "post_woo_ml_validate_key",
128 key:key
129 },
130 async: !1,
131 success: function(a) {
132 location.reload()
133 }
134 })
135 }
136 });
137 if (a('#woocommerce_mailerlite_group').length > 0) {
138 a('#woocommerce_mailerlite_group').select2();
139 }
140
141 if (a('#woocommerce_mailerlite_ignore_product_list').length > 0) {
142 a('#woocommerce_mailerlite_ignore_product_list').select2();
143 }
144
145 var cs_field = a('#woocommerce_mailerlite_consumer_secret');
146 if (0 !== cs_field.length) {
147 var field_desc = cs_field.next(".description");
148 field_desc.closest('tr').after(
149 '<h2>Integration Details</h2>\
150 <p class="section-description">Customize MailerLite integration for WooCommerce</p>');
151 }
152
153 var tracking_field = a('#woocommerce_mailerlite_popups');
154
155 tracking_field.closest('tr').before(
156 '<h2>Popups</h2>\
157 <p class="section-description">Display pop-up subscribe forms created within MailerLite</p>');
158
159 var button = a('[name="save"]');
160 if (field.length !== 0 && cs_field.length === 0) {
161 button.hide();
162 } else {
163 button.show();
164 }
165
166 var ignored_p_field = a('#woocommerce_mailerlite_ignore_product_list');
167 if (ignored_p_field.length !== 0) {
168 ignored_p_field.closest('tr').before(
169 '<h2>E-commerce Automations</h2>\
170 <p class="section-description">Customize settings for your e-commerce automations created in MailerLite </p>'
171 )
172 }
173 });