blob: f0bb3dde9473c38fe80ec9d1b49e170b218b25c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
preventDefault = (event) ->
event.preventDefault()
srp.session = new srp.Session()
srp.signedUp = ->
srp.login
srp.loggedIn = ->
window.location = '/'
#// TODO: not sure this is what we want.
srp.updated = ->
window.location = '/'
srp.error = (message) ->
if $.isPlainObject(message) && message.errors
for field, error of message.errors
element = $('form input[name$="['+field+']"]')
next unless element
element.trigger('element:validate:fail.ClientSideValidations', error).data('valid', false)
else
alert(message)
$(document).ready ->
$('#new_user').submit preventDefault
$('#new_user').submit srp.signup
$('#new_session').submit preventDefault
$('#new_session').submit srp.login
$('.user.form.edit').submit srp.update
$('.user.form.edit').submit preventDefault
|