mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-18 11:32:25 -05:00
41 lines
1.2 KiB
CoffeeScript
41 lines
1.2 KiB
CoffeeScript
|
ModalView = require 'views/kinds/ModalView'
|
||
|
template = require 'templates/modal/save_version'
|
||
|
|
||
|
module.exports = class SaveVersionModal extends ModalView
|
||
|
id: 'save-version-modal'
|
||
|
template: template
|
||
|
modalTitle: 'Save New Version'
|
||
|
|
||
|
events:
|
||
|
'click #save-version-button': 'onClickSaveButton'
|
||
|
'click #cla-link': 'onClickCLALink'
|
||
|
'click #agreement-button': 'onAgreedToCLA'
|
||
|
|
||
|
afterRender: ->
|
||
|
super()
|
||
|
@$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide()
|
||
|
|
||
|
onClickSaveButton: ->
|
||
|
Backbone.Mediator.publish 'save-new-version', {
|
||
|
major: @$el.find('#major-version').prop('checked')
|
||
|
commitMessage: @$el.find('#commit-message').val()
|
||
|
}
|
||
|
|
||
|
onClickCLALink: ->
|
||
|
window.open('/cla', 'cla', 'height=800,width=900')
|
||
|
|
||
|
onAgreedToCLA: ->
|
||
|
@$el.find('#agreement-button').text('Saving').prop('disabled', true)
|
||
|
$.ajax({
|
||
|
url: "/db/user/me/agreeToCLA"
|
||
|
method: 'POST'
|
||
|
success: @onAgreeSucceeded
|
||
|
error: @onAgreeFailed
|
||
|
})
|
||
|
|
||
|
onAgreeSucceeded: =>
|
||
|
@$el.find('#agreement-button').text('Thanks!')
|
||
|
@$el.find('#save-version-button').show()
|
||
|
|
||
|
onAgreeFailed: =>
|
||
|
@$el.find('#agreement-button').text('Failed').prop('disabled', false)
|