mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Refactor PrepaidView to use new event callback naming guideline
See: https://github.com/codecombat/codecombat/wiki/Events,-subscriptions,-shortcuts#events
This commit is contained in:
parent
cef4fc0794
commit
452e6467b4
3 changed files with 20 additions and 20 deletions
|
@ -1,3 +1,3 @@
|
|||
|
||||
#users, #months
|
||||
#users-input, #months-input
|
||||
max-width: 100px
|
|
@ -30,17 +30,17 @@ block content
|
|||
.form-group
|
||||
label.control-label.col-md-2(for="users") Users
|
||||
.col-md-2
|
||||
input#users.form-control(name="users", type="number", value="#{purchase.users}", min=1)
|
||||
input#users-input.form-control(name="users", type="number", value="#{purchase.users}", min=1)
|
||||
.form-group
|
||||
label.control-label.col-md-2(for="months") Months
|
||||
.col-md-2
|
||||
input#months.form-control(name="months", type="number", value="#{purchase.months}", min=1)
|
||||
input#months-input.form-control(name="months", type="number", value="#{purchase.months}", min=1)
|
||||
.form-group
|
||||
label.control-label.col-md-2(data-i18n="account_prepaid.purchase_total")
|
||||
.col-md-10
|
||||
p.form-control-static $
|
||||
span#total #{purchase.total.toFixed(2)}
|
||||
button#purchase-button.btn.btn-success.pull-right(data-i18n="account_prepaid.purchase_button")
|
||||
button#purchase-btn.btn.btn-success.pull-right(data-i18n="account_prepaid.purchase_button")
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
|
@ -60,9 +60,9 @@ block content
|
|||
!= info
|
||||
p
|
||||
span.spr
|
||||
button.btn.btn-info.btn-check-code Lookup prepaid code
|
||||
button#lookup-code-btn.btn.btn-info Lookup prepaid code
|
||||
span
|
||||
button.btn.btn-success.btn-redeem-code Apply to your account
|
||||
button#redeem-code-btn.btn.btn-success Apply to your account
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
|
|
|
@ -16,12 +16,12 @@ module.exports = class PrepaidView extends RootView
|
|||
className: 'container-fluid'
|
||||
|
||||
events:
|
||||
'change #users': 'onUsersChanged'
|
||||
'change #months': 'onMonthsChanged'
|
||||
'click #purchase-button': 'onPurchaseClicked'
|
||||
'click #redeem-button': 'onRedeemClicked'
|
||||
'click .btn-check-code': 'onClickCheckCode'
|
||||
'click .btn-redeem-code': 'onClickRedeemCode'
|
||||
'change #users-input': 'onChangeUsersInput'
|
||||
'change #months-input': 'onChangeMonthsInput'
|
||||
'click #purchase-btn': 'onClickPurchaseButton'
|
||||
'click #redeem-btn': 'onClickRedeemButton' # DNE?
|
||||
'click #lookup-code-btn': 'onClickLookupCodeButton'
|
||||
'click #redeem-code-btn': 'onClickRedeemCodeButton'
|
||||
|
||||
subscriptions:
|
||||
'stripe:received-token': 'onStripeReceivedToken'
|
||||
|
@ -63,10 +63,10 @@ module.exports = class PrepaidView extends RootView
|
|||
|
||||
updateTotal: ->
|
||||
@purchase.total = getPrepaidCodeAmount(@baseAmount, @purchase.users, @purchase.months)
|
||||
@renderSelectors("#total", "#users", "#months")
|
||||
@renderSelectors("#total", "#users-input", "#months-input")
|
||||
|
||||
# Form Input Callbacks
|
||||
onUsersChanged: (e) ->
|
||||
onChangeUsersInput: (e) ->
|
||||
newAmount = $(e.target).val()
|
||||
newAmount = 1 if newAmount < 1
|
||||
@purchase.users = newAmount
|
||||
|
@ -81,7 +81,7 @@ module.exports = class PrepaidView extends RootView
|
|||
|
||||
@updateTotal()
|
||||
|
||||
onMonthsChanged: (e) ->
|
||||
onChangeMonthsInput: (e) ->
|
||||
newAmount = $(e.target).val()
|
||||
newAmount = 1 if newAmount < 1
|
||||
@purchase.months = newAmount
|
||||
|
@ -96,8 +96,8 @@ module.exports = class PrepaidView extends RootView
|
|||
|
||||
@updateTotal()
|
||||
|
||||
onPurchaseClicked: (e) ->
|
||||
return unless $("#users").val() >= 3 or $("#months").val() >= 3
|
||||
onClickPurchaseButton: (e) ->
|
||||
return unless $("#users-input").val() >= 3 or $("#months-input").val() >= 3
|
||||
@purchaseTimestamp = new Date().getTime()
|
||||
@stripeAmount = @purchase.total * 100
|
||||
@description = "Prepaid Code for " + @purchase.users + " users / " + @purchase.months + " months"
|
||||
|
@ -108,7 +108,7 @@ module.exports = class PrepaidView extends RootView
|
|||
bitcoin: true
|
||||
alipay: if me.get('country') is 'china' or (me.get('preferredLanguage') or 'en-US')[...2] is 'zh' then true else 'auto'
|
||||
|
||||
onRedeemClicked: (e) ->
|
||||
onClickRedeemButton: (e) ->
|
||||
@ppc = $('#ppc').val()
|
||||
|
||||
unless @ppc
|
||||
|
@ -209,7 +209,7 @@ module.exports = class PrepaidView extends RootView
|
|||
@prepaid = new Prepaid()
|
||||
@prepaid.fetch(options)
|
||||
|
||||
onClickCheckCode: (e) ->
|
||||
onClickLookupCodeButton: (e) ->
|
||||
@ppc = $('.input-ppc').val()
|
||||
unless @ppc
|
||||
@statusMessage "You must enter a code.", "error"
|
||||
|
@ -218,7 +218,7 @@ module.exports = class PrepaidView extends RootView
|
|||
@render?()
|
||||
@loadPrepaid(@ppc)
|
||||
|
||||
onClickRedeemCode: (e) ->
|
||||
onClickRedeemCodeButton: (e) ->
|
||||
@ppc = $('.input-ppc').val()
|
||||
options =
|
||||
url: '/db/subscription/-/subscribe_prepaid'
|
||||
|
|
Loading…
Reference in a new issue