-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.js
118 lines (103 loc) · 2.57 KB
/
widget.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var args = arguments[0];
var isContentBoxOpen = false;
var contentBoxHeight = args.contentBoxHeight || (Ti.Platform.displayCaps.platformHeight / 3);
var contentBoxBottom = (contentBoxHeight + 15) * -1;
hideOverLay();
$.Overlay.addEventListener('click', hideContentBox);
$.ContentBox.addEventListener('swipe', expandContentBox);
initViews();
function initViews() {
$.ContentBox.height = contentBoxHeight;
$.ContentBox.bottom = contentBoxBottom;
var children;
if (args.children) {
children = args.children || [];
for (var i = 0, j = children.length; i < j; i++) {
$.ContentBoxHolder.add(children[i]);
}
}
}
function expandContentBox(e) {
if (e.direction === 'up') {
var animation = Ti.UI.createAnimation({
duration: 200,
height: Ti.UI.FILL,
borderRadius: 0
});
$.ContentBox.animate(animation, function() {
$.ContentBox.borderRadius = 0;
});
} else if (e.direction === 'down') {
hideContentBox();
}
}
function hideContentBox() {
var animation = Ti.UI.createAnimation({
duration: 300,
bottom: contentBoxBottom,
height: contentBoxHeight,
});
hideOverLay();
$.ContentBox.animate(animation, function() {
$.ContentBox.borderRadius = 15;
$.ButtomSheetView.width = 0;
$.ButtomSheetView.height = 0;
$.ButtomSheetView.fireEvent('closed');
});
}
function showContentBox() {
$.ButtomSheetView.width = Ti.UI.FILL;
$.ButtomSheetView.height = Ti.UI.FILL;
var animation = Ti.UI.createAnimation({
duration: 300,
bottom: -15,
});
showOverLay();
$.ContentBox.animate(animation, function() {
$.ButtomSheetView.fireEvent('opened');
});
}
function hideOverLay() {
var animation = Ti.UI.createAnimation({
duration: 300,
opacity: 0
});
$.Overlay.animate(animation, function() {
$.Overlay.height = 0;
$.Overlay.opacity = 0;
$.Overlay.hide();
})
}
function showOverLay() {
$.Overlay.height = Ti.UI.FILL;
$.Overlay.opacity = 0;
$.Overlay.show();
var animation = Ti.UI.createAnimation({
duration: 300,
opacity: 0.3
});
$.Overlay.animate(animation)
}
$.setContentBoxHeight = function() {
contentBoxHeight;
}
$.addEventListener = function(event, callback) {
$.ButtomSheetView.addEventListener(event, callback);
};
$.setViews = function(views) {
for (var i = 0, j = views.length; i < j; i++) {
$.ContentBoxHolder.add(views[i]);
}
};
$.clearViews = function() {
$.ContentBoxHolder.removeAllChildren();
};
$.expand = function() {
expandContentBox()
};
$.show = function() {
showContentBox();
};
$.hide = function() {
hideContentBox();
};