2014-01-03 13:32:13 -05:00
|
|
|
View = require 'views/kinds/ModalView'
|
|
|
|
template = require 'templates/modal/contact'
|
|
|
|
|
|
|
|
forms = require 'lib/forms'
|
|
|
|
{sendContactMessage} = require 'lib/contact'
|
|
|
|
|
|
|
|
contactSchema =
|
|
|
|
additionalProperties: false
|
|
|
|
properties:
|
|
|
|
email:
|
|
|
|
required: true
|
|
|
|
type: 'string'
|
|
|
|
maxLength: 100
|
|
|
|
minLength: 1
|
|
|
|
format: 'email'
|
|
|
|
|
|
|
|
message:
|
|
|
|
required: true
|
|
|
|
type: 'string'
|
|
|
|
minLength: 1
|
|
|
|
|
|
|
|
module.exports = class ContactView extends View
|
|
|
|
id: "contact-modal"
|
|
|
|
template: template
|
2014-01-10 20:32:29 -05:00
|
|
|
closeButton: true
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
events:
|
|
|
|
"click #contact-submit-button": "contact"
|
|
|
|
|
|
|
|
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
|