2014-11-28 20:49:41 -05:00
|
|
|
ModalView = require 'views/core/ModalView'
|
2014-09-17 21:56:08 -04:00
|
|
|
template = require 'templates/play/modal/play-account-modal'
|
2014-11-25 15:43:17 -05:00
|
|
|
AccountSettingsView = require 'views/account/AccountSettingsView'
|
2014-09-17 21:56:08 -04:00
|
|
|
|
|
|
|
module.exports = class PlayAccountModal extends ModalView
|
|
|
|
className: 'modal fade play-modal'
|
|
|
|
template: template
|
2014-11-25 15:43:17 -05:00
|
|
|
plain: true
|
2014-09-17 21:56:08 -04:00
|
|
|
id: 'play-account-modal'
|
|
|
|
|
2014-11-25 15:43:17 -05:00
|
|
|
events:
|
|
|
|
'click #save-button': -> @accountSettingsView.save()
|
2014-09-17 21:56:08 -04:00
|
|
|
|
|
|
|
constructor: (options) ->
|
|
|
|
super options
|
|
|
|
|
|
|
|
getRenderData: (context={}) ->
|
|
|
|
context = super(context)
|
|
|
|
context
|
|
|
|
|
|
|
|
afterRender: ->
|
|
|
|
super()
|
|
|
|
return unless @supermodel.finished()
|
2014-11-26 09:58:23 -05:00
|
|
|
@playSound 'game-menu-open'
|
2014-11-25 15:43:17 -05:00
|
|
|
@accountSettingsView = new AccountSettingsView()
|
|
|
|
@insertSubView(@accountSettingsView)
|
|
|
|
@listenTo @accountSettingsView, 'input-changed', @onInputChanged
|
|
|
|
@listenTo @accountSettingsView, 'save-user-began', @onUserSaveBegan
|
|
|
|
@listenTo @accountSettingsView, 'save-user-success', @hide
|
|
|
|
@listenTo @accountSettingsView, 'save-user-error', @onUserSaveError
|
2014-09-17 21:56:08 -04:00
|
|
|
|
|
|
|
onHidden: ->
|
|
|
|
super()
|
2014-11-26 09:58:23 -05:00
|
|
|
@playSound 'game-menu-close'
|
2014-11-25 15:43:17 -05:00
|
|
|
|
|
|
|
onInputChanged: ->
|
|
|
|
@$el.find('#save-button')
|
2014-11-25 16:32:43 -05:00
|
|
|
.text($.i18n.t('common.save', defaultValue: 'Save'))
|
|
|
|
.addClass 'btn-info'
|
|
|
|
.removeClass 'disabled btn-danger'
|
|
|
|
.removeAttr 'disabled'
|
2014-11-25 15:43:17 -05:00
|
|
|
|
|
|
|
onUserSaveBegan: ->
|
|
|
|
@$el.find('#save-button')
|
2014-11-25 16:32:43 -05:00
|
|
|
.text($.i18n.t('common.saving', defaultValue: 'Saving...'))
|
|
|
|
.removeClass('btn-danger')
|
|
|
|
.addClass('btn-success').show()
|
2014-11-25 15:43:17 -05:00
|
|
|
|
|
|
|
onUserSaveError: ->
|
|
|
|
@$el.find('#save-button')
|
2014-11-25 16:32:43 -05:00
|
|
|
.text($.i18n.t('account_settings.error_saving', defaultValue: 'Error Saving'))
|
|
|
|
.removeClass('btn-success')
|
|
|
|
.addClass('btn-danger', 500)
|