-
Notifications
You must be signed in to change notification settings - Fork 1
/
buttontest.js
92 lines (82 loc) · 4.83 KB
/
buttontest.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
// Button test page (lots of variables/permutations)
//
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: "stackpanel", orientation: "Horizontal", contents: [
{ control: "text", value: "Enabled:", fontsize: 10, verticalAlignment: "Center" },
{ control: "toggle", binding: "enabled", fontsize: 12, verticalAlignment: "Center" },
] },
{ control: "button", caption: "No icon", icon: "foo", binding: { command: "vary", amount: 1 } },
{ control: "stackpanel", orientation: "Horizontal", contents: [
{ control: "button", icon: "{buttonIcon}", caption: "{buttonCap}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", caption: "{buttonCap}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", icon: "{buttonIcon}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
]},
{ control: "stackpanel", orientation: "Horizontal", contents: [
{ control: "button", width: 150, icon: "{buttonIcon}", caption: "{buttonCap}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", width: 150, caption: "{buttonCap}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", width: 75, icon: "{buttonIcon}", binding: "text", enabled: "{enabled}", style: "btnStyle" },
]},
{ control: "stackpanel", orientation: "Horizontal", contents: [
{ control: "button", borderless: true, icon: "{buttonIcon}", caption: "{buttonCap}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}"},
{ control: "button", borderless: true, caption: "{buttonCap}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", borderless: true, icon: "{buttonIcon}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
]},
{ control: "stackpanel", orientation: "Horizontal", contents: [
{ control: "button", borderless: true, foreground: "Black", icon: "{buttonIcon}", caption: "{buttonCap}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", borderless: true, foreground: "White", caption: "{buttonCap}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
{ control: "rectangle", color: "Red", width: "{spacerWidth}", height: "{spacerHeight}" },
{ control: "button", borderless: true, foreground: "Red", icon: "{buttonIcon}", binding: "text", height: "{buttonHeight}", enabled: "{enabled}", style: "btnStyle" },
]},
{ control: "text", value: "{message}", fontsize: 12 },
]
}
exports.InitializeViewModel = function(context, session)
{
var viewModel =
{
enabled: true,
buttonCap: "Like",
buttonIcon: "thumb_up",
buttonHeight: 45,
spacerWidth: 25,
spacerHeight: 60,
btnStyle: { background: "Gray", xfontsize: 20 },
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 = "";
},
}