summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/auth/SignupView.js
blob: 3ad84cc90c8b1c6ae02dc579a4b84fd24393901e (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var SignupView = FormView.extend({
  
  el: "#signup",
  
  action: sdk.account.signup,
  
  events: {
    "click .privacy-msg": "privacy_link",
    "submit form": "save",
  },
  
  initialize: function(){
    this.$form = this.$("form")
    this.$msg = this.$(".msg")
    this.scroller = new IScroll('#signup', app.iscroll_options)
  },
  
  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_presence: {
    "Name": "Please enter your first name.",
    "Surname": "Please enter your last name.",
    "Email": "Please enter a valid email address.",
    "ConfirmEmail": "Please enter a valid email address.",
    "Password": "Please enter your password.",
    "Password2": "Please enter your password again.",
    "DataProfiling": "You must agree to data profiling.",
  },
  
  validate_fields: function(errors){
    if (data.Password.length < 7) { errors.push("Password", "Password must be 7 characters or more.") }
    if (data.Password !== data.Password2) { errors.push("Password2", "Passwords don't match.") }
    if (data.Email !== data.ConfirmEmail) { errors.push("ConfirmEmail", "Email addresses don't match.") }
    if (data.DataProfiling !== "true") { errors.push("DataProfiling", "You must consent to use this service.") }
    if (data.DataProfiling2 !== "true") { errors.push("DataProfiling2", "You must consent to use this service.") }
    if (! data.YooxLetter) { data.YooxLetter = "false" }
  },
  
  privacy_link: function(){
    // rewrite app.privacy instance temporarily
    app.privacy.back = function(){
      app.router.go("account/signup")
    }
    app.privacy.hide = function(){
      app.privacy.back = app.privacy.hide = null
    }
    app.router.go("page/privacy")
  },
  
  success: function(data){
    console.log('success', data)
    app.account.logged_in()
  },
  
  error: function(data){
    console.log('error', data)
  },

  cancel: function(){
    auth.deferred_product = null
  },

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

})