/**
 * Admin UI for Frontierline Forms free build.
 *
 * @package CF7MasterPro
 */
( function ( $ ) {
	'use strict';

	var cfg = window.cf7mpAdmin || {};

	$( function () {
		$( document ).on( 'click', '.cf7mp-submission-list__row', function ( e ) {
			if ( 'A' === e.target.tagName || 'BUTTON' === e.target.tagName ) {
				return;
			}
			var url = this.getAttribute( 'data-detail-url' );
			if ( url ) {
				window.location.href = url;
			}
		} );

		$( document ).on( 'click', '.cf7mp-dismiss', function ( e ) {
			e.preventDefault();
			var $link  = $( this );
			var notice = $link.data( 'notice' );
			$.post( cfg.ajaxUrl, {
				action: 'cf7mp_dismiss_notice',
				notice: notice,
				_wpnonce: cfg.dismissNonce
			} );
			$link.closest( '.notice' ).fadeOut();
		} );
		// レビューCTA: 新規タブ遷移は妨げず既読化のみ
		$( document ).on( 'click', '.cf7mp-review-cta', function () {
			$.post( cfg.ajaxUrl, {
				action: 'cf7mp_dismiss_notice',
				notice: $( this ).data( 'notice' ),
				_wpnonce: cfg.dismissNonce
			} );
		} );
	} );
}( jQuery ) );
