resin 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,339 @@
1
1
  Smalltalk current createPackage: 'Canvas' properties: #{}!
2
+ Object subclass: #Widget
3
+ instanceVariableNames: ''
4
+ category: 'Canvas'!
5
+
6
+ !Widget methodsFor: 'adding'!
7
+
8
+ appendToBrush: aTagBrush
9
+ self appendToJQuery: aTagBrush asJQuery
10
+ !
11
+
12
+ appendToJQuery: aJQuery
13
+ self renderOn: (HTMLCanvas onJQuery: aJQuery)
14
+ ! !
15
+
16
+ !Widget methodsFor: 'rendering'!
17
+
18
+ renderOn: html
19
+ self
20
+ ! !
21
+
22
+ Object subclass: #TagBrush
23
+ instanceVariableNames: 'canvas element'
24
+ category: 'Canvas'!
25
+
26
+ !TagBrush methodsFor: 'accessing'!
27
+
28
+ element
29
+ ^element
30
+ ! !
31
+
32
+ !TagBrush methodsFor: 'adding'!
33
+
34
+ contents: anObject
35
+ self
36
+ empty;
37
+ append: anObject
38
+ !
39
+
40
+ addBrush: aTagBrush
41
+ self appendChild: aTagBrush element.
42
+ ^aTagBrush
43
+ !
44
+
45
+ with: anObject
46
+ self append: anObject
47
+ !
48
+
49
+ append: anObject
50
+ anObject appendToBrush: self
51
+ !
52
+
53
+ appendToBrush: aTagBrush
54
+ aTagBrush addBrush: self
55
+ !
56
+
57
+ appendBlock: aBlock
58
+ | root |
59
+ root := canvas root.
60
+ canvas root: self.
61
+ aBlock value: canvas.
62
+ canvas root: root
63
+ !
64
+
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
+ } >
73
+ !
74
+
75
+ appendString: aString
76
+ self appendChild: (self createTextNodeFor: aString)
77
+ !
78
+
79
+ empty
80
+ self asJQuery empty
81
+ ! !
82
+
83
+ !TagBrush methodsFor: 'attributes'!
84
+
85
+ at: aString put: aValue
86
+ <self['@element'].setAttribute(aString, aValue)>
87
+ !
88
+
89
+ removeAt: aString
90
+ <self['@element'].removeAttribute(aString)>
91
+ !
92
+
93
+ class: aString
94
+ <self['@element'].className = aString>
95
+ !
96
+
97
+ id: aString
98
+ self at: 'id' put: aString
99
+ !
100
+
101
+ src: aString
102
+ self at: 'src' put: aString
103
+ !
104
+
105
+ href: aString
106
+ self at: 'href' put: aString
107
+ !
108
+
109
+ title: aString
110
+ self at: 'title' put: aString
111
+ !
112
+
113
+ style: aString
114
+ self at: 'style' put: aString
115
+ !
116
+
117
+ type: aString
118
+ self at: 'type' put: aString
119
+ !
120
+
121
+ media: aString
122
+ self at: 'media' put: aString
123
+ !
124
+
125
+ rel: aString
126
+ self at: 'rel' put: aString
127
+ !
128
+
129
+ width: aString
130
+ self at: 'width' put: aString
131
+ !
132
+
133
+ height: aString
134
+ self at: 'height' put: aString
135
+ !
136
+
137
+ value: aString
138
+ self at: 'value' put: aString
139
+ !
140
+
141
+ for: aString
142
+ self at: 'for' put: aString
143
+ !
144
+
145
+ placeholder: aString
146
+ self at: 'placeholder' put: aString
147
+ !
148
+
149
+ accesskey: aString
150
+ self at: 'accesskey' put: aString
151
+ !
152
+
153
+ contenteditable: aString
154
+ self at: 'contenteditable' put: aString
155
+ !
156
+
157
+ contextmenu: aString
158
+ self at: 'contextmenu' put: aString
159
+ !
160
+
161
+ draggable: aString
162
+ self at: 'draggable' put: aString
163
+ !
164
+
165
+ hidden
166
+ self at: 'hidden' put: 'hidden'
167
+ !
168
+
169
+ tabindex: aNumber
170
+ self at: 'tabindex' put: aNumber
171
+ !
172
+
173
+ target: aString
174
+ self at: 'target' put: aString
175
+ !
176
+
177
+ align: aString
178
+ self at: 'align' put: aString
179
+ !
180
+
181
+ alt: aString
182
+ self at: 'alt' put: aString
183
+ !
184
+
185
+ name: aString
186
+ self at: 'name' put: aString
187
+ !
188
+
189
+ valign: aString
190
+ self at: 'valign' put: aString
191
+ !
192
+
193
+ method: aString
194
+ self at: 'method' put: aString
195
+ !
196
+
197
+ action: aString
198
+ self at: 'action' put: aString
199
+ !
200
+
201
+ rows: aString
202
+ self at: 'rows' put: aString
203
+ !
204
+
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
219
+ !
220
+
221
+ onKeyPress: aBlock
222
+ self asJQuery bind: 'keypress' do: aBlock
223
+ !
224
+
225
+ onKeyUp: aBlock
226
+ self asJQuery bind: 'keyup' do: aBlock
227
+ !
228
+
229
+ onFocus: aBlock
230
+ self asJQuery bind: 'focus' do: aBlock
231
+ !
232
+
233
+ onBlur: aBlock
234
+ self asJQuery bind: 'blur' do: aBlock
235
+ !
236
+
237
+ onChange: aBlock
238
+ self asJQuery bind: 'change' do: aBlock
239
+ !
240
+
241
+ onClick: aBlock
242
+ self asJQuery bind: 'click' do: aBlock
243
+ !
244
+
245
+ onSubmit: aBlock
246
+ self asJQuery bind: 'submit' do: aBlock
247
+ !
248
+
249
+ onDblClick: aBlock
250
+ self asJQuery bind: 'dblclick' do: aBlock
251
+ !
252
+
253
+ onHover: aBlock
254
+ self asJQuery bind: 'hover' do: aBlock
255
+ !
256
+
257
+ onFocusIn: aBlock
258
+ self asJQuery bind: 'focusin' do: aBlock
259
+ !
260
+
261
+ onFocusOut: aBlock
262
+ self asJQuery bind: 'focusout' do: aBlock
263
+ !
264
+
265
+ onMouseDown: aBlock
266
+ self asJQuery bind: 'mousedown' do: aBlock
267
+ !
268
+
269
+ onMouseUp: aBlock
270
+ self asJQuery bind: 'mouseup' do: aBlock
271
+ !
272
+
273
+ onMouseEnter: aBlock
274
+ self asJQuery bind: 'mouseenter' do: aBlock
275
+ !
276
+
277
+ onMouseLeave: aBlock
278
+ self asJQuery bind: 'mouseleave' do: aBlock
279
+ !
280
+
281
+ onMouseMove: aBlock
282
+ self asJQuery bind: 'mousemove' do: aBlock
283
+ !
284
+
285
+ onMouseOut: aBlock
286
+ self asJQuery bind: 'mouseout' do: aBlock
287
+ !
288
+
289
+ onMouseOver: aBlock
290
+ self asJQuery bind: 'mouseover' do: aBlock
291
+ !
292
+
293
+ onSelect: aBlock
294
+ self asJQuery bind: 'select' do: aBlock
295
+ !
296
+
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
306
+ !
307
+
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))>
317
+ !
318
+
319
+ createTextNodeFor: aString
320
+ <return document.createTextNode(String(aString))>
321
+ ! !
322
+
323
+ !TagBrush class methodsFor: 'instance creation'!
324
+
325
+ fromString: aString canvas: aCanvas
326
+ ^self new
327
+ initializeFromString: aString canvas: aCanvas;
328
+ yourself
329
+ !
330
+
331
+ fromJQuery: aJQuery canvas: aCanvas
332
+ ^self new
333
+ initializeFromJQuery: aJQuery canvas: aCanvas;
334
+ yourself
335
+ ! !
336
+
2
337
  Object subclass: #HTMLCanvas
