admin_bar_menu.js
4 years ago
bootstrap.bundle.min.js
4 years ago
bootstrap.min.js
6 years ago
gravity_forms.js
3 years ago
math_captcha.js
3 years ago
metabox.js
6 years ago
np_notices.js
3 years ago
np_safemode.js
4 years ago
overlay.js
6 years ago
popper.min.js
4 years ago
widgets_ajax.js
3 years ago
np_safemode.js
72 lines
| 1 | (function ($) { |
| 2 | $(window).on("load", function () { |
| 3 | let deactivateLink = 'tr[data-slug="nitropack"] #deactivate-nitropack'; |
| 4 | let deactivateLinkUrl = $(deactivateLink).attr('href'); |
| 5 | |
| 6 | $(deactivateLink).parent().append($('#nitropack-safemode-popup')); |
| 7 | |
| 8 | |
| 9 | $(deactivateLink).on('click', function (e) { |
| 10 | e.preventDefault(); |
| 11 | $('#nitropack-safemode-veil').show(); |
| 12 | $('#nitropack-safemode-popup').show(); |
| 13 | let ref1 = $(window).scrollTop()+$(window).height(); |
| 14 | let ref2 = $('#nitropack-safemode-popup').offset().top + $('#nitropack-safemode-popup').outerHeight(true); |
| 15 | if (ref2 > ref1) { |
| 16 | $('html,body').animate({scrollTop: $('#nitropack-safemode-popup').offset().top - ($(window).height() - $('#nitropack-safemode-popup').outerHeight(true) - 10)}, 200); |
| 17 | } |
| 18 | |
| 19 | $('#nitropack-safemode-veil').on('click', function () { |
| 20 | $('#nitropack-safemode-popup').hide(); |
| 21 | $('#nitropack-safemode-veil').hide(); |
| 22 | }); |
| 23 | }); |
| 24 | |
| 25 | $('#np-safemode-nogo').on('click', function (e) { |
| 26 | e.preventDefault(); |
| 27 | e.stopPropagation(); |
| 28 | $(deactivateLink).unbind('click'); |
| 29 | $('#nitropack-safemode-popup').hide(); |
| 30 | $('#nitropack-safemode-popup').remove(); |
| 31 | if (deactivateLinkUrl !== '') {location.href = deactivateLinkUrl;} |
| 32 | }); |
| 33 | |
| 34 | $('#np-safemode-go').on('click', function (e) { |
| 35 | e.preventDefault(); |
| 36 | e.stopPropagation(); |
| 37 | $(deactivateLink).unbind('click'); |
| 38 | |
| 39 | $.ajax({ |
| 40 | url: ajaxurl, |
| 41 | type: 'POST', |
| 42 | data: {action: 'nitropack_enable_safemode'}, |
| 43 | beforeSend: function () { |
| 44 | $('#nitropack-safemode-popup').height($('#np-safemode-content').height()); |
| 45 | $('#np-safemode-content').hide(); |
| 46 | $('#np-safemode-loader-loading').show(); |
| 47 | }, |
| 48 | success: function (response) { |
| 49 | $('#np-safemode-loader-loading').hide(); |
| 50 | let responseResult = JSON.parse(response); |
| 51 | if (responseResult.type === 'success') { |
| 52 | $('#np-safemode-loader-success').show(); |
| 53 | } else { |
| 54 | $('#np-safemode-loader-error').show(); |
| 55 | } |
| 56 | }, |
| 57 | error: function () { |
| 58 | $('#np-safemode-loader-loading').hide(); |
| 59 | $('#np-safemode-loader-error').show(); |
| 60 | }, |
| 61 | complete: function() { |
| 62 | setTimeout(function(){ |
| 63 | $('#np-safemode-loader-success').hide(); |
| 64 | $('#np-safemode-loader-error').hide(); |
| 65 | $('#nitropack-safemode-popup').remove(); |
| 66 | $('#nitropack-safemode-veil').hide(); |
| 67 | }, 1500); |
| 68 | } |
| 69 | }); |
| 70 | }); |
| 71 | }); |
| 72 | })(jQuery); |