Index: trunk/parsers/wikidom/tests/synth/test.js |
— | — | @@ -32,6 +32,10 @@ |
33 | 33 | container1.append( item3 ); |
34 | 34 | equal( updates, 3, 'es.ModelContainer emits update events on append' ); |
35 | 35 | strictEqual( item3.c, container1, 'es.ModelContainer.append attaches item to container' ); |
| 36 | + |
| 37 | + strictEqual( item1.a, container1, 'Item container is set upon adding' ); |
| 38 | + strictEqual( item2.b, container1, 'Item container is set upon adding' ); |
| 39 | + strictEqual( item3.c, container1, 'Item container is set upon adding' ); |
36 | 40 | |
37 | 41 | // Accessing |
38 | 42 | |
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewContainer.js |
— | — | @@ -28,22 +28,22 @@ |
29 | 29 | .data( typeName, this ); |
30 | 30 | var container = this; |
31 | 31 | this.containerModel.on( 'prepend', function( itemModel ) { |
32 | | - var itemView = container.createItemView( itemModel ); |
| 32 | + var itemView = itemModel.createView(); |
33 | 33 | container.views.unshift( itemView ); |
34 | 34 | container.$.prepend( itemView.$ ); |
35 | 35 | container.emit( 'prepend', itemView ); |
36 | 36 | container.emit( 'update' ); |
37 | 37 | } ); |
38 | 38 | this.containerModel.on( 'append', function( itemModel ) { |
39 | | - var itemView = container.createItemView( itemModel ); |
| 39 | + var itemView = itemModel.createView(); |
40 | 40 | container.views.push( itemView ); |
41 | 41 | container.$.append( itemView.$ ); |
42 | 42 | container.emit( 'append', itemView ); |
43 | 43 | container.emit( 'update' ); |
44 | 44 | } ); |
45 | | - this.containerModel.on( 'insertBefore', function( item, before ) { |
46 | | - var itemView = container.createItemView( item ), |
47 | | - beforeView = container.lookupItemView( before ); |
| 45 | + this.containerModel.on( 'insertBefore', function( itemModel, beforeModel ) { |
| 46 | + var itemView = itemModel.createView(), |
| 47 | + beforeView = container.lookupItemView( beforebeforeModel ); |
48 | 48 | if ( beforeView ) { |
49 | 49 | container.views.splice( container.views.indexOf( beforeView ), 0, itemView ); |
50 | 50 | itemView.$.insertBefore( beforeView.$ ); |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | container.emit( 'update' ); |
57 | 57 | } ); |
58 | 58 | this.containerModel.on( 'insertAfter', function( itemModel, afterModel ) { |
59 | | - var itemView = container.createItemView( item ), |
| 59 | + var itemView = itemModel.createView(), |
60 | 60 | afterView = container.lookupItemView( afterModel ); |
61 | 61 | if ( afterView ) { |
62 | 62 | container.views.splice( container.views.indexOf( afterView ) + 1, 0, itemView ); |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | // Auto-add views for existing items |
79 | 79 | var itemModels = this.containerModel.all(); |
80 | 80 | for ( var i = 0; i < itemModels.length; i++ ) { |
81 | | - this.views.push( this.createItemView( itemModels[i] ) ); |
| 81 | + this.views.push( itemModels[i].createView() ); |
82 | 82 | } |
83 | 83 | }; |
84 | 84 | |
— | — | @@ -90,10 +90,6 @@ |
91 | 91 | return null; |
92 | 92 | }; |
93 | 93 | |
94 | | -es.ViewContainer.prototype.createItemView = function( itemModel ) { |
95 | | - throw 'es.ViewContainer.createItemView not implemented in this subclass'; |
96 | | -}; |
97 | | - |
98 | 94 | /* Inheritance */ |
99 | 95 | |
100 | 96 | es.extend( es.ViewContainer, es.EventEmitter ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.BlockView.js |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * @param tagName {String} HTML tag name to use in rendering (optional, default: "div") |
11 | 11 | */ |
12 | 12 | es.BlockView = function( typeName, tagName ) { |
13 | | - es.DomContainerItem.call( this, 'document', typeName || 'block', tagName || 'div' ); |
| 13 | + es.ViewContainerItem.call( this, 'document', typeName || 'block', tagName || 'div' ); |
14 | 14 | }; |
15 | 15 | |
16 | 16 | /** |
— | — | @@ -40,4 +40,4 @@ |
41 | 41 | throw 'BlockView.getRenderedLineIndex not implemented in this subclass.'; |
42 | 42 | }; |
43 | 43 | |
44 | | -es.extend( es.BlockView, es.DomContainerItem ); |
| 44 | +es.extend( es.BlockView, es.ViewContainerItem ); |