3
338
  instanceVariableNames: 'root'
4
339
  category: 'Canvas'!
@@ -224,10 +559,6 @@ style: aString
224
559
  ^ self style with: aString; yourself
225
560
  !
226
561
 
227
- articles
228
- ^self tag: 'articles'
229
- !
230
-
231
562
  audio
232
563
  ^self tag: 'audio'
233
564
  !
@@ -266,226 +597,231 @@ thead
266
597
 
267
598
  video
268
599
  ^self tag: 'video'
269
- ! !
600
+ !
270
601
 
271
- !HTMLCanvas class methodsFor: 'instance creation'!
602
+ label
603
+ ^self tag: 'label'
604
+ !
272
605
 
273
- onJQuery: aJQuery
274
- ^self basicNew
275
- initializeFromJQuery: aJQuery;
276
- initialize;
277
- yourself
278
- ! !
606
+ title
607
+ ^self tag: 'title'
608
+ !
279
609
 
280
- Object subclass: #TagBrush
281
- instanceVariableNames: 'canvas element'
282
- category: 'Canvas'!
610
+ time
611
+ ^self tag: 'time'
612
+ !
283
613
 
284
- !TagBrush methodsFor: 'accessing'!
614
+ sup
615
+ ^self tag: 'sup'
616
+ !
285
617
 
