mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-01 16:33:38 -04:00
Now showing SubscribeModal before AuthModal for players who need to sign up before subscribing.
This commit is contained in:
parent
e9ab0c1f4d
commit
175cdb5151
4 changed files with 11 additions and 14 deletions
app
models
views/play
|
@ -45,14 +45,14 @@ class CocoModel extends Backbone.Model
|
||||||
@loading = false
|
@loading = false
|
||||||
@jqxhr = null
|
@jqxhr = null
|
||||||
if jqxhr.status is 402
|
if jqxhr.status is 402
|
||||||
Backbone.Mediator.publish 'level:subscription-required'
|
Backbone.Mediator.publish 'level:subscription-required', {}
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
@loaded = true
|
@loaded = true
|
||||||
@loading = false
|
@loading = false
|
||||||
@jqxhr = null
|
@jqxhr = null
|
||||||
@loadFromBackup()
|
@loadFromBackup()
|
||||||
|
|
||||||
getCreationDate: -> new Date(parseInt(@id.slice(0,8), 16)*1000)
|
getCreationDate: -> new Date(parseInt(@id.slice(0,8), 16)*1000)
|
||||||
|
|
||||||
getNormalizedURL: -> "#{@urlRoot}/#{@id}"
|
getNormalizedURL: -> "#{@urlRoot}/#{@id}"
|
||||||
|
@ -351,7 +351,7 @@ class CocoModel extends Backbone.Model
|
||||||
|
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
Achievement = require 'models/Achievement'
|
Achievement = require 'models/Achievement'
|
||||||
|
|
||||||
class NewAchievementCollection extends CocoCollection
|
class NewAchievementCollection extends CocoCollection
|
||||||
model: Achievement
|
model: Achievement
|
||||||
initialize: (me = require('core/auth').me) ->
|
initialize: (me = require('core/auth').me) ->
|
||||||
|
|
|
@ -208,11 +208,9 @@ module.exports = class WorldMapView extends RootView
|
||||||
@endHighlight()
|
@endHighlight()
|
||||||
else
|
else
|
||||||
if level.requiresSubscription and @requiresSubscription and not @levelStatusMap[level.id] and not level.adventurer
|
if level.requiresSubscription and @requiresSubscription and not @levelStatusMap[level.id] and not level.adventurer
|
||||||
modal = if me.get('anonymous') then AuthModal else SubscribeModal
|
@openModalView new SubscribeModal()
|
||||||
@openModalView new modal()
|
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'map level clicked'
|
||||||
if modal is SubscribeModal
|
window.tracker?.trackPageView "subscription/show-modal", ['Google Analytics']
|
||||||
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'map level clicked'
|
|
||||||
window.tracker?.trackPageView "subscription/show-modal", ['Google Analytics']
|
|
||||||
else if $(e.target).attr('disabled')
|
else if $(e.target).attr('disabled')
|
||||||
Backbone.Mediator.publish 'router:navigate', route: '/contribute/adventurer'
|
Backbone.Mediator.publish 'router:navigate', route: '/contribute/adventurer'
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,6 @@ CocoView = require 'views/core/CocoView'
|
||||||
template = require 'templates/play/level/level_loading'
|
template = require 'templates/play/level/level_loading'
|
||||||
utils = require 'core/utils'
|
utils = require 'core/utils'
|
||||||
SubscribeModal = require 'views/play/modal/SubscribeModal'
|
SubscribeModal = require 'views/play/modal/SubscribeModal'
|
||||||
AuthModal = require 'views/core/AuthModal'
|
|
||||||
|
|
||||||
module.exports = class LevelLoadingView extends CocoView
|
module.exports = class LevelLoadingView extends CocoView
|
||||||
id: 'level-loading-view'
|
id: 'level-loading-view'
|
||||||
|
@ -110,11 +109,9 @@ module.exports = class LevelLoadingView extends CocoView
|
||||||
@$el.find('.subscription-required').show()
|
@$el.find('.subscription-required').show()
|
||||||
|
|
||||||
onClickStartSubscription: (e) ->
|
onClickStartSubscription: (e) ->
|
||||||
modal = if me.get('anonymous') then AuthModal else SubscribeModal
|
@openModalView new SubscribeModal()
|
||||||
@openModalView new modal()
|
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'level loading'
|
||||||
if modal is SubscribeModal
|
window.tracker?.trackPageView "subscription/show-modal", ['Google Analytics']
|
||||||
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'level loading'
|
|
||||||
window.tracker?.trackPageView "subscription/show-modal", ['Google Analytics']
|
|
||||||
|
|
||||||
onSubscribed: ->
|
onSubscribed: ->
|
||||||
document.location.reload()
|
document.location.reload()
|
||||||
|
|
|
@ -2,6 +2,7 @@ ModalView = require 'views/core/ModalView'
|
||||||
template = require 'templates/play/modal/subscribe-modal'
|
template = require 'templates/play/modal/subscribe-modal'
|
||||||
stripeHandler = require 'core/services/stripe'
|
stripeHandler = require 'core/services/stripe'
|
||||||
utils = require 'core/utils'
|
utils = require 'core/utils'
|
||||||
|
AuthModal = require 'views/core/AuthModal'
|
||||||
|
|
||||||
module.exports = class SubscribeModal extends ModalView
|
module.exports = class SubscribeModal extends ModalView
|
||||||
id: 'subscribe-modal'
|
id: 'subscribe-modal'
|
||||||
|
@ -49,6 +50,7 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
|
|
||||||
onClickPurchaseButton: (e) ->
|
onClickPurchaseButton: (e) ->
|
||||||
@playSound 'menu-button-click'
|
@playSound 'menu-button-click'
|
||||||
|
return @openModalView new AuthModal() if me.get('anonymous')
|
||||||
application.tracker?.trackEvent 'Started subscription purchase', {}
|
application.tracker?.trackEvent 'Started subscription purchase', {}
|
||||||
application.tracker?.trackPageView "subscription/start-purchase", ['Google Analytics']
|
application.tracker?.trackPageView "subscription/start-purchase", ['Google Analytics']
|
||||||
stripeHandler.open({
|
stripeHandler.open({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue