| 1 |
(function($) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
$(document).on('click', '[data-slug="poll-maker"] .deactivate a', function () { |
| 5 |
swal({ |
| 6 |
html: "<h2>Do you want to upgrade to Pro version or permanently delete the plugin?</h2><ul><li>Upgrade: Your data will be saved for upgrade.</li><li>Deactivate: Your data will be deleted completely.</li></ul>", |
| 7 |
footer: '<a href="" class="ays-poll-temporary-deactivation">Temporary deactivation</a>', |
| 8 |
type: 'question', |
| 9 |
showCancelButton: true, |
| 10 |
showCloseButton: true, |
| 11 |
allowOutsideClick: false, |
| 12 |
allowEscapeKey: false, |
| 13 |
allowEnterKey: false, |
| 14 |
confirmButtonColor: '#3085d6', |
| 15 |
cancelButtonColor: '#d33', |
| 16 |
confirmButtonText: 'Upgrade', |
| 17 |
cancelButtonText: 'Deactivate', |
| 18 |
confirmButtonClass: "ays-poll-upgrade-button", |
| 19 |
cancelButtonClass: "ays-poll-cancel-button", |
| 20 |
customClass: ".ays-poll-deactivate-popup", |
| 21 |
}).then((result) => { |
| 22 |
let upgrade_plugin = false; |
| 23 |
if (result.value) upgrade_plugin = true; |
| 24 |
|
| 25 |
if( result.dismiss && result.dismiss == 'close' ){ |
| 26 |
return false; |
| 27 |
} |
| 28 |
|
| 29 |
var wp_nonce = $(document).find('#ays_poll_maker_ajax_deactivate_plugin_nonce').val(); |
| 30 |
|
| 31 |
let data = { |
| 32 |
action: 'apm_deactivate_plugin_option_pm', |
| 33 |
upgrade_plugin, |
| 34 |
_ajax_nonce: wp_nonce, |
| 35 |
}; |
| 36 |
$.ajax({ |
| 37 |
url: apm_admin_ajax_obj.ajaxUrl, |
| 38 |
method: "post", |
| 39 |
dataType: 'json', |
| 40 |
data, |
| 41 |
success() { |
| 42 |
location.replace($('[data-slug="poll-maker"] .deactivate a').attr('href')) |
| 43 |
} |
| 44 |
}); |
| 45 |
}); |
| 46 |
return false; |
| 47 |
}); |
| 48 |
|
| 49 |
$(document).on('click', '.ays-poll-temporary-deactivation', function (e) { |
| 50 |
e.preventDefault(); |
| 51 |
|
| 52 |
$(document).find('.ays-poll-upgrade-button').trigger('click'); |
| 53 |
|
| 54 |
}); |
| 55 |
|
| 56 |
$('.ays-poll-upgrade-plugin-btn').hover( |
| 57 |
function() { |
| 58 |
$(this).css('color', '#3B8D3F'); |
| 59 |
}, |
| 60 |
function() { |
| 61 |
$(this).css('color', '#01A32A'); |
| 62 |
} |
| 63 |
); |
| 64 |
|
| 65 |
})(jQuery); |