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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
var app = (function(){
var app = {}
app.init = function(){
console.log("init")
if (window.location.hostname === 'lvh.me' || window.location.hostname === 'dev.stone.giraffe.life' || window.location.hostname === 'staging.stone.giraffe.life') {
console.log('launching in test mode')
sdk.init({ env: "test" })
}
else {
sdk.init({ env: "production" })
}
if (window.cordova) {
document.addEventListener('deviceready', app.device_ready, false)
}
else {
app.device_ready()
}
}
app.bind = function(){
document.addEventListener('touchmove', function(e){ e.preventDefault() })
if (!app.accessible) {
FastClick.attach(document.body)
}
}
app.build = function(){
app.blog = new BlogView ()
app.archive = new ArchiveView ()
app.hub = new HubView ()
app.story = new StoryView ()
app.cart = new CartView ()
app.intro = new IntroView ()
app.header = new HeaderView ()
app.footer = new FooterView ()
app.curtain = new CurtainView ()
app.nav = new NavView ()
app.account = new AccountView ()
app.login = new LoginView ()
app.logout = new LogoutView ()
app.signup = new SignupView ()
app.profile = new ProfileView ()
app.payment = new PaymentView ()
app.shipping = new ShippingView ()
app.settings = new SettingsView ()
app.orders = new OrdersView ()
app.terms = new PageView ({ page: "terms" })
app.privacy = new PageView ({ page: "privacy" })
app.account_terms = new PageView ({ page: "account_terms" })
app.returns = new PageView ({ page: "returns" })
app.care = new PageView ({ page: "care" })
app.collection = new CollectionView ()
app.product = new ProductView ()
app.closed = new ClosedStoreView ()
app.search = new SearchView ()
app.selector = new Selector ()
}
app.device_ready = function(){
accessibility.init(app.ready) // check if we can do native scrolling before build
}
app.ready = function(){
console.log(">> READY")
app.bind()
app.build()
app.iscroll_options = {
mouseWheel: true,
scrollbars: true,
disablePointer: is_android ? true : false, // important to disable the pointer events that causes the issues
disableTouch: false, // false if you want the slider to be usable with touch devices
disableMouse: false // false if you want the slider to be usable with a mouse (desktop)
}
if (window.cordova) {
document.addEventListener('pause', app.paused, false)
document.addEventListener('resume', app.resumed, false)
document.addEventListener('online', app.online, false)
document.addEventListener('offline', app.offline, false)
cordova.plugins.Keyboard.disableScroll(true)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false)
analytics.init()
geo.fetch()
sim.fetch(app.api_ready)
var image = new Image
image.src = "./img/compass-logo.png"
}
else {
app.api_ready()
}
}
app.api_ready = function(){
if (is_iphone_x && 'StatusBar' in window) {
window.StatusBar.hide()
}
app.view = null
app.router = new SiteRouter ()
// if (sdk.env == "test") {
// app.router.launch()
// }
// else {
// }
push.init()
if (navigator.onLine) {
app.account.connect(window.deepLinkRoute || '/intro')
app.blog.fetch(function(){
console.log("blog fetched, launching router")
app.router.initial_route = window.deepLinkRoute || null
if (app.router.initial_route) {
analytics.sendPageView('push/' + app.router.initial_route)
}
app.router.launch()
})
}
else {
console.log(">> LAUNCHED WHILE OFFLINE")
app.router.go("intro")
app.finished_launching()
}
}
app.finished_launching = function(){
console.log(">> FINISHED LAUNCHING")
if (window.cordova) {
navigator.splashscreen.hide()
}
if (window.deepLinkRoute) {
app.router.go(window.deepLinkRoute)
}
app.fullscreenViewer = ImageViewer()
$("body").removeClass("loading")
}
var refresh_time = +Date.now()
app.paused = function(){}
app.resumed = function(){
console.log( "app is ready?", app.is_ready )
geo.fetch()
var now = +Date.now()
if (now - refresh_time > 60 * 60 * 1000) {
refresh_time = now
app.blog.refresh()
}
}
app.online = function(){
console.log(">> ONLINE")
}
app.offline = function(){
console.log(">> OFFLINE")
}
return app
})()
app.init()
|