| @@ -59,9 +59,12 @@ | ||
| 59 | 59 | window.location.href = response.data.redirect_url; |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - showNotification( response.data.error.message, 'error' ); | |
| 63 | + // A toast that stands in for a hidden success message stays until | |
| 64 | + // the visitor closes it — otherwise the form is left saying | |
| 65 | + // nothing at all after ten seconds. | |
| 66 | + showNotification( response.data.error.message, 'error', !! response.data.error.hide_confirmation ); | |
| 64 | 67 | |
| 65 | 68 | // Prevent duplicate checks for 5 seconds |
| 66 | 69 | cooldown = true; |
| 67 | 70 | setTimeout( function () { |
| @@ -125,11 +128,12 @@ | ||
| 125 | 128 | /** |
| 126 | 129 | * Show a toast notification. |
| 127 | 130 | * |
| 128 | 131 | * @param {string} message The message to display. |
| 129 | - * @param {string} [type] 'error' (default) or 'success' — controls colour + icon. | |
| 132 | + * @param {string} [type] 'error' (default) or 'success' — controls colour + icon. | |
| 133 | + * @param {boolean} [sticky] Keep it until the visitor closes it. | |
| 130 | 134 | */ |
| 131 | - function showNotification( message, type ) { | |
| 135 | + function showNotification( message, type, sticky ) { | |
| 132 | 136 | type = type === 'success' ? 'success' : 'error'; |
| 133 | 137 | |
| 134 | 138 | var existing = document.querySelector( '.doi-error-notification' ); |
| 135 | 139 | if ( existing ) { |
| @@ -172,8 +176,12 @@ | ||
| 172 | 176 | // Trigger enter animation |
| 173 | 177 | requestAnimationFrame( function () { |
| 174 | 178 | notification.classList.add( 'doi-error-notification--visible' ); |
| 175 | 179 | } ); |
| 180 | + | |
| 181 | + if ( sticky ) { | |
| 182 | + return; | |
| 183 | + } | |
| 176 | 184 | |
| 177 | 185 | // Auto-dismiss after 10 seconds |
| 178 | 186 | setTimeout( function () { |
| 179 | 187 | dismiss( notification ); |