@@ -10,11 +10,10 @@ define(["iter2d", "csshelper", "evileval", "net"], function(iter2d, csshelper, e
10
10
cell . context = context ;
11
11
cell . hint = createCellDiv ( "hint" , row , col , height , width ) ;
12
12
cell . ui = makeCellUi ( row , col , height , width ) ;
13
- addCellUiListener ( cell . ui ) ;
14
13
return cell ;
15
14
} ;
16
15
17
- var addCellUiListener = function ( cellUi ) {
16
+ var addCellUiListeners = function ( cellUi , store ) {
18
17
var childNodes = cellUi . childNodes ;
19
18
cellUi . addEventListener ( "mouseover" , function ( e ) {
20
19
for ( var i = 0 ; i < childNodes . length ; i ++ ) {
@@ -26,7 +25,7 @@ define(["iter2d", "csshelper", "evileval", "net"], function(iter2d, csshelper, e
26
25
childNodes [ i ] . style . visibility = "hidden" ;
27
26
} ;
28
27
} ) ;
29
-
28
+ addLoadAnimationHandler ( cellUi . id , store ) ;
30
29
} ;
31
30
32
31
var makeCanvasAnimation = function ( context ) {
@@ -125,26 +124,34 @@ define(["iter2d", "csshelper", "evileval", "net"], function(iter2d, csshelper, e
125
124
return cellDiv ;
126
125
} ;
127
126
128
- var makeIcon = function ( classNames ) {
127
+ var makeIcon = function ( classNames , id ) {
129
128
var icon = document . createElement ( 'span' ) ;
130
129
icon . style . visibility = "hidden" ;
131
130
icon . style . cursor = "pointer" ;
132
131
icon . className = classNames ;
132
+ if ( id ) {
133
+ icon . id = id ;
134
+ }
133
135
return icon ;
134
136
} ;
135
137
138
+ var loadIconSuffix = "-load-icon" ;
136
139
var makeCellUi = function ( row , col , height , width ) {
137
140
var cellUi = createCellDiv ( "cellUi" , row , col , height , width ) ;
138
- var loadAnimationIcon = makeIcon ( "fa fa-folder-open-o fa-lg" ) ;
141
+ var loadAnimationIcon = makeIcon ( "fa fa-folder-open-o fa-lg" , cellUi . id + loadIconSuffix ) ;
139
142
cellUi . appendChild ( loadAnimationIcon ) ;
143
+ return cellUi ;
144
+ } ;
145
+
146
+ var addLoadAnimationHandler = function ( cellUiId , store ) {
147
+ var loadAnimationIcon = document . getElementById ( cellUiId + loadIconSuffix ) ;
140
148
loadAnimationIcon . addEventListener ( 'click' , function ( ) {
141
- alert ( "not today" ) ;
142
- //TODO load list of animations from store
149
+ store . loadAnimationList ( ) . then ( function ( fileUris ) {
150
+ alert ( fileUris ) ;
151
+ } ) ;
143
152
//TODO display list in dialog
144
153
//TODO load animation on canvasAnim
145
154
} ) ;
146
-
147
- return cellUi ;
148
155
} ;
149
156
150
157
var addHintListeners = function ( cells ) {
@@ -176,7 +183,7 @@ define(["iter2d", "csshelper", "evileval", "net"], function(iter2d, csshelper, e
176
183
exquis . editorController . show ( ) ;
177
184
} ;
178
185
179
- var editIcon = makeIcon ( "fa fa-pencil-square-o fa-lg" ) ;
186
+ var editIcon = makeIcon ( "fa fa-pencil-square-o fa-lg" , cell . ui . id + "-edit-icon" ) ;
180
187
editIcon . addEventListener ( 'click' , edit , false ) ;
181
188
cell . ui . appendChild ( editIcon ) ;
182
189
} ) ;
@@ -191,18 +198,19 @@ define(["iter2d", "csshelper", "evileval", "net"], function(iter2d, csshelper, e
191
198
document . addEventListener ( 'click' , possiblyHideEditor , true ) ;
192
199
} ;
193
200
194
- var init = function ( assName , animUris , makeEditorView , makeEditorController ) {
201
+ var init = function ( assName , animUris , makeEditorView , makeEditorController , store ) {
195
202
var container = document . getElementById ( "container" ) ,
196
203
exquis = { } ;
197
204
exquis . assName = assName ;
198
205
199
- //TODO give the code url as argument instead of animCode
200
- // canvasAnim should have a method to load the code from the url:
206
+ //TODO canvasAnim should have a method to load the source code from the url:
201
207
// getSourceCodeString (which reads from the cache of the canvasAnim, or the store)
208
+ // This becomes necessary when start to have code other than javascript
202
209
exquis . cells = iter2d . map2dArray ( animUris , function ( animUri , row , col ) {
203
210
var height = 150 ,
204
211
width = 150 ,
205
212
cell = makeCell ( row , col , height , width ) ;
213
+ addCellUiListeners ( cell . ui , store ) ;
206
214
cell . canvasAnim = makeCanvasAnimation ( cell . context ) ;
207
215
evileval . loadJsAnim ( animUri ) . then ( function ( animationCodeClone ) {
208
216
cell . canvasAnim . setAnimation ( animationCodeClone , animUri ) ;
0 commit comments