Built the BuyGemsModal stub.

This commit is contained in:
Scott Erickson 2014-11-12 09:40:55 -08:00
parent f1947d7d9d
commit ad35109878
5 changed files with 61 additions and 0 deletions

View file

@ -64,6 +64,7 @@
next: "Next" # Go from choose hero to choose inventory before playing a level
change_hero: "Change Hero" # Go back from choose inventory to choose hero
choose_inventory: "Equip Items"
buy_gems: "Buy Gems"
older_campaigns: "Older Campaigns"
anonymous: "Anonymous Player"
level_difficulty: "Difficulty: "

View file

@ -0,0 +1,8 @@
#buy-gems-modal
button
width: 100%
margin-bottom: 10px
.gem
width: 20px
height: 20px

View file

@ -0,0 +1,14 @@
extends /templates/modal/modal_base
block modal-header-content
h3(data-i18n='play.buy_gems')
block modal-body-content
for product in products
button.product.btn.btn-lg(value=product.id)
img.gem(src="/images/common/gem.png")
span x#{product.gems): #{product.price}
block modal-footer
.modal-footer
button(data-dismiss="modal", data-i18n="common.cancel").btn Cancel

View file

@ -40,6 +40,7 @@
button.btn.items(data-toggle='coco-modal', data-target='play/modal/PlayItemsModal', data-i18n="[title]play.items")
button.btn.heroes(data-toggle='coco-modal', data-target='play/modal/PlayHeroesModal', data-i18n="[title]play.heroes")
if me.isAdmin()
button.btn.gems(data-toggle='coco-modal', data-target='play/modal/BuyGemsModal', data-i18n="[title]play.buy_gems")
button.btn.achievements(data-toggle='coco-modal', data-target='play/modal/PlayAchievementsModal', data-i18n="[title]play.achievements")
button.btn.account(data-toggle='coco-modal', data-target='play/modal/PlayAccountModal', data-i18n="[title]play.account")
button.btn.settings(data-toggle='coco-modal', data-target='play/modal/PlaySettingsModal', data-i18n="[title]play.settings")

View file

@ -0,0 +1,37 @@
ModalView = require 'views/kinds/ModalView'
template = require 'templates/play/modal/buy-gems-modal'
module.exports = class BuyGemsModal extends ModalView
id: 'buy-gems-modal'
template: template
plain: true
events:
'click button.product': 'onClickProductButton'
getRenderData: ->
c = super()
c.products = @getProducts()
return c
getProducts: ->
if application.isIPadApp
# Inject IAP data here.
else
return [
{ price: '$4.99', gems: 5000, id: 'gems_5' }
{ price: '$9.99', gems: 11000, id: 'gems_10' }
{ price: '$19.99', gems: 25000, id: 'gems_20' }
]
onClickProductButton: (e) ->
productID = $(e.target).closest('button.product').val()
product = _.find @getProducts(), { id: productID }
console.log 'wanna purchase product', product
if application.isIPadApp
# Trigger IAP here.
else
@$el.find('.modal-body').append($('<div class="alert alert-danger">Not implemented</div>'))