286
- element
287
- ^element
288
- ! !
618
+ summary
619
+ ^self tag: 'summary'
620
+ !
289
621
 
290
- !TagBrush methodsFor: 'adding'!
622
+ sub
623
+ ^self tag: 'sub'
624
+ !
291
625
 
292
- contents: anObject
293
- self
294
- empty;
295
- append: anObject
626
+ strong
627
+ ^self tag: 'strong'
296
628
  !
297
629
 
298
- addBrush: aTagBrush
299
- self appendChild: aTagBrush element.
300
- ^aTagBrush
630
+ strong: anObject
631
+ ^self strong with: anObject
301
632
  !
302
633
 
303
- with: anObject
304
- self append: anObject
634
+ source
635
+ ^self tag: 'source'
305
636
  !
306
637
 
307
- append: anObject
308
- anObject appendToBrush: self
638
+ small
639
+ ^self tag: 'small'
309
640
  !
310
641
 
311
- appendToBrush: aTagBrush
312
- aTagBrush addBrush: self
642
+ progress
643
+ ^self tag: 'progress'
313
644
  !
314
645
 
315
- appendBlock: aBlock
316
- | root |
317
- root := canvas root.
318
- canvas root: self.
319
- aBlock value: canvas.
320
- canvas root: root
646
+ param
647
+ ^self tag: 'param'
321
648
  !
322
649
 
323
- appendChild: anElement
324
- "In IE7 and IE8 appendChild fails on several node types. So we need to check"
325
- <var element=self['@element'];
326
- if (null == element.canHaveChildren || element.canHaveChildren) {
327
- element.appendChild(anElement);
328
- } else {
329
- element.text = String(element.text) + anElement.innerHTML;
330
- } >
650
+ output
651
+ ^self tag: 'output'
331
652
  !
332
653
 
333
- appendString: aString
334
- self appendChild: (self createTextNodeFor: aString)
654
+ optgroup
655
+ ^self tag: 'optgroup'
335
656
  !
336
657
 
337
- empty
338
- self asJQuery empty
339
- ! !
658
+ object
659
+ ^self tag: 'object'
660
+ !
340
661
 
341
- !TagBrush methodsFor: 'attributes'!
662
+ noscript
663
+ ^self tag: 'noscript'
664
+ !
342
665
 
