@@ -11,23 +11,23 @@ enyo.kind({
11
11
classes : "board" ,
12
12
published : {
13
13
context : null ,
14
- } ,
14
+ } ,
15
15
components : [
16
16
{ kind : "Signals" , onEndOfSound : "endSound" } ,
17
17
{ components : [
18
- { name : "colorBar" , classes : "colorBar" } ,
18
+ { name : "colorBar" , classes : "colorBar" } ,
19
19
{ name : "home" , kind : "Abcd.HomeButton" } ,
20
20
{ kind : "Abcd.CaseButton" } ,
21
21
{ kind : "Abcd.LanguageButton" }
22
22
] } ,
23
23
{ components : [
24
24
{ name : "filterLetter" , kind : "Abcd.Letter" , letter : "" , classes : "filterLetter" } ,
25
25
{ name : "filterCollection" , kind : "Abcd.Collection" , index : 0 , classes : "filterCollection" , showing : false } ,
26
- { name : "itemCount" , content : "-/-" , classes : "itemCount" , showing : false } ,
26
+ { name : "itemCount" , content : "-/-" , classes : "itemCount" , showing : false } ,
27
27
{ name : "back" , kind : "Image" , src : "images/back.png" , showing : false , classes : "standardButton backButton" , ontap : "backTaped" } ,
28
28
{ name : "filter" , kind : "Image" , src : "images/filter.png" , showing : false , classes : "standardButton filterButton" , ontap : "filterTaped" } ,
29
29
{ name : "check" , kind : "Image" , src : "images/check.png" , showing : false , classes : "standardButton checkButton" , ontap : "checkTaped" } ,
30
- { name : "gameFinished" , kind : "Control" , showing : false , classes : "gameFinished" ,
30
+ { name : "gameFinished" , kind : "Control" , showing : false , classes : "gameFinished" ,
31
31
components : [
32
32
{
33
33
name : "gameFinishedMsg" ,
@@ -40,12 +40,12 @@ enyo.kind({
40
40
] }
41
41
]
42
42
}
43
- ] } ,
43
+ ] } ,
44
44
{ name : "box" , classes : "playbox" , components : [
45
45
] } ,
46
46
{ name : "filterPopup" , kind : "Abcd.FilterPopup" , onFilterChanged : "filterChanged" }
47
47
] ,
48
-
48
+
49
49
// Constructor
50
50
create : function ( ) {
51
51
this . inherited ( arguments ) ;
@@ -57,19 +57,19 @@ enyo.kind({
57
57
this . selected = null ;
58
58
this . forbidentry = false ;
59
59
this . filter = null ;
60
-
60
+
61
61
this . restoreContext ( ) ;
62
62
this . filterChanged ( { filter : this . filter } ) ;
63
63
if ( this . theme != - 1 )
64
64
this . doGame ( this . themeButton ) ;
65
65
else
66
66
this . displayButtons ( ) ;
67
-
67
+
68
68
if ( this . gamecount === entriesByGame ) {
69
69
this . showGameFinished ( ) ;
70
70
}
71
71
} ,
72
-
72
+
73
73
// Context handling
74
74
restoreContext : function ( ) {
75
75
if ( this . context == null || this . context == "" )
@@ -81,7 +81,7 @@ enyo.kind({
81
81
if ( values [ 4 ] != "" )
82
82
this . filter = { kind : values [ 4 ] , index : values [ 5 ] , letter : values [ 5 ] } ;
83
83
} ,
84
-
84
+
85
85
saveContext : function ( ) {
86
86
var values = [ ] ;
87
87
values . push ( this . theme ) ;
@@ -102,18 +102,18 @@ enyo.kind({
102
102
}
103
103
return values . join ( "|" ) ;
104
104
} ,
105
-
105
+
106
106
// Delete all the box content
107
107
cleanBox : function ( ) {
108
108
var items = [ ] ;
109
109
enyo . forEach ( this . $ . box . getControls ( ) , function ( item ) {
110
110
items . push ( item ) ;
111
- } ) ;
111
+ } ) ;
112
112
for ( var i = 0 ; i < items . length ; i ++ ) {
113
113
items [ i ] . destroy ( ) ;
114
- }
114
+ }
115
115
} ,
116
-
116
+
117
117
// Display game choice buttons
118
118
displayButtons : function ( ) {
119
119
this . cleanBox ( ) ;
@@ -123,7 +123,7 @@ enyo.kind({
123
123
this . $ . colorBar . addClass ( "themeColor" + this . theme ) ;
124
124
if ( this . filter == null )
125
125
this . $ . filterLetter . hide ( ) ;
126
-
126
+
127
127
// Draw From picture buttons
128
128
this . $ . box . createComponent (
129
129
{ kind : "Abcd.PlayTypeButton" , from : "picture" , to : "letter" + Abcd . context . casevalue , ontap : "doGame" , theme : "play-button-color1" } ,
@@ -133,7 +133,7 @@ enyo.kind({
133
133
{ kind : "Abcd.PlayTypeButton" , from : "picture" , to : "listen" , ontap : "doGame" , theme : "play-button-color1" } ,
134
134
{ owner : this }
135
135
) . render ( ) ;
136
-
136
+
137
137
// Draw From letter buttons
138
138
this . $ . box . createComponent (
139
139
{ kind : "Abcd.PlayTypeButton" , from : "letter" + Abcd . context . casevalue , to : "picture" , ontap : "doGame" , theme : "play-button-color2" } ,
@@ -152,32 +152,32 @@ enyo.kind({
152
152
this . $ . box . createComponent (
153
153
{ kind : "Abcd.PlayTypeButton" , from : "listen" , to : "letter" + Abcd . context . casevalue , ontap : "doGame" , theme : "play-button-color3" } ,
154
154
{ owner : this }
155
- ) . render ( ) ;
155
+ ) . render ( ) ;
156
156
} ,
157
-
157
+
158
158
// Localization changed
159
159
setLocale : function ( ) {
160
160
// Remove filter because too risky
161
161
this . filter = null ;
162
- this . $ . filterLetter . hide ( ) ;
163
- this . $ . filterCollection . hide ( ) ;
164
-
162
+ this . $ . filterLetter . hide ( ) ;
163
+ this . $ . filterCollection . hide ( ) ;
164
+
165
165
// If playing, change game because could inexist in the current language
166
166
if ( this . theme != - 1 )
167
167
this . computeGame ( ) ;
168
-
168
+
169
169
} ,
170
-
170
+
171
171
// Case changed
172
172
setCase : function ( ) {
173
173
// Redraw button
174
174
enyo . forEach ( this . $ . box . getControls ( ) , function ( item ) {
175
175
if ( item . kind == 'Abcd.Entry' )
176
176
item . indexChanged ( ) ;
177
177
else
178
- item . setCase ( ) ;
178
+ item . setCase ( ) ;
179
179
} ) ;
180
-
180
+
181
181
// Redraw filter letter and filter popup
182
182
if ( this . filter != null ) {
183
183
if ( this . filter . kind == "Abcd.Letter" )
@@ -186,28 +186,28 @@ enyo.kind({
186
186
this . $ . filterCollection . indexChanged ( ) ;
187
187
}
188
188
} ,
189
-
189
+
190
190
// Display filter dialog
191
191
filterTaped : function ( ) {
192
192
this . $ . filterPopup . display ( this . filter ) ;
193
193
} ,
194
-
194
+
195
195
// Process filter change
196
196
filterChanged : function ( s , e ) {
197
197
this . filter = s . filter ;
198
198
this . $ . filterLetter . hide ( ) ;
199
- this . $ . filterCollection . hide ( ) ;
199
+ this . $ . filterCollection . hide ( ) ;
200
200
if ( this . filter != null ) {
201
201
if ( this . filter . kind == "Abcd.Letter" ) {
202
202
this . $ . filterLetter . show ( ) ;
203
203
this . $ . filterLetter . setLetter ( this . filter . letter ) ;
204
204
} else {
205
205
this . $ . filterCollection . show ( ) ;
206
- this . $ . filterCollection . setIndex ( this . filter . index ) ;
206
+ this . $ . filterCollection . setIndex ( this . filter . index ) ;
207
207
}
208
208
}
209
209
} ,
210
-
210
+
211
211
// Convert value to entry option
212
212
convertToEntryOption : function ( value ) {
213
213
return {
@@ -216,9 +216,9 @@ enyo.kind({
216
216
textonly : value . substr ( 0 , 6 ) == "letter"
217
217
} ;
218
218
} ,
219
-
219
+
220
220
// Start game
221
- doGame : function ( button , event ) {
221
+ doGame : function ( button , event ) {
222
222
// Redraw bar
223
223
Abcd . changeVisibility ( this , { home : false , back : true , filter : false , check : true , itemCount : true } ) ;
224
224
this . themeButton = button ;
@@ -227,32 +227,32 @@ enyo.kind({
227
227
else this . theme = 6 ;
228
228
this . $ . colorBar . removeClass ( "themeColor-1" ) ;
229
229
this . $ . colorBar . addClass ( "themeColor" + this . theme ) ;
230
-
230
+
231
231
// Compute game
232
232
this . computeGame ( ) ;
233
233
} ,
234
-
234
+
235
235
// Compute game
236
236
computeGame : function ( ) {
237
237
// Compute card to find
238
238
this . cleanBox ( ) ;
239
239
this . forbidentry = false ;
240
240
this . $ . itemCount . setContent ( ( this . gamecount + 1 ) + "/" + entriesByGame ) ;
241
241
var tofind = Abcd . randomEntryIndex ( undefined , this . filter ) ;
242
- var options = this . convertToEntryOption ( this . themeButton . from ) ;
242
+ var options = this . convertToEntryOption ( this . themeButton . from ) ;
243
243
var fromEntry = this . from = this . $ . box . createComponent (
244
244
{ kind : "Abcd.Entry" , index :tofind , soundonly : options [ "soundonly" ] , imageonly : options [ "imageonly" ] , textonly : options [ "textonly" ] , ontap : "entryTaped" } ,
245
245
{ owner : this }
246
246
) ;
247
247
fromEntry . addClass ( "entryPlayFrom" ) ;
248
248
fromEntry . render ( ) ;
249
-
249
+
250
250
// Play from card if its a sound
251
251
if ( options [ "soundonly" ] ) {
252
252
this . playing = fromEntry ;
253
- this . playing . play ( Abcd . sound ) ;
253
+ this . playing . play ( Abcd . sound ) ;
254
254
}
255
-
255
+
256
256
// Compute cards to choose
257
257
var excludes = [ ] ;
258
258
excludes . push ( tofind ) ;
@@ -261,7 +261,7 @@ enyo.kind({
261
261
excludes . push ( wrong ) ;
262
262
}
263
263
excludes = Abcd . mix ( excludes ) ;
264
-
264
+
265
265
// Draw cards
266
266
var len = excludes . length ;
267
267
for ( var i = 0 ; i < len ; i ++ ) {
@@ -273,29 +273,29 @@ enyo.kind({
273
273
toEntry . addClass ( "entryPlayTo" ) ;
274
274
toEntry . render ( ) ;
275
275
}
276
-
276
+
277
277
// Save context
278
- Abcd . saveContext ( ) ;
278
+ Abcd . saveContext ( ) ;
279
279
} ,
280
-
280
+
281
281
// Entry taped play sound and/or select entry
282
282
entryTaped : function ( entry , event ) {
283
283
// No selection now
284
284
if ( this . forbidentry )
285
285
return ;
286
-
286
+
287
287
// Play sound
288
288
if ( entry . soundonly ) {
289
289
if ( this . playing != null )
290
290
this . playing . abort ( ) ;
291
291
this . playing = entry ;
292
292
this . playing . play ( Abcd . sound ) ;
293
293
}
294
-
294
+
295
295
// Don't select the from entry
296
296
if ( entry . hasClass ( "entryPlayFrom" ) )
297
297
return ;
298
-
298
+
299
299
// Select the entry
300
300
if ( ! entry . hasClass ( "entryPlaySelected" ) ) {
301
301
if ( this . selected != null )
@@ -310,6 +310,8 @@ enyo.kind({
310
310
Abcd . changeVisibility ( this , { home : false , back : false , filter : false , check : false , itemCount : false } ) ;
311
311
Abcd . hideLang ( ) ;
312
312
this . $ . caseButton . hide ( ) ;
313
+ this . $ . colorBar . removeClass ( "themeColor" + this . theme ) ;
314
+ this . $ . colorBar . addClass ( "themeColor-1" ) ;
313
315
var playMode = this ;
314
316
requirejs ( [ "webL10n" ] , function ( webL10n ) {
315
317
playMode . $ . gameFinishedMsg . setContent ( webL10n . get ( "GameFinised" ) ) ;
@@ -322,7 +324,7 @@ enyo.kind({
322
324
Abcd . showLang ( ) ;
323
325
this . $ . caseButton . show ( ) ;
324
326
} ,
325
-
327
+
326
328
replayTaped : function ( ) {
327
329
this . hideGameFinished ( ) ;
328
330
Abcd . changeVisibility ( this , { home : false , back : true , filter : false , check : true , itemCount : true } ) ;
@@ -334,21 +336,21 @@ enyo.kind({
334
336
this . hideGameFinished ( ) ;
335
337
this . backTaped ( ) ;
336
338
} ,
337
-
339
+
338
340
// Go to the home of the game
339
341
backTaped : function ( ) {
340
342
this . $ . colorBar . removeClass ( "themeColor" + this . theme ) ;
341
343
this . theme = - 1 ;
342
344
this . gamecount = 0 ;
343
- this . selected = null ;
345
+ this . selected = null ;
344
346
this . displayButtons ( ) ;
345
347
} ,
346
-
348
+
347
349
// Check taped
348
350
checkTaped : function ( ) {
349
351
this . forbidentry = true ;
350
352
if ( this . playing != null )
351
- this . playing . abort ( ) ;
353
+ this . playing . abort ( ) ;
352
354
if ( this . selected == null ) {
353
355
Abcd . sound . play ( "audio/disappointed" ) ;
354
356
this . selected = this . from ;
@@ -363,27 +365,27 @@ enyo.kind({
363
365
this . selected . addClass ( "entryPlayWrong" ) ;
364
366
}
365
367
} ,
366
-
368
+
367
369
// End sound
368
370
endSound : function ( e , s ) {
369
371
// Prematured end
370
372
if ( this . selected == null )
371
373
return ;
372
-
374
+
373
375
// Bad check, retry
374
376
if ( s . sound == "audio/disappointed" ) {
375
377
this . selected . removeClass ( "entryPlaySelected" ) ;
376
378
this . selected . removeClass ( "entryPlayWrong" ) ;
377
379
this . selected = null ;
378
380
this . forbidentry = false ;
379
-
381
+
380
382
// Good check
381
383
} else if ( s . sound == "audio/applause" ) {
382
384
// Clean state
383
385
this . selected . removeClass ( "entryPlaySelected" ) ;
384
386
this . selected . removeClass ( "entryPlayRight" ) ;
385
- this . selected = null ;
386
-
387
+ this . selected = null ;
388
+
387
389
// Next game or try another game
388
390
if ( ++ this . gamecount == entriesByGame ) {
389
391
this . showGameFinished ( ) ;
0 commit comments