Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/html/item.js
blob: b210035fe4ac2edecbb76be30b5bf23e646360a5 (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
52
// Moveable item
enyo.kind({
	name: "Abcd.Item",
	kind: enyo.Control,
	published: { x: -1, y: -1, z: -1, selected: false },
	
	// Constructor
	create: function() {
		this.inherited(arguments);
		this.xChanged();
		this.yChanged();
		this.zChanged();
		this.selectedChanged();
	},
	
	// Localization changed, update 
	setLocale: function() {
		this.render();
	},
	
	// Coordinate setup
	xChanged: function() {
		if (this.x != -1) this.applyStyle("margin-left", this.x+"px");
	},
	
	// Coordinate setup
	yChanged: function() {
		if (this.y != -1) this.applyStyle("margin-top", this.y+"px");
	},
	
	// Coordinate setup
	zChanged: function() {	
		if (this.z != -1) this.applyStyle("z-index", this.z);
	},
	
	// Selection changed
	selectedChanged: function() {
		var className = "item"+this.kind.substring(5)+"-selected";
		if (this.selected)
			this.addClass(className);
		else
			this.removeClass(className);
	},
	
	// Change position
	moveTo: function(x, y) {
		this.x = x;
		this.xChanged();
		this.y = y;
		this.yChanged();
	}
});