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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
var BlogView = View.extend({
data: null,
loaded: false,
us_states: $("#us_states").html(),
ca_states: $("#ca_states").html(),
initialize: function(){
this.loader = new Loader ()
},
fetch: function(fn){
$.ajax({
method: "GET",
url: sdk.env === 'test' ? '/db.json' : sdk.cms() + '/db.json',
// url: "https://stone.giraffe.life/db.json",
success: function(data){
this.success(data)
fn && fn()
}.bind(this),
cache: true,
})
},
refresh: function(){
this.loaded = false
this.fetch()
},
success: function(data){
if (this.loaded) return
this.loaded = true
this.data = data = typeof data == "string" ? JSON.parse(data) : data
// sdk.env = 'test'
if (sdk.env === 'test') {
app.store = data.store[1]
}
else {
app.store = data.store[0]
}
switch (app.store.DepartmentStoreStatus) {
case "open":
app.closed.storeIsClosed = false
break
case "closed":
app.closed.storeIsClosed = true
app.closed.storeClosedMessageOne = app.store.StoreClosedMessageOne
app.closed.storeClosedMessageTwo = app.store.StoreClosedMessageTwo
break
}
console.log(data)
if (app.closed.storeIsClosed && sdk.env !== 'test') {
app.closed.populate(app.store.ClosedStoreImages)
}
else {
app.departments = app.store.Departments
app.department_id = app.store.Departments[0].uri
$("#collections h1").toggleClass("single-dept", app.store.Departments.length == 1)
app.collection.setCollectionName( app.store.Departments[0].text )
//// demo department for shoes with weird SizeTypeId
// app.department_id = "NKDrtSC"
if (sdk.env === 'test') {
app.department_id = window.location.search.substr(1) || app.department_id
console.log('using test department id', app.department_id)
// app.department_id = 'TSTSZS'
}
app.collection.loaded = false
app.collection.fetch()
}
app.archive.populate(data.archive)
this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
app.hub.populate(data.hub)
}.bind(this))
this.loader.preloadImage(data.story[0].image.uri, function(img){
app.story.populate(data.story)
setTimeout(function(){
this.loader.preloadImage(data.story[1].image.uri)
this.loader.preloadImage(data.story[2].image.uri)
}.bind(this), 2000)
}.bind(this))
data.page.forEach(function(page){
app[page.tag] && app[page.tag].populate(page)
})
console.log(app.store.StoreStatus)
app.product.fitLargeCodes = {}
if (app.store.FittingCodes.length) {
app.store.FittingCodes.split("\n").forEach(function(code){
app.product.fitLargeCodes[code] = true
})
}
if (app.store.BackgroundIsGray === "true") {
app.collection.$el.addClass("gray")
app.product.gallery.$el.addClass("gray")
}
var states = this.us_states
if (! app.store.NotAvailableInCanada) {
states += this.ca_states
}
$('[name=Province]').html(states)
},
})
|