343
- at: aString put: aValue
344
- <self['@element'].setAttribute(aString, aValue)>
666
+ nav
667
+ ^self tag: 'nav'
345
668
  !
346
669
 
347
- removeAt: aString
348
- <self['@element'].removeAttribute(aString)>
670
+ meta
671
+ ^self tag: 'meta'
349
672
  !
350
673
 
351
- class: aString
352
- <self['@element'].className = aString>
674
+ menu
675
+ ^self tag: 'menu'
353
676
  !
354
677
 
355
- id: aString
356
- self at: 'id' put: aString
678
+ mark
679
+ ^self tag: 'mark'
357
680
  !
358
681
 
359
- src: aString
360
- self at: 'src' put: aString
682
+ map
683
+ ^self tag: 'map'
361
684
  !
362
685
 
363
- href: aString
364
- self at: 'href' put: aString
686
+ legend
687
+ ^self tag: 'legend'
365
688
  !
366
689
 
367
- title: aString
368
- self at: 'title' put: aString
690
+ html
691
+ ^self tag: 'html'
369
692
  !
370
693
 
371
- style: aString
372
- self at: 'style' put: aString
694
+ hgroup
695
+ ^self tag: 'hgroup'
373
696
  !
374
697
 
375
- type: aString
376
- self at: 'type' put: aString
698
+ head
699
+ ^self tag: 'head'
377
700
  !
378
701
 
379
- media: aString
380
- self at: 'media' put: aString
702
+ figure
703
+ ^self tag: 'figure'
381
704
  !
382
705
 
383
- rel: aString
384
- self at: 'rel' put: aString
706
+ figcaption
707
+ ^self tag: 'figcaption'
385
708
  !
386
709
 
387
- width: aString
388
- self at: 'width' put: aString
710
+ embed
711
+ ^self tag: 'embed'
389
712
  !
390
713
 
391
- height: aString
392
- self at: 'height' put: aString
714
+ em
715
+ ^self tag: 'em'
393
716
  !
394
717
 
395
- value: aString
396
- self at: 'value' put: aString
397
- ! !
718
+ dt
719
+ ^self tag: 'dt'
720
+ !
398
721
 
399
- !TagBrush methodsFor: 'converting'!
722
+ dl
723
+ ^self tag: 'dl'
724
+ !
400
725
 
401
- asJQuery
402
- ^window jQuery: self element
403
- ! !
726
+ details
727
+ ^self tag: 'details'
728
+ !
404
729
 
405
- !TagBrush methodsFor: 'events'!
730
+ del
731
+ ^self tag: 'del'
732
+ !
406
733
 
407
- onKeyDown: aBlock
408
- self asJQuery bind: 'keydown' do: aBlock
734
+ dd
735
+ ^self tag: 'dd'
409
736
  !
410
737
 
411
- onKeyPress: aBlock
412
- self asJQuery bind: 'keypress' do: aBlock
738
+ datalist
739
+ ^self tag: 'datalist'
413
740
  !
414
741
 
415
- onKeyUp: aBlock
416
- self asJQuery bind: 'keyup' do: aBlock
742
+ command
743
+ ^self tag: 'command'
417
744
  !
418
745
 
419
- onFocus: aBlock
420
- self asJQuery bind: 'focus' do: aBlock
746
+ colgroup
747
+ ^self tag: 'colgroup'
421
748
  !
422
749
 
423
- onBlur: aBlock
424
- self asJQuery bind: 'blur' do: aBlock
750
+ col
751
+ ^self tag: 'col'
425
752
  !
426
753
 
427
- onChange: aBlock
428
- self asJQuery bind: 'change' do: aBlock
754
+ cite
755
+ ^self tag: 'cite'
429
756
  !
430
757
 
431
- onClick: aBlock
432
- self asJQuery bind: 'click' do: aBlock
433
- ! !
758
+ caption
759
+ ^self tag: 'caption'
760
+ !
434
761
 
