PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 2.0.2
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v2.0.2
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
powered-cache / assets / js / admin / admin.js

admin.js in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 2.0.2, at assets/js/admin/admin.js

97 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global jQuery */
2 import '@wpmudev/shared-ui/dist/js/_src/modal-dialog';
3 import './modules/nav';
4 import './modules/toggle';
5 import './modules/modal';
6
7 (function ($) {
8 let zone_index = 0;
9
10 $('.add_cdn_hostname').click(function (e) {
11 e.preventDefault();
12 let ref_el = $('.cdn-zone:first').clone();
13
14 if (zone_index === 0) {
15 zone_index = $('.cdn-zone').length;
16 } else {
17 zone_index++;
18 }
19
20 ref_el = $(ref_el).attr('id', `cdn-zone-${zone_index}`);
21 $(ref_el).find('.cdn_hostname').val('');
22 $(ref_el).find('.cdn_zone').prop('selectedIndex', 0);
23
24 $(ref_el).find('button').removeClass('sui-hidden-important');
25
26 $('#cdn-zones').append(ref_el);
27 });
28
29 $('#cdn-zones').on('click', '.remove_cdn_hostname', function () {
30 const target_node = $(this).parents('.cdn-zone');
31 if (target_node.attr('id') === 'cdn-zone-0') {
32 alert('Nice try :) This zone cannot be removed!');
33 return false;
34 }
35
36 target_node.remove();
37 return true;
38 });
39
40 // toggle sitemap options based on cache preloading
41 $('#enable_cache_preload').on('change', function () {
42 if ($(this).is(':checked')) {
43 $('#enable_sitemap_preload_wrapper').show();
44 } else {
45 $('#enable_sitemap_preload_wrapper').hide();
46 }
47 });
48
49 $('#enable_page_cache').on('change', function () {
50 if ($(this).is(':checked')) {
51 $('#preload_page_cache_warning_message').hide();
52 } else {
53 $('#preload_page_cache_warning_message').show();
54 }
55 });
56
57 $('.heartbeat_dashboard_status').on('change', function () {
58 if ($(this).val() === 'modify') {
59 $('#heartbeat-dashboard-interval').show();
60 } else {
61 $('#heartbeat-dashboard-interval').hide();
62 }
63 });
64
65 $('.heartbeat_radio').on('change', function () {
66 const targetInput = $(this).attr('aria-controls');
67
68 if (!targetInput) {
69 return;
70 }
71
72 if ($(this).val() === 'modify') {
73 $(`#${targetInput}`).show();
74 } else {
75 $(`#${targetInput}`).hide();
76 }
77 });
78
79 $('#powered-cache-import-file-input').on('change', function () {
80 const elm = $(this)[0];
81 if (elm.files.length) {
82 const file = elm.files[0];
83 $('#powered-cache-import-file-name').text(file.name);
84 $('#powered-cache-import-upload-wrap').addClass('sui-has_file');
85 $('#powered-cache-import-btn').removeAttr('disabled');
86 } else {
87 $('#powered-cache-import-file-name').text('');
88 $('#powered-cache-import-upload-wrap').removeClass('sui-has_file');
89 $('#powered-cache-import-btn').attr('disabled', 'disabled');
90 }
91 });
92
93 $('#powered-cache-import-remove-file').on('click', function () {
94 $('#powered-cache-import-file-input').val('').trigger('change');
95 });
96 })(jQuery);
97