-
Notifications
You must be signed in to change notification settings - Fork 170
/
image.js
47 lines (38 loc) · 1.33 KB
/
image.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
var MARGIN = 16;
var MARGIN_LARGE = 32;
var scaleModes = ["auto", "fit", "fill", "stretch", "none"];
var page = tabris.create("Page", {
title: "ImageView",
topLevel: true
});
var imageView = tabris.create("ImageView", {
image: getImage(0),
background: "rgb(220, 220, 220)",
layoutData: {top: MARGIN, width: 200, height: 200, centerX: 0}
}).appendTo(page);
tabris.create("TextView", {
id: "imageSizeLabel",
layoutData: {left: MARGIN, top: [imageView, MARGIN_LARGE], width: 96},
text: "Image"
}).appendTo(page);
tabris.create("Picker", {
layoutData: {right: MARGIN, left: "#imageSizeLabel", baseline: "#imageSizeLabel"},
items: ["Large", "Small"]
}).on("change:selectionIndex", function(picker, index) {
imageView.set("image", getImage(index));
}).appendTo(page);
tabris.create("TextView", {
id: "scaleModeLabel",
layoutData: {left: MARGIN, top: ["#imageSizeLabel", MARGIN_LARGE], width: 96},
text: "Scale mode"
}).appendTo(page);
tabris.create("Picker", {
layoutData: {right: MARGIN, left: "#scaleModeLabel", baseline: "#scaleModeLabel"},
items: scaleModes
}).on("change:selectionIndex", function(picker, index) {
imageView.set("scaleMode", scaleModes[index]);
}).appendTo(page);
function getImage(index) {
return index === 0 ? {src: "images/salad.jpg", scale: 3} : {src: "images/landscape.jpg", scale: 3};
}
page.open();