jQuery(document).ready(function($) {
	var isBulkUpdate = false;

	$( "tr" ).each(function( index ) {
		if ( $(this).attr('data-slug') === 'wpcasa-admin-map-ui' ) {
			$(this).find('.activate').css('display', 'none');
		}

		if ( $(this).attr('data-slug') === 'wpcasa-listings-map' ) {
			$(this).find('.activate').css('display', 'none');
		}
	});

	$( document ).on( 'wp-plugin-bulk-update-selected', function( event, checked ) {
		isBulkUpdate = checked && checked.length > 1;
	});

	$( '#bulk-action-form' ).on( 'click', '[data-plugin] .update-link', function() {
		isBulkUpdate = false;
	});

	$( document ).on( 'wp-plugin-update-success', function( event, response ) {
		if ( isBulkUpdate || ! window.wpsightPluginsAdmin || ! response || response.plugin !== window.wpsightPluginsAdmin.pluginFile ) {
			return;
		}

		window.location.href = window.wpsightPluginsAdmin.updatePageUrl;
	});

});
