Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/html/collection.js
blob: 4c9c2b5d737efbc17a13f919d8b9077473211bb1 (plain)
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
// 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" },
			{ 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();
		}
	},
	
	// 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 = "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);
	}
});