PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 114
Lasso Lite – Affiliate Link Manager & Product Displays v114
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
simple-urls / admin / assets / js / support.js

support.js in Lasso Lite – Affiliate Link Manager & Product Displays 114, at admin/assets/js/support.js

148 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function() {
2 setTimeout(function () {
3 jQuery('#fake-intercom-bubble-chat').css('opacity', 1);
4 jQuery('#support-launcher').css('opacity', 1);
5 }, 2000);
6
7 jQuery(document)
8 .on('click', '#enable-support-wrapper .dismiss', function () {
9 jQuery("#enable-support").modal('hide');
10 lasso_lite_helper.set_local_storage('lasso_lite_should_open_support_modal', 0);
11 })
12 .on('click', '#btn-save-support', save_support )
13 .on('click', '#fake-intercom-bubble-chat', function () {
14 jQuery("#enable-support").modal('show');
15 })
16 .on('click', '#support-launcher', support_launcher )
17 .on('click', '#flow-confirm-button', customer_flow_confirm )
18 .on('click', '#customer-flow-confirm .no-thanks-button', customer_flow_no_thanks )
19 .on('click', '#customer-flow .support-option', intercom_support )
20 .ready(function () {
21 update_support();
22 });
23
24 function save_support() {
25 let btn_save = jQuery('#btn-save-support');
26 let js_error = jQuery('#enable-support-wrapper .js-error');
27 let email = jQuery('#enable-support-wrapper #email').val().trim();
28 let is_subscribe = jQuery('#enable-support-wrapper #subscribe').prop("checked");
29 if ( email !== '' ) {
30 jQuery.ajax({
31 url: lassoLiteOptionsData.ajax_url,
32 type: 'post',
33 data: {
34 action: 'lasso_lite_save_support',
35 email: email,
36 is_subscribe: is_subscribe,
37 },
38 beforeSend: function() {
39 jQuery('#enable-support-wrapper #email').removeClass('invalid-field');
40 js_error.css('display', 'none');
41 lasso_lite_helper.add_loading_button(btn_save);
42 }
43 }).done(function(res) {
44 lasso_lite_helper.add_loading_button(btn_save, 'Enable Support', false);
45 let data = res.data;
46 if ( data.success ) {
47 jQuery("#enable-support").modal('hide');
48
49 // Auto open customization display helper after enabling support
50 if ( 'undefined' !== typeof window.need_more_customization_flag ) {
51 lasso_lite_helper.set_local_storage('lasso_lite_open_need_more_customization', 1);
52 }
53
54 // Go to next step if we are in Welcome page
55 if ( 'surl-onboarding' === lasso_lite_helper.get_page_name() ) {
56 go_to_next_step_action(btn_save);
57 } else {
58 location.reload();
59 }
60 } else {
61 jQuery('#enable-support-wrapper #email').addClass('invalid-field');
62 js_error.text(data.msg);
63 js_error.css('display', 'block');
64 }
65 })
66 }
67 }
68
69 function update_support() {
70 jQuery('input[name="enable_support"]').change(lasso_lite_helper.debounce(function(e) {
71 let enable_support = jQuery('input[name="enable_support"]').prop('checked');
72 jQuery.ajax({
73 url: lassoLiteOptionsData.ajax_url,
74 type: 'post',
75 data: {
76 action: 'lasso_lite_update_support',
77 enable_support: enable_support,
78 }
79 });
80 }, 1000, null, true));
81 }
82
83 function support_launcher() {
84 let $el_support_launcher = jQuery('#support-launcher');
85 let $customer_flow_confirm_modal = jQuery('#customer-flow-confirm');
86
87 if ( ! $el_support_launcher.data('active') ) {
88 jQuery('#support-launcher .icon-default').css({'transform': 'rotate(180deg) scale(.5)', 'opacity': '0'});
89 jQuery('#support-launcher .icon-close').css({'transform': 'rotate(0deg) scale(1)', 'opacity': '1'});
90 jQuery('.support-wrap').css({'opacity': 1, 'height': 'auto'});
91 $el_support_launcher.data('active', true);
92 } else {
93 jQuery('#support-launcher .icon-default').css({'transform': 'rotate(0deg) scale(1)', 'opacity': '1'});
94 jQuery('#support-launcher .icon-close').css({'transform': 'rotate(-180deg) scale(.5)', 'opacity': '0'});
95 jQuery('.support-wrap').css({'opacity': 0, 'height': '0'});
96 $el_support_launcher.data('active', false);
97 Intercom('hide');
98
99 if ( $customer_flow_confirm_modal.hasClass('show') ) {
100 $customer_flow_confirm_modal.modal('hide');
101 }
102 }
103 }
104
105 function customer_flow_confirm() {
106 let $customer_flow_confirm_btn = jQuery('#flow-confirm-button');
107 let customer_flow_confirm = 1;
108
109 jQuery.ajax({
110 url: lassoLiteOptionsData.ajax_url,
111 type: 'post',
112 data: {
113 action: 'lasso_lite_update_customer_flow_enabled',
114 customer_flow_enabled: customer_flow_confirm,
115 },
116 beforeSend: function() {
117 $customer_flow_confirm_btn.html(lasso_lite_helper.get_loading_image_small())
118 }
119 }).done(function(res) {
120 if ( res.success ) {
121 jQuery('#customer-flow').data('customer-flow-enabled', customer_flow_confirm);
122 jQuery('#customer-flow-confirm').modal('hide');
123 Intercom('show');
124 }
125 });
126 }
127
128 function customer_flow_no_thanks() {
129 let $el_support_launcher = jQuery('#support-launcher');
130
131 jQuery('#support-launcher .icon-default').css({'transform': 'rotate(0deg) scale(1)', 'opacity': '1'});
132 jQuery('#support-launcher .icon-close').css({'transform': 'rotate(-180deg) scale(.5)', 'opacity': '0'});
133 jQuery('.support-wrap').css({'opacity': 0, 'height': '0'});
134 $el_support_launcher.data('active', false);
135 }
136
137 function intercom_support() {
138 let customer_flow_enabled = jQuery('#customer-flow').data('customer-flow-enabled');
139
140 if ( ! customer_flow_enabled ) {
141 jQuery('#customer-flow-confirm').modal('show');
142 } else {
143 Intercom('show');
144 jQuery('.support-wrap').css({'opacity': 0, 'height': '0'});
145 }
146 }
147 });
148