admin_bar_menu.js
1 year ago
flowbite.min.js
2 years ago
gravity_forms.js
3 years ago
math_captcha.js
3 years ago
metabox.js
2 years ago
nitropackUI.js
2 years ago
np_notices.js
1 year ago
np_safemode.js
2 years ago
np_settings.js
2 years ago
popper.min.js
4 years ago
widgets_ajax.js
3 years ago
admin_bar_menu.js
87 lines
| 1 | jQuery(window).on("load", _ => { |
| 2 | const loading_icon = '<img src="' + frontendajax.nitro_plugin_url + '/view/images/loading.svg" width="14" class="icon loading"/>'; |
| 3 | |
| 4 | function clearCacheSingleHandler(clearCacheAction, elem) { |
| 5 | jQuery.ajax({ |
| 6 | url: frontendajax.ajaxurl, |
| 7 | type: 'POST', |
| 8 | data: { |
| 9 | action: "nitropack_" + clearCacheAction + "_single_cache", |
| 10 | postUrl: window.location.href.split('#')[0], |
| 11 | postId: -1, |
| 12 | nonce: frontendajax.nitroNonce |
| 13 | }, |
| 14 | dataType: 'json', |
| 15 | beforeSend: function () { |
| 16 | if (!elem.find('.icon').length) { |
| 17 | elem.find('a').first().append(loading_icon); |
| 18 | } else { |
| 19 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/loading.svg') |
| 20 | elem.find('.icon').addClass('loading').removeClass('error success'); |
| 21 | } |
| 22 | }, |
| 23 | success: function (data) { |
| 24 | if (data.type == 'error') { |
| 25 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/x-mark.svg'); |
| 26 | elem.find('.icon').addClass('error'); |
| 27 | alert(data.message); |
| 28 | } else { |
| 29 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/check.svg'); |
| 30 | } |
| 31 | elem.find('.icon').removeClass('loading'); |
| 32 | } |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | function clearCacheEntireHandler(clearCacheAction, elem) { |
| 37 | jQuery.ajax({ |
| 38 | url: frontendajax.ajaxurl, |
| 39 | type: 'POST', |
| 40 | data: { |
| 41 | action: "nitropack_" + clearCacheAction + "_entire_cache", |
| 42 | nonce: frontendajax.nitroNonce |
| 43 | }, |
| 44 | dataType: 'json', |
| 45 | beforeSend: function () { |
| 46 | if (!elem.find('.icon').length) { |
| 47 | elem.find('a').first().append(loading_icon); |
| 48 | } else { |
| 49 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/loading.svg') |
| 50 | elem.find('.icon').addClass('loading').removeClass('error success'); |
| 51 | } |
| 52 | }, |
| 53 | success: function (data) { |
| 54 | if (data.type == 'error') { |
| 55 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/x-mark.svg'); |
| 56 | elem.find('.icon').addClass('error'); |
| 57 | alert(data.message); |
| 58 | } else { |
| 59 | elem.find('.icon').attr('src', frontendajax.nitro_plugin_url + 'view/images/check.svg') |
| 60 | elem.find('.icon').addClass('success'); |
| 61 | } |
| 62 | elem.find('.icon').removeClass('loading'); |
| 63 | } |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | jQuery('.nitropack-invalidate-cache').click(function (e) { |
| 68 | e.preventDefault(); |
| 69 | clearCacheSingleHandler("invalidate", jQuery(this)) |
| 70 | return false; |
| 71 | }); |
| 72 | |
| 73 | jQuery('.nitropack-purge-cache').click(function (e) { |
| 74 | e.preventDefault(); |
| 75 | clearCacheSingleHandler("purge", jQuery(this)) |
| 76 | return false; |
| 77 | }); |
| 78 | |
| 79 | jQuery('.nitropack-purge-cache-entire-site').click(function (e) { |
| 80 | e.preventDefault(); |
| 81 | clearCacheEntireHandler("purge", jQuery(this)) |
| 82 | return false; |
| 83 | }); |
| 84 | |
| 85 | }); |
| 86 | |
| 87 |