codecombat/app/views/modal/contact_modal.coffee

37 lines
972 B
CoffeeScript
Raw Normal View History

2014-07-17 20:22:26 -04:00
ModalView = require 'views/kinds/ModalView'
2014-01-03 13:32:13 -05:00
template = require 'templates/modal/contact'
forms = require 'lib/forms'
{sendContactMessage} = require 'lib/contact'
contactSchema =
additionalProperties: false
required: ['email', 'message']
2014-01-03 13:32:13 -05:00
properties:
email:
type: 'string'
maxLength: 100
minLength: 1
format: 'email'
message:
type: 'string'
minLength: 1
2014-07-17 20:22:26 -04:00
module.exports = class ContactView extends ModalView
2014-06-30 22:16:26 -04:00
id: 'contact-modal'
2014-01-03 13:32:13 -05:00
template: template
2014-01-10 20:32:29 -05:00
closeButton: true
2014-01-03 13:32:13 -05:00
events:
2014-06-30 22:16:26 -04:00
'click #contact-submit-button': 'contact'
2014-01-03 13:32:13 -05:00
contact: ->
forms.clearFormAlerts @$el
contactMessage = forms.formToObject @$el
res = tv4.validateMultiple contactMessage, contactSchema
return forms.applyErrorsToForm @$el, res.errors unless res.valid
window.tracker?.trackEvent 'Sent Feedback', message: contactMessage
sendContactMessage contactMessage, @$el
$.post "/db/user/#{me.id}/track/contact_codecombat"