Donate form: show a clear thank-you panel after a successful donation

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXhhC8xipsBR7e3o76i
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-16 08:21:20 -08:00
1 parent a41ad107a1
commit 565ee0a352
3 files changed
+30 -1

No files matched your search

+5
View File
@@ -53,3 +53,8 @@
.sg-donate .sg-progress [hidden]{display:none}
.sg-donate.sg-progress-only .sg-progress{margin-bottom:0}
@media (prefers-reduced-motion:reduce){.sg-donate .sg-progress-fill{transition:none}}
.sg-donate .sg-thanks{margin:.5rem 0 0;padding:1.1rem 1rem;border:1px solid rgba(26,127,55,.55);border-left-width:4px;border-radius:.4rem;text-align:center}
.sg-donate .sg-thanks:focus{outline:0}
.sg-donate .sg-thanks-title{margin:0 0 .8rem;font-size:1.15em;font-weight:700;line-height:1.4;overflow-wrap:anywhere}
.sg-donate .sg-again{cursor:pointer;min-height:44px}
.sg-donate [hidden]{display:none!important}
+24 -1
View File
@@ -262,6 +262,28 @@
};
}
// Swap the form for a clear confirmation (keeps the progress bar); "Donate again" restores it.
function showThanks(text) {
var hidden = [];
Array.prototype.forEach.call(root.children, function (n) {
if (n === barBox || n.hidden) { return; }
n.hidden = true; hidden.push(n);
});
var again = el('button', { type: 'button', 'class': 'sg-again', text: T.donateAgain || 'Donate again' });
var panel = el('div', { 'class': 'sg-thanks', role: 'status', tabindex: '-1' }, [
el('p', { 'class': 'sg-thanks-title', text: text }),
again
]);
root.appendChild(panel);
try { panel.focus(); panel.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); } catch (e) { /* ignore */ }
again.addEventListener('click', function () {
root.removeChild(panel);
hidden.forEach(function (n) { n.hidden = false; });
msg.value = ''; say('');
refresh(); renderButtons();
});
}
function renderButtons() {
var token = ++state.renderToken;
buttons.textContent = '';
@@ -277,7 +299,8 @@
},
onApprove: function (data) {
return api('/orders/' + encodeURIComponent(data.orderID) + '/capture', { method: 'POST' }).then(function (r) {
say(r.status === 'completed' ? T.thanks : T.processing, 'sg-ok');
say('');
showThanks(r.status === 'completed' ? T.thanks : T.processing);
afterDonation();
});
},
+1
View File
@@ -240,6 +240,7 @@ final class DonateController {
'coverFees' => __( 'Cover the processing fees', 'streamgoals-donate' ),
'total' => __( 'Total you will pay', 'streamgoals-donate' ),
'thanks' => __( 'Thank you for your donation!', 'streamgoals-donate' ),
'donateAgain' => __( 'Donate again', 'streamgoals-donate' ),
'processing' => __( 'Your payment is being processed. Thank you!', 'streamgoals-donate' ),
'error' => __( 'Something went wrong. Please try again.', 'streamgoals-donate' ),
'sdkError' => __( 'Could not load PayPal.', 'streamgoals-donate' ),