Follow mockup for successful form submission

This commit is contained in:
Kelly Dwan 2019-11-20 18:25:38 -05:00
parent 3133f0896a
commit de07108905
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
4 changed files with 28 additions and 16 deletions

View file

@ -93,15 +93,19 @@ jQuery( document ).ready( function( $ ) {
}, },
success( response ) { success( response ) {
if ( response.message ) { if ( response.message ) {
// Say the message for screen reader users.
wp.a11y.speak( response.message );
if ( response.success ) {
closeModal();
$( button ).after( $( '<p>' ).html( '<em>' + response.message + '<em>' ) );
} else {
const $message = $( '<div>' ) const $message = $( '<div>' )
.addClass( 'notice notice-alt' ) .addClass( 'notice notice-alt' )
.addClass( response.success ? 'notice-success' : 'notice-error' ) .addClass( response.success ? 'notice-success' : 'notice-error' )
.append( $( '<p>' ).html( response.message ) ); .append( $( '<p>' ).html( response.message ) );
$( event.target.querySelector( '.message' ) ).html( $message ); $( event.target.querySelector( '.message' ) ).html( $message );
if ( response.success ) {
$( event.target.querySelector( 'input[type="submit"]' ) ).remove();
} }
} }
}, },

View file

@ -270,7 +270,7 @@ function enqueue_assets() {
if ( CPT_ID === get_post_type() ) { if ( CPT_ID === get_post_type() ) {
$ver = filemtime( FiveForTheFuture\PATH . '/assets/js/frontend.js' ); $ver = filemtime( FiveForTheFuture\PATH . '/assets/js/frontend.js' );
wp_enqueue_script( '5ftf-frontend', plugins_url( 'assets/js/frontend.js', __DIR__ ), [ 'jquery', 'wp-util', 'wicg-inert' ], $ver, true ); wp_enqueue_script( '5ftf-frontend', plugins_url( 'assets/js/frontend.js', __DIR__ ), [ 'jquery', 'wp-a11y', 'wp-util', 'wicg-inert' ], $ver, true );
$script_data = [ $script_data = [
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), // The global ajaxurl is not set on the frontend. 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), // The global ajaxurl is not set on the frontend.

View file

@ -31,7 +31,7 @@ defined( 'WPINC' ) || die();
value="" value=""
/> />
<div class="message" role="alert" aria-atomic="true"></div> <div class="message"></div>
<input <input
type="submit" type="submit"

View file

@ -63,7 +63,14 @@ body.single.single-5ftf_pledge {
} }
} }
.edit-pledge-wrapper .button { .edit-pledge-wrapper {
text-align: right;
p {
font-size: ms(-2);
}
.button {
padding-right: 4px; padding-right: 4px;
text-decoration: none; text-decoration: none;
color: $color__wp-blue; color: $color__wp-blue;
@ -73,6 +80,7 @@ body.single.single-5ftf_pledge {
border-bottom: 1px solid currentColor; border-bottom: 1px solid currentColor;
} }
} }
}
@include breakpoint( $breakpoint-tablet ) { @include breakpoint( $breakpoint-tablet ) {
display: flex; display: flex;