jQuery( document ).ready( function( $ ) {

	// Save tab notifications
	$( document ).on( 'click', '.js-save-tab-notifications-button', function( e ) {
		e.preventDefault();

		var $this = $( this );

		// Add loader
		$( '<span class="spinner compiler-colours-spinner" style="visibility: visible; float: initial;"></span>' ).insertBefore( '.save-tab-notifications' );

		// Remove the other options
		$( '.notification-wrapper:not(.active)' ).remove();

		// Subit the tab form
		setTimeout( function() {
			$this.parents( 'form' ).submit();
		}, 1000 );
	});

	// Trigger tab notifications
	$( document ).on( 'click', '.js-save-tab-notifications-trigger', function( e ) {
		e.preventDefault();
		$( '.notification-wrapper.active' ).find( '.js-save-tab-notifications-button' ).trigger( 'click' );
	});

	// Trigger all notifications
	$( document ).on( 'click', '.js-save-all-notifications-trigger', function( e ) {
		e.preventDefault();
		$( '.js-save-all-notifications-button' ).trigger( 'click' );
	});

});