Commit 144d3bcb authored by Aral Balkan's avatar Aral Balkan

Improve custom amount control

parent 0f8a976f
...@@ -22,6 +22,8 @@ class PatronageForm { ...@@ -22,6 +22,8 @@ class PatronageForm {
constructor () { constructor () {
window.addEventListener('load', this.setInitialInterfaceState.bind(this)) window.addEventListener('load', this.setInitialInterfaceState.bind(this))
// TODO: Set key based on hostname.
this.stripe = Stripe('pk_test_mLQRpGuO7qq3XMfSgwmt4n8U00FSZOIY1h') this.stripe = Stripe('pk_test_mLQRpGuO7qq3XMfSgwmt4n8U00FSZOIY1h')
} }
...@@ -57,6 +59,10 @@ class PatronageForm { ...@@ -57,6 +59,10 @@ class PatronageForm {
element.addEventListener('change', updateFormState) element.addEventListener('change', updateFormState)
}) })
// Ensure that selecting either the button or the text input focuses the custom
// amount control and that focus is not lost when person clicks on already-selected control.
this.interface.otherDonationAmountRadioButton.addEventListener('click', updateFormState)
this.interface.otherDonationAmountTextInput.addEventListener('click', updateFormState)
this.interface.otherDonationAmountTextInput.addEventListener('focus', updateFormState) this.interface.otherDonationAmountTextInput.addEventListener('focus', updateFormState)
this.interface.otherDonationAmountTextInput.addEventListener('input', updateFormState) this.interface.otherDonationAmountTextInput.addEventListener('input', updateFormState)
...@@ -82,6 +88,8 @@ class PatronageForm { ...@@ -82,6 +88,8 @@ class PatronageForm {
// Updates form state in response to interface events. // Updates form state in response to interface events.
updateFormState () { updateFormState () {
console.log('<<< update form state >>>')
// Handle the label of the submit button based on the type of donation. // Handle the label of the submit button based on the type of donation.
this.interface.submitButton.innerHTML = this.isPatronage ? 'Become a patron' : 'Donate' this.interface.submitButton.innerHTML = this.isPatronage ? 'Become a patron' : 'Donate'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment