Merge pull request #13 from houdiniproject/fix_for_partial_dollar_campaign_amounts
Fix for javascript failures when partial dollars are used for campaign gift levels
This commit is contained in:
commit
7fa0039d14
2 changed files with 5 additions and 1 deletions
|
@ -17,6 +17,10 @@ format.camelToWords = function(str, os) {
|
|||
|
||||
format.dollarsToCents = function(dollars) {
|
||||
dollars = dollars.toString().replace(/[$,]/g, '')
|
||||
if(!isNaN(dollars) && dollars.match(/^-?\d+\.\d$/)) {
|
||||
// could we use toFixed instead? Probably but this is straightforward.
|
||||
dollars = dollars + "0"
|
||||
}
|
||||
if(isNaN(dollars) || !dollars.match(/^-?\d+(\.\d\d)?$/)) throw "Invalid dollar amount: " + dollars
|
||||
return Math.round(Number(dollars) * 100)
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ function showSingleAmount(isRecurring, state) {
|
|||
var desig = state.params$().designation
|
||||
return h('section.u-centered', [
|
||||
h('p.singleAmount-message', [
|
||||
h('strong', app.currency_symbol + state.params$().single_amount)
|
||||
h('strong', app.currency_symbol + format.centsToDollars(format.dollarsToCents(state.params$().single_amount)))
|
||||
, h('span.u-padding--0', { class: {'u-hide': !isRecurring} }, ' monthly')
|
||||
, h('span', {class: {'u-hide': !state.params$().designation && !gift.id}}, [ ' for ' + (desig || gift.name) ])
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue