-
Notifications
You must be signed in to change notification settings - Fork 0
/
weblayers.html
executable file
·122 lines (98 loc) · 3.63 KB
/
weblayers.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
</head>
<body>
<div class="block">
<p><b>WebLayers</b> allow you to add a webview over the current webview.<br/>
The webview is positionned on the same place that the current one and the background is transparent so that you
can define your own "popin" style.</p>
<p>Here is a simple one.</p>
<a href="javascript:;" id="test1">Simple one</a>
</div>
<div class="block">
<p>Same thing below but with a longer fadeIn effect.</p>
<a href="javascript:;" id="test2">Longer fadeIn</a>
</div>
<div class="block">
<p>No fadeIn at all for this one:</p>
<a href="javascript:;" id="test3">no fadeIn</a>
</div>
<div class="block">
<p>This one is a bit more complex. It has an editable field and when you validate, the parent page is warned and can
show what was written.</p>
<a href="javascript:;" id="test4">Try it</a>
</div>
<div class="block">
<p>This weblayer loads a distant page on the cobaltians server. In this page we load cobalt.js so we can use as if
it was in the app.</p>
<a href="javascript:;" id="test5">Distant one</a>
</div>
<div class="block">
<p>Weblayers can also be put in foreground and background. Clic on show below and then move the weblayer background
and foreground with proposed buttons.</p>
<a href="javascript:;" id="test6">Show</a>
<a href="javascript:;" id="test7">Move foreground</a>
<a href="javascript:;" id="test8">Dismiss</a>
<a href="javascript:;" id="test9">Subscribe to channel</a>
<a href="javascript:;" id="test10">Publish to channel</a>
<a href="javascript:;" id="test11">Unsubscribe to channel</a>
</div>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/Cobalt-Web/cobalt.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script>
Zepto(function($) {
cobalt.init();
cobalt.subscribe('cobalt:onWebLayerDismissed', function(data){
if (data && data.page === "weblayer_content_2.html") {
cobalt.toast('webLayer ' + data.page + ' closed')
if (data.data) {
cobalt.toast('webLayer result is ' + JSON.stringify(data.data))
}
}
});
app.touch('#test1', function() {
cobalt.webLayer.show("weblayer_content_1.html");
});
app.touch('#test2', function() {
cobalt.webLayer.show("weblayer_content_1.html", 1.2);
});
app.touch('#test3', function() {
cobalt.webLayer.show("weblayer_content_1.html", 0);
});
app.touch('#test4', function() {
cobalt.webLayer.show("weblayer_content_2.html");
});
app.touch('#test5', function() {
cobalt.webLayer.show("https://cobaltians.org/distantCobaltWebview/index.html");
});
app.touch('#test6', function() {
cobalt.webLayer.show("weblayer_content_3.html");
});
app.touch('#test7', function() {
cobalt.webLayer.bringToFront();
});
app.touch('#test8', function() {
cobalt.webLayer.dismiss();
});
app.touch('#test9', function() {
cobalt.subscribe('wl', function(data) {
cobalt.log('main webview received', data);
})
});
app.touch('#test10', function() {
cobalt.publish('wl', {'hip': 'hop'});
});
app.touch('#test11', function() {
cobalt.unsubscribe('wl')
});
app.initPage("Web layers");
})
</script>
</body>
</html>