435
- !TagBrush methodsFor: 'initialization'!
762
+ body
763
+ ^self tag: 'body'
764
+ !
436
765
 
437
- initializeFromString: aString canvas: aCanvas
438
- element := self createElementFor: aString.
439
- canvas := aCanvas
766
+ blockquote
767
+ ^self tag: 'blockquote'
440
768
  !
441
769
 
442
- initializeFromJQuery: aJQuery canvas: aCanvas
443
- element := aJQuery get: 0.
444
- canvas := aCanvas
445
- ! !
770
+ base
771
+ ^self tag: 'base'
772
+ !
446
773
 
447
- !TagBrush methodsFor: 'private'!
774
+ aside
775
+ ^self tag: 'aside'
776
+ !
448
777
 
449
- createElementFor: aString
450
- <return document.createElement(String(aString))>
778
+ article
779
+ ^self tag: 'article'
451
780
  !
452
781
 
453
- createTextNodeFor: aString
454
- <return document.createTextNode(String(aString))>
455
- ! !
782
+ area
783
+ ^self tag: 'area'
784
+ !
456
785
 
457
- !TagBrush class methodsFor: 'instance creation'!
786
+ address
787
+ ^self tag: 'address'
788
+ !
458
789
 
459
- fromString: aString canvas: aCanvas
460
- ^self new
461
- initializeFromString: aString canvas: aCanvas;
462
- yourself
790
+ abbr
791
+ ^self tag: 'abbr'
463
792
  !
464
793
 
465
- fromJQuery: aJQuery canvas: aCanvas
466
- ^self new
467
- initializeFromJQuery: aJQuery canvas: aCanvas;
468
- yourself
794
+ div: aBlock
795
+ ^self div with: aBlock
469
796
  ! !
470
797
 
471
- Object subclass: #Widget
472
- instanceVariableNames: ''
473
- category: 'Canvas'!
798
+ !HTMLCanvas class methodsFor: 'instance creation'!
474
799
 
475
- !Widget methodsFor: 'adding'!
800
+ onJQuery: aJQuery
801
+ ^self basicNew
802
+ initializeFromJQuery: aJQuery;
803
+ initialize;
804
+ yourself
805
+ !
476
806
 
477
- appendToBrush: aTagBrush
478
- self appendToJQuery: aTagBrush asJQuery
807
+ isMSIE
808
+ ^((jQuery at: #browser) at: #msie) notNil
479
809
  !
480
810
 
481
- appendToJQuery: aJQuery
482
- self renderOn: (HTMLCanvas onJQuery: aJQuery)
483
- ! !
811
+ isOpera
812
+ ^((jQuery at: #browser) at: #opera) notNil
813
+ !
484
814
 
485
- !Widget methodsFor: 'rendering'!
815
+ isMozilla
816
+ ^((jQuery at: #browser) at: #mozilla) notNil
817
+ !
486
818
 
487
- renderOn: html
488
- self
819
+ isWebkit
820
+ ^((jQuery at: #browser) at: #webkit) notNil
821
+ !
822
+
823
+ browserVersion
824
+ ^(jQuery at: #browser) version
489
825
  ! !
490
826
 
491
827
  TagBrush subclass: #StyleTag
@@ -499,19 +835,11 @@ For inlining handle IE compatibility problems.!
499
835
  !StyleTag methodsFor: 'adding'!
500
836
 
501
837
  with: aString
502
- self isBrowserIE
838
+ HTMLCanvas isMSIE
503
839
  ifTrue: [self element styleSheet cssText: aString ]
504
840
  ifFalse: [super with: aString ].
505
841
  ! !
506
842
 
507
- !StyleTag methodsFor: 'testing'!
508
-
509
- isBrowserIE
510
- |ie|
511
- ie := <jQuery.browser.msie>.
512
- ^ ie notNil.
513
- ! !
514
-
515
843
  !StyleTag class methodsFor: 'instance creation'!
516
844
 
517
845
  canvas: aCanvas