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
|
var CartShipping = FormView.extend({
el: "#cart_shipping",
list_mode: true,
template: $("#cart_shipping .template").html(),
events: {
"click .dropdown-wrapper": "toggle_dropdown",
},
initialize: function(opt){
this.parent = opt.parent
this.$form = this.$("form")
this.$address_list = this.$(".address_list")
this.$address_form = this.$(".address")
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this })
this.scroller = new IScroll('#cart_shipping', app.iscroll_options)
},
show: function(){
document.body.className = "cart"
app.cart.el.className = "shipping"
app.footer.show("PAYMENT >", "CANCEL")
window.location.hash = "#/cart/shipping"
this.populate()
this.deferScrollToTop()
},
populate: function(){
// id checked name address city state zip
this.$(".save_as_default").show()
this.$address_list.empty()
if (! app.account.addresses.length) {
this.toggle_dropdown(true)
}
app.account.addresses.forEach(function(address){
var t = this.template.replace(/{{id}}/g, address.Id)
.replace(/{{checked}}/g, address.IsDefault ? "checked" : "")
.replace(/{{name}}/g, address.Name + " " + address.Surname)
.replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", "<br>"))
.replace(/{{city}}/g, address.City)
.replace(/{{state}}/g, address.Province)
.replace(/{{zip}}/g, address.ZipCode)
this.$address_list.append(t)
}.bind(this))
},
toggle_dropdown: function(state){
this.list_mode = typeof state == "boolean" ? state : ! this.list_mode
this.$address_form.toggle(! this.list_mode)
this.$address_list.toggle(this.list_mode)
},
// sdk.cart.set_shipping_address
// sdk.shipping.get_delivery_types
// sdk.shipping.set_delivery_type
finalize: function(data){
console.log(data)
return
},
success: function(){
},
cancel: function(){
app.cart.cart_summary.show()
},
})
|