summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
blob: 1f7438cc5a7c1aa96e131ab369fc2c3f06657aca (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
var LoginView = FormView.extend({
  
  el: "#login",
  
  action: sdk.account.login,
  
  events: {
    "click .newuser": "new_user",
    "submit form": "save",
  },
  
  initialize: function(){
    this.$form = this.$("form")
    this.$msg = this.$(".msg")
    this.scroller = new IScroll('#login', app.iscroll_options)
  },
  
  show: function(){
    if (auth.logged_in()) {
      app.router.go("intro")
      return
    }
    var msg = "* Your personal and payment<br>information will always remain private"
    app.footer.show("SUBMIT", "CANCEL")
    this.$form.get(0).reset()
    this.$msg.html(msg)
    document.body.className = "login"
  },

  new_user: function(){
    app.router.go("account/signup")
  },

  validate_presence: {
    "Email": "Please enter a valid email address.",
    "Password": "Please enter your password.",
  },
  
  success: function(data){
    // console.log(data)
    app.account.logged_in(function(){ app.router.go("store") })
  },
  
  error: function(data){
    this.$msg.html("There was an error logging you in. Bad password?")
    this.$msg.addClass('alert-notice')
  },
  
  cancel: function(){
    auth.deferred_product = null
  },

})