resin 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/README.markdown +2 -0
  2. data/amber/bin/nodecompile.js +3 -3
  3. data/amber/css/amber.css +47 -23
  4. data/amber/images/off.amber.png +0 -0
  5. data/amber/images/offHover.amber.png +0 -0
  6. data/amber/images/sprite.amber.png +0 -0
  7. data/amber/images/tinylogo.amber.png +0 -0
  8. data/amber/js/Benchfib.deploy.js +34 -34
  9. data/amber/js/Benchfib.js +49 -49
  10. data/amber/js/Canvas.deploy.js +937 -937
  11. data/amber/js/Canvas.js +1622 -1622
  12. data/amber/js/Compiler-Tests.deploy.js +97 -0
  13. data/amber/js/Compiler-Tests.js +137 -0
  14. data/amber/js/Compiler.deploy.js +1030 -924
  15. data/amber/js/Compiler.js +1613 -1467
  16. data/amber/js/Documentation.deploy.js +417 -417
  17. data/amber/js/Documentation.js +728 -728
  18. data/amber/js/Examples.deploy.js +24 -13
  19. data/amber/js/Examples.js +36 -19
  20. data/amber/js/IDE.deploy.js +1583 -1527
  21. data/amber/js/IDE.js +2586 -2510
  22. data/amber/js/Kernel-Announcements.deploy.js +19 -19
  23. data/amber/js/Kernel-Announcements.js +28 -28
  24. data/amber/js/Kernel-Classes.deploy.js +332 -229
  25. data/amber/js/Kernel-Classes.js +532 -384
  26. data/amber/js/Kernel-Collections.deploy.js +1516 -1712
  27. data/amber/js/Kernel-Collections.js +2436 -2712
  28. data/amber/js/Kernel-Exceptions.deploy.js +85 -62
  29. data/amber/js/Kernel-Exceptions.js +131 -98
  30. data/amber/js/Kernel-Methods.deploy.js +326 -378
  31. data/amber/js/Kernel-Methods.js +473 -525
  32. data/amber/js/Kernel-Objects.deploy.js +1777 -2428
  33. data/amber/js/Kernel-Objects.js +2599 -3426
  34. data/amber/js/Kernel-Tests.deploy.js +871 -772
  35. data/amber/js/Kernel-Tests.js +1207 -1083
  36. data/amber/js/Kernel-Transcript.deploy.js +57 -57
  37. data/amber/js/Kernel-Transcript.js +94 -94
  38. data/amber/js/SUnit.deploy.js +116 -116
  39. data/amber/js/SUnit.js +211 -211
  40. data/amber/js/amber.js +10 -11
  41. data/amber/js/boot.js +132 -156
  42. data/amber/js/init.js +2 -2
  43. data/amber/js/parser.js +2095 -3014
  44. data/amber/js/parser.pegjs +1 -1
  45. data/amber/st/Benchfib.st +22 -22
  46. data/amber/st/Canvas.st +471 -471
  47. data/amber/st/Compiler-Tests.st +471 -0
  48. data/amber/st/Compiler.st +858 -794
  49. data/amber/st/Examples.st +22 -5
  50. data/amber/st/IDE.st +1326 -1291
  51. data/amber/st/Kernel-Announcements.st +2 -2
  52. data/amber/st/Kernel-Classes.st +148 -90
  53. data/amber/st/Kernel-Collections.st +950 -1061
  54. data/amber/st/Kernel-Exceptions.st +33 -25
  55. data/amber/st/Kernel-Methods.st +151 -151
  56. data/amber/st/Kernel-Objects.st +891 -1036
  57. data/amber/st/Kernel-Tests.st +622 -544
  58. data/amber/st/Kernel-Transcript.st +38 -38
  59. data/amber/st/SUnit.st +53 -53
  60. metadata +27 -20
@@ -28,7 +28,7 @@ literalArray = "#(" ws lits:(lit:literal ws {return lit._value()})* ws ")" {
28
28
  return smalltalk.ValueNode._new()
29
29
  ._value_(lits)
30
30
  }
