PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.5.2
EmailKit – Email Customizer for WooCommerce & WP v1.5.2
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / EmailSettings / Wcintegration.js

Wcintegration.js in EmailKit – Email Customizer for WooCommerce & WP 1.5.2, at includes/Admin/EmailSettings/Wcintegration.js

65 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function($) {
2
3 function disableBtn(el, exceptEl = '', isTrue = false) {
4 if (exceptEl !== "") {
5 jQuery(el).not(exceptEl).each((index, item) => {
6 jQuery(item).prop('disabled', isTrue);
7 })
8 } else {
9 jQuery(el).each((index, item) => {
10 jQuery(item).prop('disabled', isTrue);
11 })
12 }
13 }
14
15 $('.emailkit-edit-button').on('click', function(e) {
16 e.preventDefault();
17 let _self = this;
18
19 disableBtn('.emailkit-woocom-btn', _self, true);
20
21 var builderUrl = $(this).attr('href');
22
23 if (builderUrl.trim() !=='') {
24 window.open(builderUrl, '_blank');
25 disableBtn('.emailkit-woocom-btn', "", false);
26 return false;
27 }
28
29 jQuery(this).addClass('emailkit-slider-loader');
30
31 var editorTemplateUrl = $(this).data('editor-template-url');
32 var emailType = $(this).data('emailkit-email-type');
33 var templateType = $(this).data('emailkit-template-type');
34 var templateTitle = $(this).data('emailkit-template-title');
35 var templateStatus = 'active';
36
37 // Make an AJAX request to the REST API endpoint
38 $.ajax({
39 url: woocommerce.rest_url + 'template-data',
40 method: 'POST',
41 headers: {
42 'X-WP-Nonce': woocommerce.rest_nonce,
43 },
44 data: {
45 'emailkit-editor-template': editorTemplateUrl,
46 'emailkit_email_type': emailType,
47 'emailkit_template_type': templateType,
48 'emailkit_template_title': templateTitle,
49 'emailkit_template_status': templateStatus
50 },
51 success: function(response) {
52 window.open(response.data.builder_url, '_blank');
53 disableBtn('.emailkit-woocom-btn', "", false);
54 jQuery(_self).removeClass('emailkit-slider-loader');
55 },
56 error: function(error) {
57 console.error(error);
58 disableBtn('.emailkit-woocom-btn', "", false);
59 jQuery(_self).removeClass('emailkit-slider-loader');
60 }
61 });
62
63
64 });
65 });