PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 150
Lasso Lite – Affiliate Link Manager & Product Displays v150
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 / settings.js

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

170 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var affiliateLasso = affiliateLasso || {};
2 var ajax_url = lassoLiteOptionsData.ajax_url;
3 var interval_time = 5000;
4 var initialFieldsValue = {};
5 var progessPercentage = 0;
6 var progressInterval = '';
7
8 jQuery(document).ready(function() {
9
10 active_license_key();
11
12 jQuery(document)
13 .on('click', '#onboarding-save-display-btn', handleSettingSave);
14
15 // A Function send the array of setting to ajax.php
16 function handleSettingSave() {
17 // Fetch all the settings
18 var settings = lasso_lite_helper.fetchAllOptions();
19
20 // Prepare data
21 var data = {
22 action: 'lasso_lite_store_settings',
23 nonce: lassoLiteOptionsData.optionsNonce,
24 settings: settings,
25 };
26
27 // Send the POST request
28 jQuery.post(ajaxurl, data, function (response) {
29 console.log('response', response);
30 });
31
32 go_to_next_step_action(this);
33 }
34 });
35
36 // Check license-If success move to Amazon tab.
37 function active_license_key(){
38 jQuery('#activate-license').click(function(event){
39 event.preventDefault ? event.preventDefault() : (event.returnValue = false);
40 // The loading screen
41 showProgressBar("#license-activation-modal");
42 var license = jQuery('[name = license_serial]').val();
43 var settings = lasso_lite_helper.fetchAllOptions();
44 let current_page = lasso_lite_helper.get_page_name();
45 jQuery.ajax({
46 url:ajax_url,
47 type:'post',
48 data : {
49 action: 'lasso_lite_activate_license',
50 security: lassoLiteOptionsData.optionsNonce,
51 license: license,
52 settings: settings,
53 onboarding: current_page === 'install',
54 },
55 beforeSend:function(xhr){
56 if(jQuery('[name = license_serial]').val() == ""){
57 jQuery("#activate-error label").html('Please enter your license key.');
58 jQuery("#activate-error").collapse();
59 jQuery("#license").addClass("red-border");
60 xhr.abort();
61
62 // Track user enter license key Event
63 lasso_segment_tracking('Lasso User Enters License Key', {
64 license: license
65 });
66 } else {
67 jQuery("#license-activation-modal").modal();
68 }
69 }
70 })
71 .done(function(response) {
72 response = response.data;
73
74 if (typeof response === 'undefined') {
75 return;
76 }
77
78 if(response.status) {
79 jQuery("#license-activation-progress").attr('aria-valuenow', 100).css('width', '100%');
80 setTimeout(function () {
81 jQuery("#license-activation-modal").modal('hide');
82 jQuery("#onboarding_container").removeClass("container-sm");
83 jQuery('#onboarding_container .tab-item').addClass('d-none');
84 jQuery('#onboarding_container div[data-step="theme"]').removeClass('d-none');
85 }, 800);
86
87 window.location.href = "/wp-admin/edit.php?post_type=surl&page=surl-dashboard";
88
89 // Track license key validate successful Event
90 lasso_segment_tracking('Lasso License Key Validated', {
91 license: license
92 });
93
94 } else {
95 jQuery("#license-activation-modal").modal('hide');
96 jQuery("#activate-error label").html(response.error_message);
97 jQuery("#activate-error").collapse();
98 jQuery("#license").addClass("red-border");
99
100 if (typeof APP_ID !== 'undefined' && APP_ID !== 'string' && typeof lassoLiteOptionsData !== 'undefined' ) {
101 APP_ID = lassoLiteOptionsData.app_id;
102 }
103
104 if (Intercom && intercomParams && response.hash != '') {
105 intercomParams['user_hash'] = response.hash;
106 window.intercomSettings = intercomParams;
107 (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/' + APP_ID;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
108 }
109
110 // Track license key validate fail Event
111 lasso_segment_tracking('Lasso License Key Unvalidated', {
112 license: license
113 });
114 }
115 })
116 .fail(function(xhr, msg) {
117 })
118 .always(function () {
119 hideProgressBar("#license-activation-modal");
120 });
121 });
122 }
123
124 /* SEGMENT ANALYTIC */
125 function lasso_segment_tracking( tracking_title, tracking_data = {} ) {
126 try {
127 if ( typeof analytics !== 'undefined') {
128 analytics.track( tracking_title, tracking_data );
129 }
130 } catch (e) {
131 console.log( e );
132 }
133 }
134
135 function showProgressBar(selector){
136 lasso_lite_helper.setProgressZero('.modal');
137 lasso_lite_helper.scrollTop();
138
139 jQuery(selector).modal('show');
140 progressInterval = setInterval(function(){
141 progress();
142 }, 1000)
143 }
144
145 function hideProgressBar(selector){
146 setProgressComplete();
147 setTimeout(function(){
148 jQuery(selector).modal('hide');
149 }, 1000)
150 }
151
152 function setProgressComplete() {
153 progessPercentage = 100;
154 clearProgessInterval();
155 jQuery(".modal").find(".progress-bar").css({width: progessPercentage + '%'});
156 }
157
158 function progress() {
159 if(progessPercentage <=100) {
160 progessPercentage += 25;
161 jQuery(".modal").find(".progress-bar").css({width: progessPercentage + '%'});
162 } else {
163 clearProgessInterval();
164 }
165 }
166
167 function clearProgessInterval() {
168 clearInterval(progressInterval);
169 }
170