summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/cart/CartPayment.js
blob: 90fe4a762cd42400f18027e5bca3290444b6a92e (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
var CartPayment = FormView.extend({
  
  el: "#cart_payment",
  
  action: sdk.cart.set_credit_card,
  
  events: {
    "change [name=same_as_shipping]": "toggle_shipping",
    "click .dropdown-wrapper": "toggle_dropdown",
  },

  initialize: function(opt){
    this.parent = opt.parent
    this.$form = this.$("form")
    this.$msg = this.$(".msg")
    this.$address_list = this.$(".address_list")
    this.$address_form = this.$(".address")
    this.$cc_form = this.$(".cc")

    this.address = new AddressView ({ parent: this, checkPhone: false })
    this.cc = new CreditCardView ({ parent: this })
    this.scroller = new IScroll('#cart_payment', app.iscroll_options)
    this.address.disabled = true
    this.cc.disabled = true
  },

  // sdk.cart.set_credit_card
  // sdk.payment.list_credit_cards
  // sdk.payment.add_credit_card
  // sdk.payment.delete_credit_card
  // sdk.payment.get_payment_types
  // sdk.cart.use_stored_credit_card

  show: function(){
    document.body.className = "cart"
    app.cart.el.className = "payment"
    app.footer.show("CONFIRM >", "CANCEL")
    window.location.hash = "#/cart/payment"

    this.populate()
    this.deferScrollToTop()
  },

  toggle_dropdown: function(state){
    if (! app.account.ccs.length) {
      state = false
    }
    this.list_mode = typeof state == "boolean" ? state : ! this.list_mode
    this.address.disabled = this.list_mode
    this.$address_form.toggle(! this.list_mode)
    this.$cc_form.toggle(! this.list_mode)
    this.$address_list.toggle(this.list_mode)
  },

  populate: function(){
    app.account.ccs.forEach(function(cc){
    })
  },
  
  save: function(){
    // use stored credit card
    return
  },
  
  cancel: function(){
  },

})