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
|
var HeaderView = View.extend({
el: "#header",
events: {
"click .burger": "nav",
"click .logo": "logo",
"click .cart": "cart",
},
initialize: function(){
this.$burger = this.$(".burger")
this.$cart = this.$(".cart")
this.$cart_count = this.$(".cart_count")
},
back_state: false,
set_back: function(state){
this.back_state = state
if (state) {
this.$burger[0].className = "burger ion-ios-arrow-left"
}
else {
this.$burger[0].className = "burger ion-android-menu"
}
},
nav: function(){
if (this.back_state) {
app.view.back()
}
else {
app.nav.show()
}
},
logo: function(){
app.router.go("intro")
},
cart: function(){
app.router.go("cart")
},
count: 0,
set_cart_count: function(n){
this.count = n
this.$cart_count.html(n || "0")
},
increment_cart_count: function(){
this.$cart_count.html( ++this.count )
},
decrement_cart_count: function(){
this.$cart_count.html( --this.count )
},
})
|