-
Notifications
You must be signed in to change notification settings - Fork 1
/
button.js
50 lines (45 loc) · 1.53 KB
/
button.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
// Hello page
//
exports.View =
{
title: "Buttons",
elements:
[
{ control: "button", caption: "Button", foreground: "CornflowerBlue", background: "Black", binding: "text" },
{ control: "button", resource: "{imgCloud}", width: 125, height: 125, binding: "image" },
{ control: "button", icon: "star", caption: "Like", binding: "text" },
{ control: "button", borderless: true, icon: "thumb_up", caption: "Like", binding: "text" },
{ control: "button", icon: "xxxx", caption: "Bad Icon", binding: "text" },
{ control: "text", value: "{message}", fontsize: 12 },
]
}
exports.InitializeViewModel = function(context, session)
{
var viewModel =
{
imgCloud: Synchro.getResourceUrl(context, "cloud_system_256.png"),
message: null,
}
return viewModel;
}
function waitInterval(intervalMillis, callback)
{
setTimeout(function(){callback()}, intervalMillis);
}
exports.Commands =
{
text: function * (context, session, viewModel)
{
viewModel.message = "Caption button";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
image: function * (context, session, viewModel)
{
viewModel.message = "Image button";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
}