-
-
Notifications
You must be signed in to change notification settings - Fork 424
/
theme.js
56 lines (51 loc) · 1.52 KB
/
theme.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
// Theme component
enyo.kind({
name: "Abcd.Theme",
kind: "Abcd.Item",
published: { index: "" },
classes: "theme",
components: [
{ name: "spinner", kind: "Image", src: "images/spinner-light.gif", classes: "spinner"},
{ name: "contentBox", showing: false, components: [
{ name: "itemImage", classes: "themeImage", kind: "Image", onload: "imageLoaded", onerror: "imageError" },
{ name: "itemText", classes: "themeText" }
]}
],
// 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 theme = Abcd.themes[this.index];
var entry = Abcd.entries[theme.img];
var image = Abcd.context.getDatabase()+"images/database/"+entry.code+".png";
var text = __$FC(theme.text);
if (Abcd.context.casevalue == 1)
text = text.toUpperCase();
this.$.itemImage.setAttribute("src", image);
this.$.itemText.removeClass("themeText0");
this.$.itemText.removeClass("themeText1");
this.$.itemText.removeClass("themeText2");
this.$.itemText.addClass("themeText"+Abcd.context.casevalue);
this.$.itemText.setContent(text);
this.addClass("themeColor"+this.index);
}
});