PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 3.6.3
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v3.6.3
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 / modules / toggle.js

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

53 lines 997 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global jQuery, PoweredCache */
2 /* eslint-disable */
3
4 (function ($) {
5 // Use strict mode
6
7 // Define global PoweredCache object if it does not exist
8 if (typeof window.PoweredCache !== 'object') {
9 window.PoweredCache = {};
10 }
11
12 PoweredCache.pageToggles = function (page) {
13 const body = $('body');
14 if (!body.hasClass('toplevel_page_powered-cache')) {
15 return;
16 }
17
18 function showSettings(element) {
19 const settings = $(`#${element.attr('aria-controls')}`);
20
21 element.on('change', function () {
22 if (element.is(':checked')) {
23 settings.show();
24 } else {
25 settings.hide();
26 }
27 });
28 }
29
30 function init() {
31 const toggles = $('.sui-toggle input[type="checkbox"]');
32
33 toggles.each(function () {
34 const toggle = $(this);
35
36 if (undefined !== toggle.attr('aria-controls')) {
37 showSettings(toggle);
38 }
39 });
40 }
41
42 init();
43
44 return this;
45 };
46
47 $('body').ready(function () {
48 PoweredCache.pageToggles('toggles');
49 });
50 })(jQuery);
51
52 /* eslint-enable */
53