| 1 |
jQuery(document).ready(function() { |
| 2 |
setTimeout(function () { |
| 3 |
jQuery('#fake-intercom-bubble-chat').css('opacity', 1); |
| 4 |
}, 2000); |
| 5 |
|
| 6 |
jQuery(document) |
| 7 |
.on('click', '#enable-support-wrapper .dismiss', function () { |
| 8 |
jQuery("#enable-support").modal('hide'); |
| 9 |
lasso_lite_helper.set_local_storage('lasso_lite_should_open_support_modal', 0); |
| 10 |
}) |
| 11 |
.on('click', '#btn-save-support', save_support ) |
| 12 |
.on('click', '#fake-intercom-bubble-chat', function () { |
| 13 |
jQuery("#enable-support").modal('show'); |
| 14 |
}) |
| 15 |
.ready(function () { |
| 16 |
update_support(); |
| 17 |
}); |
| 18 |
|
| 19 |
function save_support() { |
| 20 |
let btn_save = jQuery('#btn-save-support'); |
| 21 |
let js_error = jQuery('#enable-support-wrapper .js-error'); |
| 22 |
let email = jQuery('#enable-support-wrapper #email').val().trim(); |
| 23 |
let is_subscribe = jQuery('#enable-support-wrapper #subscribe').prop("checked"); |
| 24 |
if ( email !== '' ) { |
| 25 |
jQuery.ajax({ |
| 26 |
url: lassoLiteOptionsData.ajax_url, |
| 27 |
type: 'post', |
| 28 |
data: { |
| 29 |
action: 'lasso_lite_save_support', |
| 30 |
email: email, |
| 31 |
is_subscribe: is_subscribe, |
| 32 |
}, |
| 33 |
beforeSend: function() { |
| 34 |
jQuery('#enable-support-wrapper #email').removeClass('invalid-field'); |
| 35 |
js_error.css('display', 'none'); |
| 36 |
lasso_lite_helper.add_loading_button(btn_save); |
| 37 |
} |
| 38 |
}).done(function(res) { |
| 39 |
lasso_lite_helper.add_loading_button(btn_save, 'Enable Support', false); |
| 40 |
let data = res.data; |
| 41 |
if ( data.success ) { |
| 42 |
jQuery("#enable-support").modal('hide'); |
| 43 |
|
| 44 |
// Auto open customization display helper after enabling support |
| 45 |
if ( 'undefined' !== typeof window.need_more_customization_flag ) { |
| 46 |
lasso_lite_helper.set_local_storage('lasso_lite_open_need_more_customization', 1); |
| 47 |
} |
| 48 |
|
| 49 |
// Go to next step if we are in Welcome page |
| 50 |
if ( 'surl-onboarding' === lasso_lite_helper.get_page_name() ) { |
| 51 |
go_to_next_step_action(btn_save); |
| 52 |
} else { |
| 53 |
location.reload(); |
| 54 |
} |
| 55 |
} else { |
| 56 |
jQuery('#enable-support-wrapper #email').addClass('invalid-field'); |
| 57 |
js_error.text(data.msg); |
| 58 |
js_error.css('display', 'block'); |
| 59 |
} |
| 60 |
}) |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
function update_support() { |
| 65 |
jQuery('input[name="enable_support"]').change(lasso_lite_helper.debounce(function(e) { |
| 66 |
let enable_support = jQuery('input[name="enable_support"]').prop('checked'); |
| 67 |
jQuery.ajax({ |
| 68 |
url: lassoLiteOptionsData.ajax_url, |
| 69 |
type: 'post', |
| 70 |
data: { |
| 71 |
action: 'lasso_lite_update_support', |
| 72 |
enable_support: enable_support, |
| 73 |
} |
| 74 |
}); |
| 75 |
}, 1000, null, true)); |
| 76 |
} |
| 77 |
}); |