This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTiLoad.js
73 lines (66 loc) · 2.99 KB
/
TiLoad.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
var TiLoad = {
visible: false,
animOpen: Ti.UI.createAnimation({
duration: 250,
opacity: 1
}),
animClose: Ti.UI.createAnimation({
duration: 250,
opacity: 0
}),
init: function(_properties) {
var options = {
opacity: 0
};
if(_properties && _properties.rotate) {
options.orientationModes = [
Titanium.UI.LANDSCAPE_LEFT,
Titanium.UI.LANDSCAPE_RIGHT,
Titanium.UI.PORTRAIT,
Titanium.UI.UPSIDE_PORTRAIT
];
}
if(_properties && _properties.rotate) {
Ti.Gesture.addEventListener("orientationchange", TiLoad.size, false);
}
TiLoad.animClose.addEventListener("complete", function(_event) {
TiLoad.window.close();
TiLoad.visible = false;
});
TiLoad.window = Ti.UI.createWindow(options);
TiLoad.view = Ti.UI.createView({ width: "100%", height: "100%", top: 0, left: 0, backgroundColor: "transparent" });
TiLoad.overlay = Ti.UI.createView({ width: "100%", height: "100%", top: 0, left: 0, backgroundColor: "#000", opacity: 0.3 });
TiLoad.modal = Ti.UI.createView({ width: 100, height: 100, backgroundColor: "#000", borderRadius: 10 });
TiLoad.label = Ti.UI.createLabel({ text: "Loading", top: 60, left: 0, height: 20, width: 100, color: "#FFF", textAlign: "center", font: { fontSize: 13, fontWeight: "bold" } });
if(Ti.Platform.osname == "iphone" || Ti.Platform.osname == "ipad") {
TiLoad.spinner = Ti.UI.createActivityIndicator({ width: 100, height: 40, top: 20, left: 0, style: Titanium.UI.iPhone.ActivityIndicatorStyle.SMALL });
TiLoad.spinner.show();
} else if(Ti.Platform.osname == "android") {
TiLoad.spinner = Ti.UI.createImageView({ images: [ Ti.Filesystem.resourcesDirectory + "TiLoad/Images/00.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/01.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/02.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/03.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/04.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/05.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/06.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/08.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/09.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/10.png", Ti.Filesystem.resourcesDirectory + "TiLoad/Images/11.png" ], width: 20, height: 20, top: 30, left: 40 });
TiLoad.spinner.start();
}
TiLoad.view.add(TiLoad.overlay);
TiLoad.modal.add(TiLoad.spinner);
TiLoad.modal.add(TiLoad.label);
TiLoad.view.add(TiLoad.modal);
TiLoad.window.add(TiLoad.view);
},
show: function() {
if(!TiLoad.visible) {
TiLoad.size();
TiLoad.visible = true;
TiLoad.window.open(TiLoad.animOpen);
}
},
hide: function() {
if(TiLoad.visible) {
TiLoad.window.animate(TiLoad.animClose);
}
},
size: function(_event) {
TiLoad.window.width = Titanium.Platform.displayCaps.platformWidth;
TiLoad.window.height = Titanium.Platform.displayCaps.platformHeight;
TiLoad.modal.top = ((TiLoad.window.height - 100) / 2);
TiLoad.modal.left = ((TiLoad.window.width - 100) / 2);
}
};