This repository has been archived by the owner on Jan 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
104 lines (86 loc) · 2.28 KB
/
app.js
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
Ext.application({
name: 'OregonsCatch',
requires: [
'Ext.MessageBox',
'OregonsCatch.util.API',
'OregonsCatch.util.CrossFilter'
],
views: [
'Error',
'Home',
'ProductMapList',
'ProductInfo',
'SimpleImagesView',
'SimpleVideosView',
'VendorMapList',
'VendorInfo'
],
controllers: [
'Error',
'Home',
'ProductMapList',
'ProductInfo',
'SimpleImagesView',
'SimpleVideosView',
'VendorMapList',
'VendorInfo'
],
models: [
'Location',
'Product',
'Story',
'Vendor',
'Preparation',
'ProductPreparation'
],
stores: [
'Distances',
'Locations',
'Products',
'Stories',
'Vendors'
],
launch: function () {
var app = this;
// Load the API into the millions of stores.
OregonsCatch.util.CrossFilter.appStart();
// Views must be manually instantiated.
// Add home view first to show it.
Ext.Viewport.add(Ext.create('OregonsCatch.view.Home'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.ProductMapList'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.ProductInfo'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.SimpleImagesView'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.SimpleVideosView'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.VendorMapList'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.VendorInfo'));
Ext.Viewport.add(Ext.create('OregonsCatch.view.Error'));
// Android back button functionality.
function onBackKeyDown (e) {
e.preventDefault();
if (OregonsCatch.util.Back.history.length) {
OregonsCatch.util.Back.pop();
} else {
navigator.app.exitApp();
}
}
if (Ext.os.is('Android')) {
document.addEventListener('backButton', Ext.bind(onBackKeyDown, this), false);
}
// This is a hacky solution to the problem:
// Cordova cannot handle inline hrefs to external pages.
// This forces links to open with JS instead.
Ext.Viewport.element.dom.addEventListener('click', function (e) {
if (e.target.tagName.toLowerCase() !== 'a') { return; }
var url = e.target.getAttribute('href');
e.preventDefault();
OregonsCatch.util.Link.openLink(url);
}, false);
// Finally, bring the user into the app.
setTimeout(function () {
if (navigator.splashscreen) {
navigator.splashscreen.hide();
}
}, 1000);
Ext.fly('appLoadingIndicator').destroy();
}
});