31
- dynamicArray = "{" ws expressions:expressions? ws "}" {
31
+ dynamicArray = "{" ws expressions:expressions? ws "."? "}" {
32
32
  return smalltalk.DynamicArrayNode._new()
33
33
  ._nodes_(expressions)
34
34
  }
@@ -1,7 +1,7 @@
1
1
  Smalltalk current createPackage: 'Benchfib' properties: #{}!
2
2
  Object subclass: #Benchfib
3
3
  instanceVariableNames: ''
4
- category: 'Benchfib'!
4
+ package: 'Benchfib'!
5
5
 
6
6
  !Benchfib class methodsFor: 'not yet classified'!
7
7
 
@@ -49,27 +49,6 @@ benchmark
49
49
  ^ count
50
50
  !
51
51
 
52
- tinyBenchmarks
53
- "Report the results of running the two tiny Squeak benchmarks.
54
- ar 9/10/1999: Adjusted to run at least 1 sec to get more stable results"
55
- "0 tinyBenchmarks"
56
- "On a 292 MHz G3 Mac: 22727272 bytecodes/sec; 984169 sends/sec"
57
- "On a 400 MHz PII/Win98: 18028169 bytecodes/sec; 1081272 sends/sec"
58
- | t1 t2 r n1 n2 |
59
- n1 := 1.
60
- [t1 := Date millisecondsToRun: [n1 benchmark].
61
- t1 < 1000] whileTrue:[n1 := n1 * 2]. "Note: #benchmark's runtime is about O(n)"
62
-
63
- n2 := 16.
64
- [t2 := Date millisecondsToRun: [r := n2 benchFib].
65
- t2 < 1000] whileTrue:[n2 := n2 + 1].
66
- "Note: #benchFib's runtime is about O(k^n),
67
- where k is the golden number = (1 + 5 sqrt) / 2 = 1.618...."
68
-
69
- ^ ((n1 * 500000 * 1000) / t1) printString, ' bytecodes/sec; ',
70
- ((r * 1000) / t2) printString, ' sends/sec'
71
- !
72
-
73
52
  jsbenchFib
74
53
 
75
54
  <if (this < 2) {
@@ -118,6 +97,27 @@ jstinyBenchmarks
118
97
  "Note: #jsbenchFib's runtime is about O(k^n),
119
98
  where k is the golden number = (1 + 5 sqrt) / 2 = 1.618...."
120
99
 
100
+ ^ ((n1 * 500000 * 1000) / t1) printString, ' bytecodes/sec; ',
101
+ ((r * 1000) / t2) printString, ' sends/sec'
102
+ !
103
+
104
+ tinyBenchmarks
105
+ "Report the results of running the two tiny Squeak benchmarks.
106
+ ar 9/10/1999: Adjusted to run at least 1 sec to get more stable results"
107
+ "0 tinyBenchmarks"
108
+ "On a 292 MHz G3 Mac: 22727272 bytecodes/sec; 984169 sends/sec"
109
+ "On a 400 MHz PII/Win98: 18028169 bytecodes/sec; 1081272 sends/sec"
110
+ | t1 t2 r n1 n2 |
111
+ n1 := 1.
112
+ [t1 := Date millisecondsToRun: [n1 benchmark].
113
+ t1 < 1000] whileTrue:[n1 := n1 * 2]. "Note: #benchmark's runtime is about O(n)"
114
+
115
+ n2 := 16.
116
+ [t2 := Date millisecondsToRun: [r := n2 benchFib].
117
+ t2 < 1000] whileTrue:[n2 := n2 + 1].
118
+ "Note: #benchFib's runtime is about O(k^n),
119
+ where k is the golden number = (1 + 5 sqrt) / 2 = 1.618...."
120
+
121
121
  ^ ((n1 * 500000 * 1000) / t1) printString, ' bytecodes/sec; ',
122
122
  ((r * 1000) / t2) printString, ' sends/sec'
123
123
  ! !
@@ -1,832 +1,812 @@
1
1
  Smalltalk current createPackage: 'Canvas' properties: #{}!
2
- Object subclass: #Widget
3
- instanceVariableNames: ''
4
- category: 'Canvas'!
2
+ Object subclass: #HTMLCanvas
3
+ instanceVariableNames: 'root'
4
+ package: 'Canvas'!
5
5
 
6
- !Widget methodsFor: 'adding'!
6
+ !HTMLCanvas methodsFor: 'accessing'!
7
7
 
8
- appendToBrush: aTagBrush
9
- self appendToJQuery: aTagBrush asJQuery
8
+ root
9
+ ^root
10
10
  !
11
11
 
12
- appendToJQuery: aJQuery
13
- self renderOn: (HTMLCanvas onJQuery: aJQuery)
12
+ root: aTagBrush
13
+ root := aTagBrush
14
14
  ! !
15
15
 
16
- !Widget methodsFor: 'rendering'!
16
+ !HTMLCanvas methodsFor: 'adding'!
17
17
 
18
- renderOn: html
19
- self
18
+ with: anObject
19
+ ^self root with: anObject
20
20
  ! !
21
21
 
22
- Object subclass: #TagBrush
23
- instanceVariableNames: 'canvas element'
24
- category: 'Canvas'!
22
+ !HTMLCanvas methodsFor: 'initialization'!
25
23
 
26
- !TagBrush methodsFor: 'accessing'!
24
+ initialize
25
+ super initialize.
26
+ root ifNil: [root := TagBrush fromString: 'div' canvas: self]
27
+ !
27
28
 
28
- element
29
- ^element
29
+ initializeFromJQuery: aJQuery
30
+ root := TagBrush fromJQuery: aJQuery canvas: self
30
31
  ! !
31
32
 
32
- !TagBrush methodsFor: 'adding'!
33
+ !HTMLCanvas methodsFor: 'tags'!
33
34
 
34
- contents: anObject
35
- self
36
- empty;
37
- append: anObject
35
+ a
36
+ ^self tag: 'a'
38
37
  !
39
38
 
40
- addBrush: aTagBrush
41
- self appendChild: aTagBrush element.
42
- ^aTagBrush
39
+ abbr
40
+ ^self tag: 'abbr'
43
41
  !
44
42
 
45
- with: anObject
46
- self append: anObject
43
+ address
44
+ ^self tag: 'address'
47
45
  !
48
46
 
49
- append: anObject
50
- anObject appendToBrush: self
47
+ area
48
+ ^self tag: 'area'
51
49
  !
52
50
 
53
- appendToBrush: aTagBrush
54
- aTagBrush addBrush: self
51
+ article
52
+ ^self tag: 'article'
55
53
  !
56
54
 
57
- appendBlock: aBlock
58
- | root |
59
- root := canvas root.
60
- canvas root: self.
61
- aBlock value: canvas.
62
- canvas root: root
55
+ aside
56
+ ^self tag: 'aside'
63
57
  !
64
58
 
65
- appendChild: anElement
66
- "In IE7 and IE8 appendChild fails on several node types. So we need to check"
67
- <var element=self['@element'];
68
- if (null == element.canHaveChildren || element.canHaveChildren) {
69
- element.appendChild(anElement);
70
- } else {
71
- element.text = String(element.text) + anElement.innerHTML;
72
- } >
59
+ audio
60
+ ^self tag: 'audio'
73
61
  !
74
62
 
75
- appendString: aString
76
- self appendChild: (self createTextNodeFor: aString)
63
+ base
64
+ ^self tag: 'base'
77
65
  !
78
66
 
79
- empty
80
- self asJQuery empty
81
- ! !
82
-
83
- !TagBrush methodsFor: 'attributes'!
84
-
85
- at: aString put: aValue
86
- <self['@element'].setAttribute(aString, aValue)>
67
+ blockquote
68
+ ^self tag: 'blockquote'
87
69
  !
88
70
 
89
- removeAt: aString
90
- <self['@element'].removeAttribute(aString)>
71
+ body
72
+ ^self tag: 'body'
91
73
  !
92
74
 
93
- class: aString
94
- <self['@element'].className = aString>
75
+ br
76
+ ^self tag: 'br'
95
77
  !
96
78
 
97
- id: aString
98
- self at: 'id' put: aString
79
+ button
80
+ ^self tag: 'button'
99
81
  !
100
82
 
101
- src: aString
102
- self at: 'src' put: aString
83
+ canvas
84
+ ^self tag: 'canvas'
103
85
  !
104
86
 
105
- href: aString
106
- self at: 'href' put: aString
87
+ caption
88
+ ^self tag: 'caption'
107
89
  !
108
90
 
109
- title: aString
110
- self at: 'title' put: aString
91
+ cite
92
+ ^self tag: 'cite'
111
93
  !
112
94
 
113
- style: aString
114
- self at: 'style' put: aString
95
+ code
96
+ ^self tag: 'code'
115
97
  !
116
98
 
117
- type: aString
118
- self at: 'type' put: aString
99
+ col
100
+ ^self tag: 'col'
119
101
  !
120
102
 
121
- media: aString
122
- self at: 'media' put: aString
103
+ colgroup
104
+ ^self tag: 'colgroup'
123
105
  !
124
106
 
125
- rel: aString
126
- self at: 'rel' put: aString
107
+ command
108
+ ^self tag: 'command'
127
109
  !
128
110
 
129
- width: aString
130
- self at: 'width' put: aString
111
+ datalist
112
+ ^self tag: 'datalist'
131
113
  !
132
114
 
133
- height: aString
134
- self at: 'height' put: aString
115
+ dd
116
+ ^self tag: 'dd'
135
117
  !
136
118
 
137
- value: aString
138
- self at: 'value' put: aString
119
+ del
120
+ ^self tag: 'del'
139
121
  !
140
122
 
141
- for: aString
142
- self at: 'for' put: aString
123
+ details
124
+ ^self tag: 'details'
143
125
  !
144
126
 
145
- placeholder: aString
146
- self at: 'placeholder' put: aString
127
+ div
128
+ ^self tag: 'div'
147
129
  !
148
130
 
149
- accesskey: aString
150
- self at: 'accesskey' put: aString
131
+ div: aBlock
132
+ ^self div with: aBlock
151
133
  !
152
134
 
153
- contenteditable: aString
154
- self at: 'contenteditable' put: aString
135
+ dl
136
+ ^self tag: 'dl'
155
137
  !
156
138
 
157
- contextmenu: aString
158
- self at: 'contextmenu' put: aString
139
+ dt
140
+ ^self tag: 'dt'
159
141
  !
160
142
 
161
- draggable: aString
162
- self at: 'draggable' put: aString
143
+ em
144
+ ^self tag: 'em'
163
145
  !
164
146
 
165
- hidden
166
- self at: 'hidden' put: 'hidden'
147
+ embed
148
+ ^self tag: 'embed'
167
149
  !
168
150
 
169
- tabindex: aNumber
170
- self at: 'tabindex' put: aNumber
151
+ fieldset
152
+ ^self tag: 'fieldset'
171
153
  !
172
154
 
173
- target: aString
174
- self at: 'target' put: aString
155
+ figcaption
156
+ ^self tag: 'figcaption'
175
157
  !
176
158
 
177
- align: aString
178
- self at: 'align' put: aString
159
+ figure
160
+ ^self tag: 'figure'
179
161
  !
180
162
 
181
- alt: aString
182
- self at: 'alt' put: aString
163
+ footer
164
+ ^self tag: 'footer'
183
165
  !
184
166
 
185
- name: aString
186
- self at: 'name' put: aString
167
+ form
168
+ ^self tag: 'form'
187
169
  !
188
170
 
189
- valign: aString
190
- self at: 'valign' put: aString
171
+ h1
172
+ ^self tag: 'h1'
191
173
  !
192
174
 
193
- method: aString
194
- self at: 'method' put: aString
175
+ h1: anObject
176
+ ^self h1 with: anObject
195
177
  !
196
178
 
197
- action: aString
198
- self at: 'action' put: aString
179
+ h2
180
+ ^self tag: 'h2'
199
181
  !
200
182
 
201
- rows: aString
202
- self at: 'rows' put: aString
183
+ h2: anObject
184
+ ^ self h2 with: anObject
203
185
  !
204
186
 
205
- cols: aString
206
- self at: 'cols' put: aString
207
- ! !
208
-
209
- !TagBrush methodsFor: 'converting'!
210
-
211
- asJQuery
212
- ^window jQuery: self element
213
- ! !
214
-
215
- !TagBrush methodsFor: 'events'!
216
-
217
- onKeyDown: aBlock
218
- self asJQuery bind: 'keydown' do: aBlock
187
+ h3
188
+ ^self tag: 'h3'
219
189
  !
220
190
 
221
- onKeyPress: aBlock
222
- self asJQuery bind: 'keypress' do: aBlock
191
+ h3: anObject
192
+ ^self h3 with: anObject
223
193
  !
224
194
 
225
- onKeyUp: aBlock
226
- self asJQuery bind: 'keyup' do: aBlock
195
+ h4
196
+ ^self tag: 'h4'
227
197
  !
228
198
 
229
- onFocus: aBlock
230
- self asJQuery bind: 'focus' do: aBlock
199
+ h4: anObject
200
+ ^self h4 with: anObject
231
201
  !
232
202
 
233
- onBlur: aBlock
234
- self asJQuery bind: 'blur' do: aBlock
203
+ h5
204
+ ^self tag: 'h5'
235
205
  !
236
206
 
237
- onChange: aBlock
238
- self asJQuery bind: 'change' do: aBlock
207
+ h5: anObject
208
+ ^self h5 with: anObject
239
209
  !
240
210
 
241
- onClick: aBlock
242
- self asJQuery bind: 'click' do: aBlock
211
+ h6
212
+ ^self tag: 'h6'
243
213
  !
244
214
 
245
- onSubmit: aBlock
246
- self asJQuery bind: 'submit' do: aBlock
215
+ h6: anObject
216
+ ^self h6 with: anObject
247
217
  !
248
218
 
249
- onDblClick: aBlock
250
- self asJQuery bind: 'dblclick' do: aBlock
219
+ head
220
+ ^self tag: 'head'
251
221
  !
252
222
 
253
- onHover: aBlock
254
- self asJQuery bind: 'hover' do: aBlock
223
+ header
224
+ ^self tag: 'header'
255
225
  !
256
226
 
257
- onFocusIn: aBlock
258
- self asJQuery bind: 'focusin' do: aBlock
227
+ hgroup
228
+ ^self tag: 'hgroup'
259
229
  !
260
230
 
261
- onFocusOut: aBlock
262
- self asJQuery bind: 'focusout' do: aBlock
231
+ hr
232
+ ^self tag: 'hr'
263
233
  !
264
234
 
265
- onMouseDown: aBlock
266
- self asJQuery bind: 'mousedown' do: aBlock
235
+ html
236
+ ^self tag: 'html'
267
237
  !
268
238
 
269
- onMouseUp: aBlock
270
- self asJQuery bind: 'mouseup' do: aBlock
239
+ iframe
240
+ ^self tag: 'iframe'
271
241
  !
272
242
 
273
- onMouseEnter: aBlock
274
- self asJQuery bind: 'mouseenter' do: aBlock
243
+ iframe: aString
244
+ ^self iframe src: aString
275
245
  !
276
246
 
277
- onMouseLeave: aBlock
278
- self asJQuery bind: 'mouseleave' do: aBlock
247
+ img
248
+ ^self tag: 'img'
279
249
  !
280
250
 
281
- onMouseMove: aBlock
282
- self asJQuery bind: 'mousemove' do: aBlock
251
+ img: aString
252
+ ^self img src: aString
283
253
  !
284
254
 
285
- onMouseOut: aBlock
286
- self asJQuery bind: 'mouseout' do: aBlock
255
+ input
256
+ ^self tag: 'input'
287
257
  !
288
258
 
289
- onMouseOver: aBlock
290
- self asJQuery bind: 'mouseover' do: aBlock
259
+ label
260
+ ^self tag: 'label'
291
261
  !
292
262
 
293
- onSelect: aBlock
294
- self asJQuery bind: 'select' do: aBlock
263
+ legend
264
+ ^self tag: 'legend'
295
265
  !
296
266
 
297
- onUnload: aBlock
298
- self asJQuery bind: 'unload' do: aBlock
299
- ! !
300
-
301
- !TagBrush methodsFor: 'initialization'!
302
-
303
- initializeFromString: aString canvas: aCanvas
304
- element := self createElementFor: aString.
305
- canvas := aCanvas
267
+ li
268
+ ^self tag: 'li'
306
269
  !
307
270
 
308
- initializeFromJQuery: aJQuery canvas: aCanvas
309
- element := aJQuery get: 0.
310
- canvas := aCanvas
311
- ! !
312
-
313
- !TagBrush methodsFor: 'private'!
314
-
315
- createElementFor: aString
316
- <return document.createElement(String(aString))>
271
+ li: anObject
272
+ ^self li with: anObject
317
273
  !
318
274
 
319
- createTextNodeFor: aString
320
- <return document.createTextNode(String(aString))>
321
- ! !
322
-
323
- !TagBrush class methodsFor: 'instance creation'!
275
+ link
276
+ ^self tag: 'link'
277
+ !
324
278
 
325
- fromString: aString canvas: aCanvas
326
- ^self new
327
- initializeFromString: aString canvas: aCanvas;
328
- yourself
279
+ map
280
+ ^self tag: 'map'
329
281
  !
330
282
 
331
- fromJQuery: aJQuery canvas: aCanvas
332
- ^self new
333
- initializeFromJQuery: aJQuery canvas: aCanvas;
334
- yourself
335
- ! !
283
+ mark
284
+ ^self tag: 'mark'
285
+ !
336
286
 
337
- Object subclass: #HTMLCanvas
338
- instanceVariableNames: 'root'
339
- category: 'Canvas'!
287
+ menu
288
+ ^self tag: 'menu'
289
+ !
340
290
 
341
- !HTMLCanvas methodsFor: 'accessing'!
291
+ meta
292
+ ^self tag: 'meta'
293
+ !
342
294
 
343
- root: aTagBrush
344
- root := aTagBrush
295
+ nav
296
+ ^self tag: 'nav'
345
297
  !
346
298
 
347
- root
348
- ^root
349
- ! !
299
+ newTag: aString
300
+ ^TagBrush fromString: aString canvas: self
301
+ !
350
302
 
351
- !HTMLCanvas methodsFor: 'adding'!
303
+ noscript
304
+ ^self tag: 'noscript'
305
+ !
352
306
 
353
- with: anObject
354
- ^self root with: anObject
355
- ! !
307
+ object
308
+ ^self tag: 'object'
309
+ !
356
310
 
357
- !HTMLCanvas methodsFor: 'initialization'!
311
+ ol
312
+ ^self tag: 'ol'
313
+ !
358
314
 
359
- initialize
360
- super initialize.
361
- root ifNil: [root := TagBrush fromString: 'div' canvas: self]
315
+ ol: anObject
316
+ ^self ol with: anObject
362
317
  !
363
318
 
364
- initializeFromJQuery: aJQuery
365
- root := TagBrush fromJQuery: aJQuery canvas: self
366
- ! !
319
+ optgroup
320
+ ^self tag: 'optgroup'
321
+ !
367
322
 
368
- !HTMLCanvas methodsFor: 'tags'!
323
+ option
324
+ ^self tag: 'option'
325
+ !
369
326
 
370
- newTag: aString
371
- ^TagBrush fromString: aString canvas: self
327
+ output
328
+ ^self tag: 'output'
372
329
  !
373
330
 
374
- tag: aString
375
- ^root addBrush: (self newTag: aString)
331
+ p
332
+ ^self tag: 'p'
376
333
  !
377
334
 
378
- h1
379
- ^self tag: 'h1'
335
+ p: anObject
336
+ ^self p with: anObject
380
337
  !
381
338
 
382
- h2
383
- ^self tag: 'h2'
339
+ param
340
+ ^self tag: 'param'
384
341
  !
385
342
 
386
- h3
387
- ^self tag: 'h3'
343
+ pre
344
+ ^self tag: 'pre'
388
345
  !
389
346
 
390
- h4
391
- ^self tag: 'h4'
347
+ progress
348
+ ^self tag: 'progress'
392
349
  !
393
350
 
394
- h5
395
- ^self tag: 'h5'
351
+ script
352
+ ^self tag: 'script'
396
353
  !
397
354
 
398
- h6
399
- ^self tag: 'h6'
355
+ section
356
+ ^self tag: 'section'
357
+ !
358
+
359
+ select
360
+ ^self tag: 'select'
400
361
  !
401
362
 
402
- p
403
- ^self tag: 'p'
363
+ small
364
+ ^self tag: 'small'
404
365
  !
405
366
 
406
- div
407
- ^self tag: 'div'
367
+ source
368
+ ^self tag: 'source'
408
369
  !
409
370
 
410
371
  span
411
372
  ^self tag: 'span'
412
373
  !
413
374
 
414
- img
415
- ^self tag: 'img'
416
- !
417
-
418
- ul
419
- ^self tag: 'ul'
375
+ span: anObject
376
+ ^self span with: anObject
420
377
  !
421
378
 
422
- ol
423
- ^self tag: 'ol'
379
+ strong
380
+ ^self tag: 'strong'
424
381
  !
425
382
 
426
- li
427
- ^self tag: 'li'
383
+ strong: anObject
384
+ ^self strong with: anObject
428
385
  !
429
386
 
430
- table
431
- ^self tag: 'table'
387
+ style
388
+ ^ root addBrush: (StyleTag canvas: self)
432
389
  !
433
390
 
434
- tr
435
- ^self tag: 'tr'
391
+ style: aString
392
+ ^ self style with: aString; yourself
436
393
  !
437
394
 
438
- td
439
- ^self tag: 'td'
395
+ sub
396
+ ^self tag: 'sub'
440
397
  !
441
398
 
442
- th
443
- ^self tag: 'th'
399
+ summary
400
+ ^self tag: 'summary'
444
401
  !
445
402
 
446
- form
447
- ^self tag: 'form'
403
+ sup
404
+ ^self tag: 'sup'
448
405
  !
449
406
 
450
- input
451
- ^self tag: 'input'
407
+ table
408
+ ^self tag: 'table'
452
409
  !
453
410
 
454
- button
455
- ^self tag: 'button'
411
+ tag: aString
412
+ ^root addBrush: (self newTag: aString)
456
413
  !
457
414
 
458
- select
459
- ^self tag: 'select'
415
+ tbody
416
+ ^self tag: 'tbody'
460
417
  !
461
418
 
462
- option
463
- ^self tag: 'option'
419
+ td
420
+ ^self tag: 'td'
464
421
  !
465
422
 
466
423
  textarea
467
424
  ^self tag: 'textarea'
468
425
  !
469
426
 
470
- a
471
- ^self tag: 'a'
472
- !
473
-
474
- canvas
475
- ^self tag: 'canvas'
427
+ tfoot
428
+ ^self tag: 'tfoot'
476
429
  !
477
430
 
478
- pre
479
- ^self tag: 'pre'
431
+ th
432
+ ^self tag: 'th'
480
433
  !
481
434
 
482
- code
483
- ^self tag: 'code'
435
+ thead
436
+ ^self tag: 'thead'
484
437
  !
485
438
 
486
- br
487
- ^self tag: 'br'
439
+ time
440
+ ^self tag: 'time'
488
441
  !
489
442
 
490
- script
491
- ^self tag: 'script'
443
+ title
444
+ ^self tag: 'title'
492
445
  !
493
446
 
494
- link
495
- ^self tag: 'link'
447
+ tr
448
+ ^self tag: 'tr'
496
449
  !
497
450
 
498
- style
499
- ^ root addBrush: (StyleTag canvas: self)
451
+ ul
452
+ ^self tag: 'ul'
500
453
  !
501
454
 
502
- p: anObject
503
- ^self p with: anObject
455
+ ul: anObject
456
+ ^self ul with: anObject
504
457
  !
505
458
 
506
- h1: anObject
507
- ^self h1 with: anObject
508
- !
459
+ video
460
+ ^self tag: 'video'
461
+ ! !
509
462
 
510
- iframe
511
- ^self tag: 'iframe'
512
- !
463
+ !HTMLCanvas class methodsFor: 'instance creation'!
513
464
 
514
- iframe: aString
515
- ^self iframe src: aString
465
+ browserVersion
466
+ ^(jQuery at: #browser) version
516
467
  !
517
468
 
518
- h2: anObject
519
- ^ self h2 with: anObject
469
+ isMSIE
470
+ ^((jQuery at: #browser) at: #msie) notNil
520
471
  !
521
472
 
522
- h3: anObject
523
- ^self h3 with: anObject
473
+ isMozilla
474
+ ^((jQuery at: #browser) at: #mozilla) notNil
524
475
  !
525
476
 
526
- h4: anObject
527
- ^self h4 with: anObject
477
+ isOpera
478
+ ^((jQuery at: #browser) at: #opera) notNil
528
479
  !
529
480
 
530
- h5: anObject
531
- ^self h5 with: anObject
481
+ isWebkit
482
+ ^((jQuery at: #browser) at: #webkit) notNil
532
483
  !
533
484
 
534
- h6: anObject
535
- ^self h6 with: anObject
536
- !
485
+ onJQuery: aJQuery
486
+ ^self basicNew
487
+ initializeFromJQuery: aJQuery;
488
+ initialize;
489
+ yourself
490
+ ! !
537
491
 
538
- img: aString
539
- ^self img src: aString
540
- !
492
+ Object subclass: #TagBrush
493
+ instanceVariableNames: 'canvas element'
494
+ package: 'Canvas'!
541
495
 
542
- ol: anObject
543
- ^self ol with: anObject
544
- !
496
+ !TagBrush methodsFor: 'accessing'!
545
497
 
546
- li: anObject
547
- ^self li with: anObject
548
- !
498
+ element
499
+ ^element
500
+ ! !
549
501
 
550
- ul: anObject
551
- ^self ul with: anObject
552
- !
502
+ !TagBrush methodsFor: 'adding'!
553
503
 
554
- span: anObject
555
- ^self span with: anObject
504
+ addBrush: aTagBrush
505
+ self appendChild: aTagBrush element.
506
+ ^aTagBrush
556
507
  !
557
508
 
558
- style: aString
559
- ^ self style with: aString; yourself
509
+ append: anObject
510
+ anObject appendToBrush: self
560
511
  !
561
512
 
562
- audio
563
- ^self tag: 'audio'
513
+ appendBlock: aBlock
514
+ | root |
515
+ root := canvas root.
516
+ canvas root: self.
517
+ aBlock value: canvas.
518
+ canvas root: root
564
519
  !
565
520
 
566
- fieldset
567
- ^self tag: 'fieldset'
521
+ appendChild: anElement
522
+ "In IE7 and IE8 appendChild fails on several node types. So we need to check"
523
+ <var element=self['@element'];
524
+ if (null == element.canHaveChildren || element.canHaveChildren) {
525
+ element.appendChild(anElement);
526
+ } else {
527
+ element.text = String(element.text) + anElement.innerHTML;
528
+ } >
568
529
  !
569
530
 
570
- footer
571
- ^self tag: 'footer'
531
+ appendString: aString
532
+ self appendChild: (self createTextNodeFor: aString)
572
533
  !
573
534
 
574
- header
575
- ^self tag: 'header'
535
+ appendToBrush: aTagBrush
536
+ aTagBrush addBrush: self
576
537
  !
577
538
 
578
- hr
579
- ^self tag: 'hr'
539
+ contents: anObject
540
+ self
541
+ empty;
542
+ append: anObject
580
543
  !
581
544
 
582
- section
583
- ^self tag: 'section'
545
+ empty
546
+ self asJQuery empty
584
547
  !
585
548
 
586
- tbody
587
- ^self tag: 'tbody'
588
- !
549
+ with: anObject
550
+ self append: anObject
551
+ ! !
589
552
 
590
- tfoot
591
- ^self tag: 'tfoot'
592
- !
553
+ !TagBrush methodsFor: 'attributes'!
593
554
 
594
- thead
595
- ^self tag: 'thead'
555
+ accesskey: aString
556
+ self at: 'accesskey' put: aString
596
557
  !
597
558
 
598
- video
599
- ^self tag: 'video'
559
+ action: aString
560
+ self at: 'action' put: aString
600
561
  !
601
562
 
602
- label
603
- ^self tag: 'label'
563
+ align: aString
564
+ self at: 'align' put: aString
604
565
  !
605
566
 
606
- title
607
- ^self tag: 'title'
567
+ alt: aString
568
+ self at: 'alt' put: aString
608
569
  !
609
570
 
610
- time
611
- ^self tag: 'time'
571
+ at: aString put: aValue
572
+ <self['@element'].setAttribute(aString, aValue)>
612
573
  !
613
574
 
614
- sup
615
- ^self tag: 'sup'
575
+ class: aString
576
+ <self['@element'].className = aString>
616
577
  !
617
578
 
618
- summary
619
- ^self tag: 'summary'
579
+ cols: aString
580
+ self at: 'cols' put: aString
620
581
  !
621
582
 
622
- sub
623
- ^self tag: 'sub'
583
+ contenteditable: aString
584
+ self at: 'contenteditable' put: aString
624
585
  !
625
586
 
626
- strong
627
- ^self tag: 'strong'
587
+ contextmenu: aString
588
+ self at: 'contextmenu' put: aString
628
589
  !
629
590
 
630
- strong: anObject
631
- ^self strong with: anObject
591
+ draggable: aString
592
+ self at: 'draggable' put: aString
632
593
  !
633
594
 
634
- source
635
- ^self tag: 'source'
595
+ for: aString
596
+ self at: 'for' put: aString
636
597
  !
637
598
 
638
- small
639
- ^self tag: 'small'
599
+ height: aString
600
+ self at: 'height' put: aString
640
601
  !
641
602
 
642
- progress
643
- ^self tag: 'progress'
603
+ hidden
604
+ self at: 'hidden' put: 'hidden'
644
605
  !
645
606
 
646
- param
647
- ^self tag: 'param'
607
+ href: aString
608
+ self at: 'href' put: aString
648
609
  !
649
610
 
650
- output
651
- ^self tag: 'output'
611
+ id: aString
612
+ self at: 'id' put: aString
652
613
  !
653
614
 
654
- optgroup
655
- ^self tag: 'optgroup'
615
+ media: aString
616
+ self at: 'media' put: aString
656
617
  !
657
618
 
658
- object
659
- ^self tag: 'object'
619
+ method: aString
620
+ self at: 'method' put: aString
660
621
  !
661
622
 
662
- noscript
663
- ^self tag: 'noscript'
623
+ name: aString
624
+ self at: 'name' put: aString
664
625
  !
665
626
 
666
- nav
667
- ^self tag: 'nav'
627
+ placeholder: aString
628
+ self at: 'placeholder' put: aString
668
629
  !
669
630
 
670
- meta
671
- ^self tag: 'meta'
631
+ rel: aString
632
+ self at: 'rel' put: aString
672
633
  !
673
634
 
674
- menu
675
- ^self tag: 'menu'
635
+ removeAt: aString
636
+ <self['@element'].removeAttribute(aString)>
676
637
  !
677
638
 
678
- mark
679
- ^self tag: 'mark'
639
+ rows: aString
640
+ self at: 'rows' put: aString
680
641
  !
681
642
 
682
- map
683
- ^self tag: 'map'
643
+ src: aString
644
+ self at: 'src' put: aString
684
645
  !
685
646
 
686
- legend
687
- ^self tag: 'legend'
647
+ style: aString
648
+ self at: 'style' put: aString
688
649
  !
689
650
 
690
- html
691
- ^self tag: 'html'
651
+ tabindex: aNumber
652
+ self at: 'tabindex' put: aNumber
692
653
  !
693
654
 
694
- hgroup
695
- ^self tag: 'hgroup'
655
+ target: aString
656
+ self at: 'target' put: aString
696
657
  !
697
658
 
698
- head
699
- ^self tag: 'head'
659
+ title: aString
660
+ self at: 'title' put: aString
700
661
  !
701
662
 
702
- figure
703
- ^self tag: 'figure'
663
+ type: aString
664
+ self at: 'type' put: aString
704
665
  !
705
666
 
706
- figcaption
707
- ^self tag: 'figcaption'
667
+ valign: aString
668
+ self at: 'valign' put: aString
708
669
  !
709
670
 
710
- embed
711
- ^self tag: 'embed'
671
+ value: aString
672
+ self at: 'value' put: aString
712
673
  !
713
674
 
714
- em
715
- ^self tag: 'em'
675
+ width: aString
676
+ self at: 'width' put: aString
677
+ ! !
678
+
679
+ !TagBrush methodsFor: 'converting'!
680
+
681
+ asJQuery
682
+ ^window jQuery: self element
683
+ ! !
684
+
685
+ !TagBrush methodsFor: 'events'!
686
+
687
+ onBlur: aBlock
688
+ self asJQuery bind: 'blur' do: aBlock
716
689
  !
717
690
 
718
- dt
719
- ^self tag: 'dt'
691
+ onChange: aBlock
692
+ self asJQuery bind: 'change' do: aBlock
720
693
  !
721
694
 
722
- dl
723
- ^self tag: 'dl'
695
+ onClick: aBlock
696
+ self asJQuery bind: 'click' do: aBlock
724
697
  !
725
698
 
726
- details
727
- ^self tag: 'details'
699
+ onDblClick: aBlock
700
+ self asJQuery bind: 'dblclick' do: aBlock
728
701
  !
729
702
 
730
- del
731
- ^self tag: 'del'
703
+ onFocus: aBlock
704
+ self asJQuery bind: 'focus' do: aBlock
732
705
  !
733
706
 
734
- dd
735
- ^self tag: 'dd'
707
+ onFocusIn: aBlock
708
+ self asJQuery bind: 'focusin' do: aBlock
736
709
  !
737
710
 
738
- datalist
739
- ^self tag: 'datalist'
711
+ onFocusOut: aBlock
712
+ self asJQuery bind: 'focusout' do: aBlock
740
713
  !
741
714
 
742
- command
743
- ^self tag: 'command'
715
+ onHover: aBlock
716
+ self asJQuery bind: 'hover' do: aBlock
744
717
  !
745
718
 
746
- colgroup
747
- ^self tag: 'colgroup'
719
+ onKeyDown: aBlock
720
+ self asJQuery bind: 'keydown' do: aBlock
748
721
  !
749
722
 
750
- col
751
- ^self tag: 'col'
723
+ onKeyPress: aBlock
724
+ self asJQuery bind: 'keypress' do: aBlock
752
725
  !
753
726
 
754
- cite
755
- ^self tag: 'cite'
727
+ onKeyUp: aBlock
728
+ self asJQuery bind: 'keyup' do: aBlock
756
729
  !
757
730
 
758
- caption
759
- ^self tag: 'caption'
731
+ onMouseDown: aBlock
732
+ self asJQuery bind: 'mousedown' do: aBlock
760
733
  !
761
734
 
762
- body
763
- ^self tag: 'body'
735
+ onMouseEnter: aBlock
736
+ self asJQuery bind: 'mouseenter' do: aBlock
764
737
  !
765
738
 
766
- blockquote
767
- ^self tag: 'blockquote'
739
+ onMouseLeave: aBlock
740
+ self asJQuery bind: 'mouseleave' do: aBlock
768
741
  !
769
742
 
770
- base
771
- ^self tag: 'base'
743
+ onMouseMove: aBlock
744
+ self asJQuery bind: 'mousemove' do: aBlock
772
745
  !
773
746
 
774
- aside
775
- ^self tag: 'aside'
747
+ onMouseOut: aBlock
748
+ self asJQuery bind: 'mouseout' do: aBlock
776
749
  !
777
750
 
778
- article
779
- ^self tag: 'article'
751
+ onMouseOver: aBlock
752
+ self asJQuery bind: 'mouseover' do: aBlock
780
753
  !
781
754
 
782
- area
783
- ^self tag: 'area'
755
+ onMouseUp: aBlock
756
+ self asJQuery bind: 'mouseup' do: aBlock
784
757
  !
785
758
 
786
- address
787
- ^self tag: 'address'
759
+ onSelect: aBlock
760
+ self asJQuery bind: 'select' do: aBlock
788
761
  !
789
762
 
790
- abbr
791
- ^self tag: 'abbr'
763
+ onSubmit: aBlock
764
+ self asJQuery bind: 'submit' do: aBlock
792
765
  !
793
766
 
794
- div: aBlock
795
- ^self div with: aBlock
767
+ onUnload: aBlock
768
+ self asJQuery bind: 'unload' do: aBlock
796
769
  ! !
797
770
 
798
- !HTMLCanvas class methodsFor: 'instance creation'!
771
+ !TagBrush methodsFor: 'initialization'!
799
772
 
800
- onJQuery: aJQuery
801
- ^self basicNew
802
- initializeFromJQuery: aJQuery;
803
- initialize;
804
- yourself
773
+ initializeFromJQuery: aJQuery canvas: aCanvas
774
+ element := aJQuery get: 0.
775
+ canvas := aCanvas
805
776
  !
806
777
 
807
- isMSIE
808
- ^((jQuery at: #browser) at: #msie) notNil
809
- !
778
+ initializeFromString: aString canvas: aCanvas
779
+ element := self createElementFor: aString.
780
+ canvas := aCanvas
781
+ ! !
810
782
 
811
- isOpera
812
- ^((jQuery at: #browser) at: #opera) notNil
813
- !
783
+ !TagBrush methodsFor: 'private'!
814
784
 
815
- isMozilla
816
- ^((jQuery at: #browser) at: #mozilla) notNil
785
+ createElementFor: aString
786
+ <return document.createElement(String(aString))>
817
787
  !
818
788
 
819
- isWebkit
820
- ^((jQuery at: #browser) at: #webkit) notNil
789
+ createTextNodeFor: aString
790
+ <return document.createTextNode(String(aString))>
791
+ ! !
792
+
793
+ !TagBrush class methodsFor: 'instance creation'!
794
+
795
+ fromJQuery: aJQuery canvas: aCanvas
796
+ ^self new
797
+ initializeFromJQuery: aJQuery canvas: aCanvas;
798
+ yourself
821
799
  !
822
800
 
823
- browserVersion
824
- ^(jQuery at: #browser) version
801
+ fromString: aString canvas: aCanvas
802
+ ^self new
803
+ initializeFromString: aString canvas: aCanvas;
804
+ yourself
825
805
  ! !
826
806
 
827
807
  TagBrush subclass: #StyleTag
828
808
  instanceVariableNames: 'canvas element'
829
- category: 'Canvas'!
809
+ package: 'Canvas'!
830
810
  !StyleTag commentStamp!
831
811
  I'm a <style> tag use to inline CSS or load a stylesheet.
832
812
 
@@ -848,37 +828,57 @@ canvas: aCanvas
848
828
  yourself
849
829
  ! !
850
830
 
851
- !Object methodsFor: '*Canvas'!
831
+ Object subclass: #Widget
832
+ instanceVariableNames: ''
833
+ package: 'Canvas'!
852
834
 
853
- appendToJQuery: aJQuery
854
- aJQuery append: self asString
835
+ !Widget methodsFor: 'adding'!
836
+
837
+ appendToBrush: aTagBrush
838
+ self appendToJQuery: aTagBrush asJQuery
855
839
  !
856
840
 
841
+ appendToJQuery: aJQuery
842
+ self renderOn: (HTMLCanvas onJQuery: aJQuery)
843
+ ! !
844
+
845
+ !Widget methodsFor: 'rendering'!
846
+
847
+ renderOn: html
848
+ self
849
+ ! !
850
+
851
+ !Object methodsFor: '*Canvas'!
852
+
857
853
  appendToBrush: aTagBrush
858
854
  aTagBrush append: self asString
855
+ !
856
+
857
+ appendToJQuery: aJQuery
858
+ aJQuery append: self asString
859
859
  ! !
860
860
 
861
861
  !BlockClosure methodsFor: '*Canvas'!
862
862
 
863
- appendToJQuery: aJQuery
864
- self value: (HTMLCanvas onJQuery: aJQuery)
865
- !
866
-
867
863
  appendToBrush: aTagBrush
868
864
  aTagBrush appendBlock: self
865
+ !
866
+
867
+ appendToJQuery: aJQuery
868
+ self value: (HTMLCanvas onJQuery: aJQuery)
869
869
  ! !
870
870
 
871
871
  !String methodsFor: '*Canvas'!
872
872
 
873
- asJQuery
874
- <return jQuery(String(self))>
873
+ appendToBrush: aTagBrush
874
+ aTagBrush appendString: self
875
875
  !
876
876
 
877
877
  appendToJQuery: aJQuery
878
878
  aJQuery append: self
879
879
  !
880
880
 
881
- appendToBrush: aTagBrush
882
- aTagBrush appendString: self
881
+ asJQuery
882
+ <return jQuery(String(self))>
883
883
  ! !
884
884