summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/account/SignupView.js
blob: e695e26fdc36719ab534b6e5e9dabd2dd60535d8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var SignupView = SerializableView.extend({
  
  el: "#signup",
  
  events: {
    "submit form": "save",
  },
  
  initialize: function(){
    this.$form = this.$("form")
    this.$msg = this.$(".msg")
  },
  
  show: function(){
    app.footer.show("SUBMIT", "CANCEL")
    this.$form.get(0).reset()
    this.$msg.html("* Your personal and payment information will always remain private")
    document.body.className = "signup"
  },

  validate: function(data){
    var errors = []
    if (! data.Name) { errors.push("Please enter your first name.") }
    if (! data.Surname) { errors.push("Please enter your last name.") }
    if (! data.Email) { errors.push("Please enter a valid email address.") }
    if (! data.Password) { errors.push("Please enter your password.") }
    if (! data.Password2) { errors.push("Please enter your password again.") }
    if (data.Password !== data.Password2) { errors.push("Passwords don't match.") }
    if (! data.DataProfiling) { errors.push("You must agree to share your data.") }
    return errors
  },

  save: function(e){
    e && e.preventDefault()
  },
  
  success: function(){
    // change login in ui to logout or whatever
  },

/*
  var new_user_data = {
    "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com",
    "Password": "TestPassword",
    "Gender": "M",
    "Name": "TestName",
    "Surname": "TestSurname",
    "DataProfiling": true,
  }
*/

})