summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/nav/LoginView.js
blob: de534e320a0af4c2e2a8b332eac6728ce62e552b (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
var LoginView = View.extend({
  
  el: "#login",
  
  events: {
    "click .close": "hide",
    "click .login_ask": "login",
    "click .signup_ask": "signup",
    "submit form": "submit",
  },
  
  mode: null,
  
  initialize: function(){
    this.$form = this.$("form")
    this.$email = this.$("[name=email]")
    this.$password = this.$("[name=password]")
  },
  
  show: function(){
    this.$form.hide()
    this.$email.val("")
    this.$password.val("")
    document.body.classList.add("login")
  },
  
  hide: function(){
    document.body.classList.remove("login")
  },
  
  login: function(){
    this.mode = "login"
    this.$form.show()
  },
  
  signup: function(){
    this.mode = "signup"
    this.$form.show()
  },
  
  submit: function(e){
    e.preventDefault()
    if (this.mode == "login") {
      // login api
    }
    else {
      // signup api
    }
  },
  
  success: function(){
    // change login in ui to logout or whatever
  },

})