jQuery(document).ready(function($) {
	'use strict';

	$('.smac-refresh-widget').on('click', function() {
		var $btn = $(this);
		$btn.prop('disabled', true).find('.dashicons').addClass('spin');

		$.ajax({
			url: ajaxurl,
			type: 'POST',
			data: {
				action: 'specflux_mac_refresh_widget',
				nonce: specfluxMacDashboardWidget.nonce
			},
			success: function() {
				location.reload();
			},
			error: function() {
				$btn.prop('disabled', false).find('.dashicons').removeClass('spin');
			}
		});
	});
});
