Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/html/buttons.js
blob: 3384e7ca6c4f84bf746cfaeb5334f4021970cca6 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94


// Go home button
enyo.kind({
	name: "Abcd.HomeButton",
	kind: enyo.Control,
	components: [
		{name: "home", kind: "Image", src: "images/home.png", classes: "backButton", ontap: "goHome"},
	],
	
	// Constructor
	rendered: function() {
		this.inherited(arguments);
	},

	// Go back home
	goHome: function() {
		Abcd.goHome();
	}	
});


// Switch case button
var caseVisibilityTab = [
	{switchToLower: false, switchToUpper: true, switchToScript: false},
	{switchToLower: false, switchToUpper: false, switchToScript: true},
	{switchToLower: true, switchToUpper: false, switchToScript: false}
];

enyo.kind({
	name: "Abcd.CaseButton",
	kind: enyo.Control,
	classes: "switchCase",
	components: [
		{name: "switchToUpper", kind: "Image", src: "images/case0.png", classes: "switchCaseButton", ontap: "localUpper"},			
		{name: "switchToScript", kind: "Image", src: "images/case1.png", showing: false, classes: "switchCaseButton", ontap: "localScript"},			
		{name: "switchToLower", kind: "Image", src: "images/case2.png", showing: false, classes: "switchCaseButton", ontap: "localLower"},			
	],
	
	// Constructor
	rendered: function() {
		this.inherited(arguments);
		Abcd.changeVisibility(this, caseVisibilityTab[Abcd.context.casevalue]);
	},
	
	// Change current case
	localUpper: function() {
		Abcd.changeVisibility(this, caseVisibilityTab[1]);
		Abcd.setCase(1);
	},
	
	localLower: function() {
		Abcd.changeVisibility(this, caseVisibilityTab[0]);
		Abcd.setCase(0);
	},
	
	localScript: function() {
		Abcd.changeVisibility(this, caseVisibilityTab[2]);	
		Abcd.setCase(2);
	}
});



// Switch language button
enyo.kind({
	name: "Abcd.LanguageButton",
	kind: enyo.Control,
	classes: "switchLang",
	components: [
		{name: "switchToFrench", kind: "Image", src: "images/us.png", showing: false, classes: "switchLangButton", ontap: "localFrench"},
		{name: "switchToEnglish", kind: "Image", src: "images/fr.png", classes: "switchLangButton", ontap: "localEnglish"}	
	],
	
	// Constructor
	rendered: function() {
		this.inherited(arguments);
		if (Abcd.context.lang == 'en')
			Abcd.changeVisibility(this, {switchToEnglish: false, switchToFrench: true});
		else
			Abcd.changeVisibility(this, {switchToEnglish: true, switchToFrench: false});
	},
	
	// Change current language
	localEnglish: function() {
		Abcd.changeVisibility(this, {switchToEnglish: false, switchToFrench: true});
		Abcd.setLocale(Abcd.enTexts);
	},
	
	localFrench: function() {
		Abcd.changeVisibility(this, {switchToEnglish: true, switchToFrench: false});
		Abcd.setLocale(Abcd.frTexts);
	}
});