| 1 |
jQuery(function($){ |
| 2 |
// This is a temporary addition. Remove along with Main.php summer 2021 |
| 3 |
$('#the-list').find('[data-plugin="order-tracking/Main.php"]').hide(); |
| 4 |
|
| 5 |
var $deactivateLink = $('#the-list').find('[data-slug="order-tracking"] span.deactivate a'), |
| 6 |
$overlay = $('#ewd-otp-deactivate-survey-order-tracking'), |
| 7 |
$form = $overlay.find('form'), |
| 8 |
formOpen = false; |
| 9 |
// Plugin listing table deactivate link. |
| 10 |
$deactivateLink.on('click', function(event) { |
| 11 |
event.preventDefault(); |
| 12 |
$overlay.css('display', 'table'); |
| 13 |
formOpen = true; |
| 14 |
$form.find('.ewd-otp-deactivate-survey-option:first-of-type input[type=radio]').focus(); |
| 15 |
}); |
| 16 |
// Survey radio option selected. |
| 17 |
$form.on('change', 'input[type=radio]', function(event) { |
| 18 |
event.preventDefault(); |
| 19 |
$form.find('input[type=text], .error').hide(); |
| 20 |
$form.find('.ewd-otp-deactivate-survey-option').removeClass('selected'); |
| 21 |
$(this).closest('.ewd-otp-deactivate-survey-option').addClass('selected').find('input[type=text]').show(); |
| 22 |
}); |
| 23 |
// Survey Skip & Deactivate. |
| 24 |
$form.on('click', '.ewd-otp-deactivate-survey-deactivate', function(event) { |
| 25 |
event.preventDefault(); |
| 26 |
location.href = $deactivateLink.attr('href'); |
| 27 |
}); |
| 28 |
// Survey submit. |
| 29 |
$form.submit(function(event) { |
| 30 |
event.preventDefault(); |
| 31 |
if (! $form.find('input[type=radio]:checked').val()) { |
| 32 |
$form.find('.ewd-otp-deactivate-survey-footer').prepend('<span class="error">Please select an option below</span>'); |
| 33 |
return; |
| 34 |
} |
| 35 |
var data = { |
| 36 |
code: $form.find('.selected input[type=radio]').val(), |
| 37 |
install_time: $form.data('installtime'), |
| 38 |
reason: $form.find('.selected .ewd-otp-deactivate-survey-option-reason').text(), |
| 39 |
details: $form.find('.selected input[type=text]').val(), |
| 40 |
site: ewd_otp_deactivation_data.site_url, |
| 41 |
plugin: 'Order Tracking' |
| 42 |
} |
| 43 |
var submitSurvey = $.post('https://www.etoilewebdesign.com/UPCP-Key-Check/Deactivation_Surveys.php', data); |
| 44 |
submitSurvey.always(function() { |
| 45 |
location.href = $deactivateLink.attr('href'); |
| 46 |
}); |
| 47 |
}); |
| 48 |
// Exit key closes survey when open. |
| 49 |
$(document).keyup(function(event) { |
| 50 |
if (27 === event.keyCode && formOpen) { |
| 51 |
$overlay.hide(); |
| 52 |
formOpen = false; |
| 53 |
$deactivateLink.focus(); |
| 54 |
} |
| 55 |
}); |
| 56 |
}); |