# essential-widgets/2.0/admin/js/admin-scripts.js

Essential Widgets, version 2.0. 102 lines.

- Page: https://pluginprobe.com/plugins/essential-widgets/2.0/code/admin/js/admin-scripts.js
- Raw: https://pluginprobe.com/plugins/essential-widgets/2.0/raw/admin/js/admin-scripts.js
- Modified: 2022-02-24T22:32:48+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/essential-widgets/2.0/code/admin/js/admin-scripts.js#L10-L20`.

```javascript
(function ($) {
	'use strict';

	$(function () {
		/* For Input Switch */
		$('.input-switch').on('click', function () {
			var loader = $(this).parent().next();

			loader.show();

			var main_control = $(this);
            var ew_nonce = main_control.prev('input').val();
			var data = {
				action: 'ew_switch',
				value: this.checked,
                security: ew_nonce,
				option_name: main_control.attr('rel'),
			};

			$.post(ajaxurl, data, function (response) {
				response = $.trim(response);

				if ('1' == response) {
					main_control.parent().parent().addClass('active');
					main_control.parent().parent().removeClass('inactive');
				} else if ('0' == response) {
					main_control.parent().parent().addClass('inactive');
					main_control.parent().parent().removeClass('active');
				} else {
					alert(response);
				}

				loader.hide();
			});
		});
		/* For Input Switch End */
	});

	$(function () {
		// Tabs
		$('.catchp_widget_settings .nav-tab-wrapper a').on(
			'click',
			function (e) {
				e.preventDefault();

				if (!$(this).hasClass('ui-state-active')) {
					$('.nav-tab').removeClass('nav-tab-active');
					$('.wpcatchtab').removeClass('active').fadeOut(0);

					$(this).addClass('nav-tab-active');

					var anchorAttr = $(this).attr('href');

					$(anchorAttr).addClass('active').fadeOut(0).fadeIn(500);
				}
			}
		);
	});

	// jQuery Match Height init for sidebar spots
	$(document).ready(function () {
		$(
			'.catchp-sidebar-spot .sidebar-spot-inner, .col-2 .catchp-lists li, .col-3 .catchp-lists li, .catch-modules'
		).matchHeight();
	});

	$(function () {
		/* CPT switch */
		$('.ctp-switch').on('click', function () {
			var loader = $(this).parent().next();

			loader.show();

			var main_control = $(this);
			var ew_switch_tabs_nonce = main_control.prev('input').val();
			var data = {
				action: 'ctp_switch',
				value: this.checked,
				security: ew_switch_tabs_nonce,
				option_name: main_control.attr('rel'),
			};

			$.post(ajaxurl, data, function (response) {
				console.log('asdfsdf');
				response = $.trim(response);

				if ('1' == response) {
					main_control.parent().parent().addClass('active');
					main_control.parent().parent().removeClass('inactive');
				} else if ('0' == response) {
					main_control.parent().parent().addClass('inactive');
					main_control.parent().parent().removeClass('active');
				} else {
					alert(response);
				}
				loader.hide();
			});
		});
		/* CPT switch End */
	});
})(jQuery);

```
