/**
 * Getting Started
 */
jQuery( document ).ready(
	function ( $ ) {

		$( '.wisnia-gsm-btn' ).click(
			function ( e ) {
				e.preventDefault();

				// Show updating gif icon.
				$( this ).addClass( 'updating-message' );

				// Change button text.
				$( this ).text( wisnia_adi_install.btn_text );

				$.ajax(
					{
						type: "POST",
						url: ajaxurl,
						async:false,
						data: {
							action : 'wisnia_getting_started',
							security : wisnia_adi_install.nonce
							},
						success:function( response ) {
							var extra_uri, redirect_uri, dismiss_nonce;

							if ( $( '.wisnia-gsm-close' ).length ) {
									dismiss_nonce = $( '.wisnia-gsm-close' ).attr( 'href' ).split( 'wisnia_gsm_admin_notice_nonce=' )[1];
									extra_uri     = '&wisnia_gsm_admin_notice_nonce=' + dismiss_nonce;
								}
									setTimeout( function() {
										redirect_uri         = 'themes.php?page=pt-one-click-demo-import&wisnia-gsm-hide-notice=welcome';
										window.location.href = redirect_uri + extra_uri;
								}, 5000);
						},
						error: function( xhr, ajaxOptions, thrownError ){
							console.log( thrownError );
						}
					}
				);
			}); // End of click action
		$( '.cwp-card-header a' ).click(
			function ( e ) {
				e.preventDefault();
				let thisLink = $( this ),
				cwpHref      = thisLink.attr( 'href' );
				$( '.cwp-card-body-wrap' ).addClass( 'hidden' );
				$( cwpHref ).removeClass( 'hidden' );
			}
		);

	}
);
