# powered-cache/2.0.1/assets/js/admin/modules/toggle.js

Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed &amp; Web Vitals Score, version 2.0.1. 53 lines.

- Page: https://pluginprobe.com/plugins/powered-cache/2.0.1/code/assets/js/admin/modules/toggle.js
- Raw: https://pluginprobe.com/plugins/powered-cache/2.0.1/raw/assets/js/admin/modules/toggle.js
- Modified: 2021-08-26T10:31:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/powered-cache/2.0.1/code/assets/js/admin/modules/toggle.js#L10-L20`.

```javascript
/* global jQuery, PoweredCache  */
/* eslint-disable */

(function ($) {
	// Use strict mode

	// Define global PoweredCache object if it does not exist
	if (typeof window.PoweredCache !== 'object') {
		window.PoweredCache = {};
	}

	PoweredCache.pageToggles = function (page) {
		const body = $('body');
		if (!body.hasClass('toplevel_page_powered-cache')) {
			return;
		}

		function showSettings(element) {
			const settings = $(`#${element.attr('aria-controls')}`);

			element.on('change', function () {
				if (element.is(':checked')) {
					settings.show();
				} else {
					settings.hide();
				}
			});
		}

		function init() {
			const toggles = $('.sui-toggle input[type="checkbox"]');

			toggles.each(function () {
				const toggle = $(this);

				if (undefined !== toggle.attr('aria-controls')) {
					showSettings(toggle);
				}
			});
		}

		init();

		return this;
	};

	$('body').ready(function () {
		PoweredCache.pageToggles('toggles');
	});
})(jQuery);

/* eslint-enable */

```
