-
-
Notifications
You must be signed in to change notification settings - Fork 422
/
collection.js
56 lines (51 loc) · 1.59 KB
/
collection.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
// Collection component
enyo.kind({
name: "Abcd.Collection",
kind: "Abcd.Item",
published: { index: "" },
classes: "collection",
components: [
{ name: "spinner", kind: "Image", src: "images/spinner-light.gif", classes: "spinner-small"},
{ name: "contentBox", showing: false, components: [
{ name: "itemImage", classes: "collectionImage", kind: "Image", onload: "imageLoaded", onerror: "imageError" },
{ name: "itemText", classes: "collectionText" }
]}
],
// Constructor
create: function() {
this.inherited(arguments);
this.indexChanged();
},
// Display only when image is load
imageLoaded: function() {
if (this.index !== "") {
this.$.spinner.hide();
this.$.contentBox.show();
}
},
// Error loading image, probably lost connection to database
imageError: function() {
Abcd.goHome();
},
// Localization changed, update text
setLocale: function() {
this.indexChanged();
this.inherited(arguments);
},
// Card setup
indexChanged: function() {
var collection = Abcd.collections[this.index];
var entry = Abcd.entries[collection.img];
var image = Abcd.context.getDatabase()+"images/database/"+entry.code+".png";
var text = __$FC(collection.text);
if (Abcd.context.casevalue == 1)
text = text.toUpperCase();
this.$.itemImage.setAttribute("src", image);
this.$.itemText.removeClass("collectionText0");
this.$.itemText.removeClass("collectionText1");
this.$.itemText.removeClass("collectionText2");
this.$.itemText.addClass("collectionText"+Abcd.context.casevalue);
this.$.itemText.setContent(text);
this.addClass("themeColor"+collection.theme);
}
});