Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | * @method |
43 | 43 | * @returns {Integer} Length of all content |
44 | 44 | */ |
45 | | -es.ListBlockItemModel.prototype.getContentLength = function() { |
| 45 | +es.ListBlockItemModel.prototype.getLength = function() { |
46 | 46 | return this.content.getLength(); |
47 | 47 | }; |
48 | 48 | |
Index: trunk/parsers/wikidom/lib/synth/bases/es.ModelContainer.js |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | listName = 'items'; |
17 | 17 | } |
18 | 18 | this._listName = listName; |
19 | | - this[this._listName] = []; |
| 19 | + this[this._listName] = new es.AggregateArray(); |
20 | 20 | var container = this; |
21 | 21 | this.relayUpdate = function() { |
22 | 22 | container.emit( 'update' ); |
Index: trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js |
— | — | @@ -73,6 +73,7 @@ |
74 | 74 | // Append items until we reach the end |
75 | 75 | from = 0; |
76 | 76 | to = Math.min( right - left - 1, end - left ); |
| 77 | + |
77 | 78 | if ( from !== to ) { |
78 | 79 | items.push( { 'item': this[i], 'from': from, 'to': to } ); |
79 | 80 | } |
— | — | @@ -83,7 +84,8 @@ |
84 | 85 | inside = true; |
85 | 86 | // Append first item |
86 | 87 | from = start - left; |
87 | | - to = Math.min( right - 1, end - left ); |
| 88 | + //to = Math.min( right - 1, end - left ); |
| 89 | + to = Math.min( right - left - 1, end - left ); |
88 | 90 | if ( from !== to ) { |
89 | 91 | items.push( { 'item': this[i], 'from': from, 'to': to } ); |
90 | 92 | } |
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewContainer.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | if ( !this.containerModel ) { |
21 | 21 | return; |
22 | 22 | } |
23 | | - this.views = []; |
| 23 | + this.views = new es.AggregateArray(); |
24 | 24 | if ( typeof typeName !== 'string' ) { |
25 | 25 | typeName = 'viewContainer'; |
26 | 26 | } |
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js |
— | — | @@ -49,4 +49,12 @@ |
50 | 50 | return this.contentView.getLineIndex( position ); |
51 | 51 | }; |
52 | 52 | |
| 53 | +es.ListBlockItemView.prototype.getLength = function() { |
| 54 | + return this.model.getLength(); |
| 55 | +}; |
| 56 | + |
| 57 | +es.ListBlockItemView.prototype.drawSelection = function( range ) { |
| 58 | + this.contentView.drawSelection( range ); |
| 59 | +}; |
| 60 | + |
53 | 61 | es.extend( es.ListBlockItemView, es.ViewContainerItem ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js |
— | — | @@ -56,5 +56,18 @@ |
57 | 57 | //return this.contentView.getLineIndex( position ); |
58 | 58 | }; |
59 | 59 | |
| 60 | +es.ListBlockView.prototype.getLength = function() { |
| 61 | + return this.model.items.getLengthOfItems(); |
| 62 | +}; |
| 63 | + |
| 64 | +es.ListBlockView.prototype.drawSelection = function( range ) { |
| 65 | + var selectedViews = this.views.select( range ); |
| 66 | + for ( var i = 0; i < selectedViews.length; i++ ) { |
| 67 | + selectedViews[i].item.drawSelection( |
| 68 | + new es.Range( selectedViews[i].from, selectedViews[i].to ) |
| 69 | + ); |
| 70 | + } |
| 71 | +}; |
| 72 | + |
60 | 73 | es.extend( es.ListBlockView, es.ViewContainer ); |
61 | 74 | es.extend( es.ListBlockView, es.BlockView ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.ContentView.js |
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | toLineIndex = this.getLineIndex( range.end ), |
204 | 204 | fromPosition = this.getPosition( range.start ), |
205 | 205 | toPosition = this.getPosition( range.end ); |
206 | | - |
| 206 | + |
207 | 207 | if ( fromLineIndex === toLineIndex ) { |
208 | 208 | // Single line selection |
209 | 209 | this.$rangeStart.css( { |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js |
— | — | @@ -21,5 +21,18 @@ |
22 | 22 | } |
23 | 23 | }; |
24 | 24 | |
| 25 | +es.TableBlockRowView.prototype.getLength = function() { |
| 26 | + return this.views.getLengthOfItems(); |
| 27 | +}; |
| 28 | + |
| 29 | +es.TableBlockRowView.prototype.drawSelection = function( range ) { |
| 30 | + var selectedViews = this.views.select( range ); |
| 31 | + for ( var i = 0; i < selectedViews.length; i++ ) { |
| 32 | + selectedViews[i].item.drawSelection( |
| 33 | + new es.Range( selectedViews[i].from, selectedViews[i].to ) |
| 34 | + ); |
| 35 | + } |
| 36 | +}; |
| 37 | + |
25 | 38 | es.extend( es.TableBlockRowView, es.ViewContainer ); |
26 | 39 | es.extend( es.TableBlockRowView, es.ViewContainerItem ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js |
— | — | @@ -11,6 +11,19 @@ |
12 | 12 | } |
13 | 13 | }; |
14 | 14 | |
| 15 | +es.DocumentView.prototype.drawSelection = function( range ) { |
| 16 | + var selectedViews = this.views.select( range ); |
| 17 | + for ( var i = 0; i < selectedViews.length; i++ ) { |
| 18 | + selectedViews[i].item.drawSelection( |
| 19 | + new es.Range( selectedViews[i].from, selectedViews[i].to ) |
| 20 | + ); |
| 21 | + } |
| 22 | +}; |
| 23 | + |
| 24 | +es.DocumentView.prototype.getLength = function( ) { |
| 25 | + return this.views.getLengthOfItems(); |
| 26 | +}; |
| 27 | + |
15 | 28 | /* Inheritance */ |
16 | 29 | |
17 | 30 | es.extend( es.DocumentView, es.ViewContainer ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js |
— | — | @@ -38,4 +38,12 @@ |
39 | 39 | return this.contentView.getLineIndex( position ); |
40 | 40 | }; |
41 | 41 | |
| 42 | +es.ParagraphBlockView.prototype.getLength = function() { |
| 43 | + return this.model.getContentLength(); |
| 44 | +}; |
| 45 | + |
| 46 | +es.ParagraphBlockView.prototype.drawSelection = function( range ) { |
| 47 | + this.contentView.drawSelection( range ); |
| 48 | +}; |
| 49 | + |
42 | 50 | es.extend( es.ParagraphBlockView, es.BlockView ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js |
— | — | @@ -18,8 +18,16 @@ |
19 | 19 | * Render content. |
20 | 20 | */ |
21 | 21 | es.TableBlockCellView.prototype.renderContent = function() { |
22 | | - //debugger; |
23 | 22 | this.documentView.renderContent(); |
24 | 23 | }; |
25 | 24 | |
| 25 | +es.TableBlockCellView.prototype.getLength = function() { |
| 26 | + return this.documentView.getLength(); |
| 27 | +}; |
| 28 | + |
| 29 | +es.TableBlockCellView.prototype.drawSelection = function( range ) { |
| 30 | + this.documentView.drawSelection( range ); |
| 31 | +}; |
| 32 | + |
| 33 | + |
26 | 34 | es.extend( es.TableBlockCellView, es.ViewContainerItem ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js |
— | — | @@ -21,5 +21,18 @@ |
22 | 22 | } |
23 | 23 | }; |
24 | 24 | |
| 25 | +es.TableBlockView.prototype.getLength = function() { |
| 26 | + return this.views.getLengthOfItems(); |
| 27 | +}; |
| 28 | + |
| 29 | +es.TableBlockView.prototype.drawSelection = function( range ) { |
| 30 | + var selectedViews = this.views.select( range ); |
| 31 | + for ( var i = 0; i < selectedViews.length; i++ ) { |
| 32 | + selectedViews[i].item.drawSelection( |
| 33 | + new es.Range( selectedViews[i].from, selectedViews[i].to ) |
| 34 | + ); |
| 35 | + } |
| 36 | +}; |
| 37 | + |
25 | 38 | es.extend( es.TableBlockView, es.ViewContainer ); |
26 | 39 | es.extend( es.TableBlockView, es.BlockView ); |