Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js |
— | — | @@ -24,7 +24,6 @@ |
25 | 25 | |
26 | 26 | /* Methods */ |
27 | 27 | |
28 | | - |
29 | 28 | /** |
30 | 29 | * Render content. |
31 | 30 | * |
— | — | @@ -35,28 +34,6 @@ |
36 | 35 | }; |
37 | 36 | |
38 | 37 | /** |
39 | | - * Gets offset within content of position. |
40 | | - * |
41 | | - * @method |
42 | | - * @param position {es.Position} Position to get offset for |
43 | | - * @returns {Integer} Offset nearest to position |
44 | | - */ |
45 | | -es.ListBlockItemView.prototype.getContentOffset = function( position ) { |
46 | | - return this.contentView.getOffset( position ); |
47 | | -}; |
48 | | - |
49 | | -/** |
50 | | - * Gets rendered position of offset within content. |
51 | | - * |
52 | | - * @method |
53 | | - * @param offset {Integer} Offset to get position for |
54 | | - * @returns {es.Position} Position of offset |
55 | | - */ |
56 | | -es.ListBlockItemView.prototype.getRenderedPosition = function( offset ) { |
57 | | - return this.contentView.getPosition( position ); |
58 | | -}; |
59 | | - |
60 | | -/** |
61 | 38 | * Draw selection around a given range. |
62 | 39 | * |
63 | 40 | * @method |
— | — | @@ -81,6 +58,28 @@ |
82 | 59 | }; |
83 | 60 | |
84 | 61 | /** |
| 62 | + * Gets offset within content of position. |
| 63 | + * |
| 64 | + * @method |
| 65 | + * @param position {es.Position} Position to get offset for |
| 66 | + * @returns {Integer} Offset nearest to position |
| 67 | + */ |
| 68 | +es.ListBlockItemView.prototype.getOffsetFromPosition = function( position ) { |
| 69 | + return this.contentView.getOffset( position ); |
| 70 | +}; |
| 71 | + |
| 72 | +/** |
| 73 | + * Gets rendered position of offset within content. |
| 74 | + * |
| 75 | + * @method |
| 76 | + * @param offset {Integer} Offset to get position for |
| 77 | + * @returns {es.Position} Position of offset |
| 78 | + */ |
| 79 | +es.ListBlockItemView.prototype.getRenderedPosition = function( offset ) { |
| 80 | + return this.contentView.getPosition( position ); |
| 81 | +}; |
| 82 | + |
| 83 | +/** |
85 | 84 | * Gets HTML rendering of block. |
86 | 85 | * |
87 | 86 | * @method |
— | — | @@ -93,7 +92,7 @@ |
94 | 93 | { 'class': this.$.attr( 'class' ) }, |
95 | 94 | this.contentView.getHtml() |
96 | 95 | ); |
97 | | -} |
| 96 | +}; |
98 | 97 | |
99 | 98 | /** |
100 | 99 | * Sets the number label of the item, used for unordered lists |
— | — | @@ -106,4 +105,4 @@ |
107 | 106 | |
108 | 107 | /* Inheritance */ |
109 | 108 | |
110 | | -es.extend( es.ListBlockItemView, es.ViewListItem ); |
| 109 | +es.extend( es.ListBlockItemView, es.ViewListItem ); |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js |
— | — | @@ -19,27 +19,14 @@ |
20 | 20 | /* Methods */ |
21 | 21 | |
22 | 22 | /** |
23 | | - * Gets the offset of a position. |
| 23 | + * Render content. |
24 | 24 | * |
25 | 25 | * @method |
26 | | - * @param position {es.Position} Position to translate |
27 | | - * @returns {Integer} Offset nearest to position |
28 | 26 | */ |
29 | | -es.ListBlockView.prototype.getOffsetFromPosition = function( position ) { |
30 | | - if ( this.items.length === 0 ) { |
31 | | - return 0; |
32 | | - } |
33 | | - |
34 | | - var listItemView = this.items[0]; |
35 | | - |
| 27 | +es.ListBlockView.prototype.renderContent = function() { |
36 | 28 | for ( var i = 0; i < this.items.length; i++ ) { |
37 | | - if ( this.items[i].$.offset().top >= position.top ) { |
38 | | - break; |
39 | | - } |
40 | | - listItemView = this.items[i]; |
| 29 | + this.items[i].renderContent(); |
41 | 30 | } |
42 | | - |
43 | | - return listItemView.list.items.offsetOf( listItemView ) + listItemView.getContentOffset( position ); |
44 | 31 | }; |
45 | 32 | |
46 | 33 | /** |
— | — | @@ -66,25 +53,37 @@ |
67 | 54 | }; |
68 | 55 | |
69 | 56 | /** |
70 | | - * Render content. |
| 57 | + * Gets length of contents. |
71 | 58 | * |
72 | 59 | * @method |
| 60 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
73 | 61 | */ |
74 | | -es.ListBlockView.prototype.renderContent = function() { |
75 | | - for ( var i = 0; i < this.items.length; i++ ) { |
76 | | - this.items[i].renderContent(); |
77 | | - } |
| 62 | +es.ListBlockView.prototype.getLength = function() { |
| 63 | + return this.model.items.getLengthOfItems(); |
78 | 64 | }; |
79 | 65 | |
80 | 66 | /** |
81 | | - * Gets offset within content of position. |
| 67 | + * Gets the offset of a position. |
82 | 68 | * |
83 | 69 | * @method |
84 | | - * @param position {es.Position} Position to get offset for |
| 70 | + * @param position {es.Position} Position to translate |
85 | 71 | * @returns {Integer} Offset nearest to position |
86 | 72 | */ |
87 | | -es.ListBlockView.prototype.getContentOffset = function( position ) { |
88 | | - // TODO |
| 73 | +es.ListBlockView.prototype.getOffsetFromPosition = function( position ) { |
| 74 | + if ( this.items.length === 0 ) { |
| 75 | + return 0; |
| 76 | + } |
| 77 | + |
| 78 | + var listItemView = this.items[0]; |
| 79 | + |
| 80 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 81 | + if ( this.items[i].$.offset().top >= position.top ) { |
| 82 | + break; |
| 83 | + } |
| 84 | + listItemView = this.items[i]; |
| 85 | + } |
| 86 | + |
| 87 | + return listItemView.list.items.offsetOf( listItemView ) + listItemView.getOffsetFromPosition( position ); |
89 | 88 | }; |
90 | 89 | |
91 | 90 | /** |
— | — | @@ -99,16 +98,6 @@ |
100 | 99 | }; |
101 | 100 | |
102 | 101 | /** |
103 | | - * Gets length of contents. |
104 | | - * |
105 | | - * @method |
106 | | - * @returns {Integer} Length of content, including any virtual spaces within the block |
107 | | - */ |
108 | | -es.ListBlockView.prototype.getLength = function() { |
109 | | - return this.model.items.getLengthOfItems(); |
110 | | -}; |
111 | | - |
112 | | -/** |
113 | 102 | * Gets HTML rendering of block. |
114 | 103 | * |
115 | 104 | * @method |
— | — | @@ -149,4 +138,4 @@ |
150 | 139 | /* Inheritance */ |
151 | 140 | |
152 | 141 | es.extend( es.ListBlockView, es.ViewList ); |
153 | | -es.extend( es.ListBlockView, es.BlockView ); |
| 142 | +es.extend( es.ListBlockView, es.BlockView ); |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/synth/views/es.HeadingBlockView.js |
— | — | @@ -8,6 +8,12 @@ |
9 | 9 | } ); |
10 | 10 | }; |
11 | 11 | |
| 12 | +/* Methods */ |
| 13 | + |
| 14 | +es.HeadingBlockView.prototype.renderContent = function() { |
| 15 | + this.contentView.render(); |
| 16 | +}; |
| 17 | + |
12 | 18 | es.HeadingBlockView.prototype.drawSelection = function( range ) { |
13 | 19 | this.contentView.drawSelection( range ); |
14 | 20 | }; |
— | — | @@ -16,10 +22,6 @@ |
17 | 23 | this.contentView.clearSelection(); |
18 | 24 | }; |
19 | 25 | |
20 | | -es.HeadingBlockView.prototype.renderContent = function() { |
21 | | - this.contentView.render(); |
22 | | -}; |
23 | | - |
24 | 26 | es.HeadingBlockView.prototype.getLength = function() { |
25 | 27 | return this.model.getContentLength(); |
26 | 28 | }; |
— | — | @@ -28,4 +30,6 @@ |
29 | 31 | return this.contentView.getOffset( position ); |
30 | 32 | }; |
31 | 33 | |
| 34 | +/* Inheritance */ |
| 35 | + |
32 | 36 | es.extend( es.HeadingBlockView, es.BlockView ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js |
— | — | @@ -15,30 +15,6 @@ |
16 | 16 | /* Methods */ |
17 | 17 | |
18 | 18 | /** |
19 | | - * Gets the offset of a position. |
20 | | - * |
21 | | - * @method |
22 | | - * @param position {es.Position} Position to translate |
23 | | - * @returns {Integer} Offset nearest to position |
24 | | - */ |
25 | | -es.TableBlockRowView.prototype.getOffsetFromPosition = function( position ) { |
26 | | - if ( this.items.length === 0 ) { |
27 | | - return 0; |
28 | | - } |
29 | | - |
30 | | - var cellView = this.items[0]; |
31 | | - |
32 | | - for ( var i = 0; i < this.items.length; i++ ) { |
33 | | - if ( this.items[i].$.offset().left >= position.left ) { |
34 | | - break; |
35 | | - } |
36 | | - cellView = this.items[i]; |
37 | | - } |
38 | | - |
39 | | - return cellView.list.items.offsetOf( cellView ) + cellView.getOffsetFromPosition( position ); |
40 | | -}; |
41 | | - |
42 | | -/** |
43 | 19 | * Render content. |
44 | 20 | * |
45 | 21 | * @method |
— | — | @@ -50,28 +26,6 @@ |
51 | 27 | }; |
52 | 28 | |
53 | 29 | /** |
54 | | - * Gets offset within content of position. |
55 | | - * |
56 | | - * @method |
57 | | - * @param position {es.Position} Position to get offset for |
58 | | - * @returns {Integer} Offset nearest to position |
59 | | - */ |
60 | | -es.TableBlockRowView.prototype.getContentOffset = function( position ) { |
61 | | - // TODO |
62 | | -}; |
63 | | - |
64 | | -/** |
65 | | - * Gets rendered position of offset within content. |
66 | | - * |
67 | | - * @method |
68 | | - * @param offset {Integer} Offset to get position for |
69 | | - * @returns {es.Position} Position of offset |
70 | | - */ |
71 | | -es.TableBlockRowView.prototype.getRenderedPosition = function( offset ) { |
72 | | - // TODO |
73 | | -}; |
74 | | - |
75 | | -/** |
76 | 30 | * Draw selection around a given range. |
77 | 31 | * |
78 | 32 | * @method |
— | — | @@ -105,6 +59,41 @@ |
106 | 60 | }; |
107 | 61 | |
108 | 62 | /** |
| 63 | + * Gets the offset of a position. |
| 64 | + * |
| 65 | + * @method |
| 66 | + * @param position {es.Position} Position to translate |
| 67 | + * @returns {Integer} Offset nearest to position |
| 68 | + */ |
| 69 | +es.TableBlockRowView.prototype.getOffsetFromPosition = function( position ) { |
| 70 | + if ( this.items.length === 0 ) { |
| 71 | + return 0; |
| 72 | + } |
| 73 | + |
| 74 | + var cellView = this.items[0]; |
| 75 | + |
| 76 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 77 | + if ( this.items[i].$.offset().left >= position.left ) { |
| 78 | + break; |
| 79 | + } |
| 80 | + cellView = this.items[i]; |
| 81 | + } |
| 82 | + |
| 83 | + return cellView.list.items.offsetOf( cellView ) + cellView.getOffsetFromPosition( position ); |
| 84 | +}; |
| 85 | + |
| 86 | +/** |
| 87 | + * Gets rendered position of offset within content. |
| 88 | + * |
| 89 | + * @method |
| 90 | + * @param offset {Integer} Offset to get position for |
| 91 | + * @returns {es.Position} Position of offset |
| 92 | + */ |
| 93 | +es.TableBlockRowView.prototype.getRenderedPosition = function( offset ) { |
| 94 | + // TODO |
| 95 | +}; |
| 96 | + |
| 97 | +/** |
109 | 98 | * Gets HTML rendering of block. |
110 | 99 | * |
111 | 100 | * @method |
— | — | @@ -115,9 +104,9 @@ |
116 | 105 | return es.Html.makeTag( 'tr', this.model.attributes, $.map( this.items, function( view ) { |
117 | 106 | return view.getHtml(); |
118 | 107 | } ).join( '' ) ); |
119 | | -} |
| 108 | +}; |
120 | 109 | |
121 | 110 | /* Inheritance */ |
122 | 111 | |
123 | 112 | es.extend( es.TableBlockRowView, es.ViewList ); |
124 | | -es.extend( es.TableBlockRowView, es.ViewListItem ); |
| 113 | +es.extend( es.TableBlockRowView, es.ViewListItem ); |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js |
— | — | @@ -18,17 +18,6 @@ |
19 | 19 | /* Methods */ |
20 | 20 | |
21 | 21 | /** |
22 | | - * Gets the offset of a position. |
23 | | - * |
24 | | - * @method |
25 | | - * @param position {es.Position} Position to translate |
26 | | - * @returns {Integer} Offset nearest to position |
27 | | - */ |
28 | | -es.ParagraphBlockView.prototype.getOffsetFromPosition = function( position ) { |
29 | | - return this.contentView.getOffset( position ); |
30 | | -}; |
31 | | - |
32 | | -/** |
33 | 22 | * Render content. |
34 | 23 | * |
35 | 24 | * @method |
— | — | @@ -38,28 +27,6 @@ |
39 | 28 | }; |
40 | 29 | |
41 | 30 | /** |
42 | | - * Gets offset within content of position. |
43 | | - * |
44 | | - * @method |
45 | | - * @param position {es.Position} Position to get offset for |
46 | | - * @returns {Integer} Offset nearest to position |
47 | | - */ |
48 | | -es.ParagraphBlockView.prototype.getContentOffset = function( position ) { |
49 | | - return this.contentView.getOffset( position ); |
50 | | -}; |
51 | | - |
52 | | -/** |
53 | | - * Gets rendered position of offset within content. |
54 | | - * |
55 | | - * @method |
56 | | - * @param offset {Integer} Offset to get position for |
57 | | - * @returns {es.Position} Position of offset |
58 | | - */ |
59 | | -es.ParagraphBlockView.prototype.getRenderedPosition = function( offset ) { |
60 | | - return this.contentView.getPosition( position ); |
61 | | -}; |
62 | | - |
63 | | -/** |
64 | 31 | * Draw selection around a given range. |
65 | 32 | * |
66 | 33 | * @method |
— | — | @@ -84,6 +51,28 @@ |
85 | 52 | }; |
86 | 53 | |
87 | 54 | /** |
| 55 | + * Gets the offset of a position. |
| 56 | + * |
| 57 | + * @method |
| 58 | + * @param position {es.Position} Position to translate |
| 59 | + * @returns {Integer} Offset nearest to position |
| 60 | + */ |
| 61 | +es.ParagraphBlockView.prototype.getOffsetFromPosition = function( position ) { |
| 62 | + return this.contentView.getOffset( position ); |
| 63 | +}; |
| 64 | + |
| 65 | +/** |
| 66 | + * Gets rendered position of offset within content. |
| 67 | + * |
| 68 | + * @method |
| 69 | + * @param offset {Integer} Offset to get position for |
| 70 | + * @returns {es.Position} Position of offset |
| 71 | + */ |
| 72 | +es.ParagraphBlockView.prototype.getRenderedPosition = function( offset ) { |
| 73 | + return this.contentView.getPosition( position ); |
| 74 | +}; |
| 75 | + |
| 76 | +/** |
88 | 77 | * Gets HTML rendering of block. |
89 | 78 | * |
90 | 79 | * @method |
— | — | @@ -100,4 +89,4 @@ |
101 | 90 | |
102 | 91 | /* Inheritance */ |
103 | 92 | |
104 | | -es.extend( es.ParagraphBlockView, es.BlockView ); |
| 93 | +es.extend( es.ParagraphBlockView, es.BlockView ); |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js |
— | — | @@ -14,27 +14,37 @@ |
15 | 15 | /* Methods */ |
16 | 16 | |
17 | 17 | /** |
18 | | - * Gets the offset of a position. |
| 18 | + * Render content. |
19 | 19 | * |
20 | 20 | * @method |
21 | | - * @param position {es.Position} Position to translate |
22 | | - * @returns {Integer} Offset nearest to position |
23 | 21 | */ |
24 | | -es.TableBlockCellView.prototype.getOffsetFromPosition = function( position ) { |
25 | | - if ( this.items.length === 0 ) { |
26 | | - return 0; |
| 22 | +es.TableBlockCellView.prototype.renderContent = function() { |
| 23 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 24 | + this.items[i].renderContent(); |
27 | 25 | } |
28 | | - |
29 | | - var blockView = this.items[0]; |
| 26 | +}; |
30 | 27 | |
| 28 | +/** |
| 29 | + * Draw selection around a given range. |
| 30 | + * |
| 31 | + * @method |
| 32 | + * @param range {es.Range} Range of content to draw selection around |
| 33 | + */ |
| 34 | +es.TableBlockCellView.prototype.drawSelection = function( range ) { |
| 35 | + var views = this.items.select( range, null, true ); |
| 36 | + |
| 37 | + for ( var i = 0; i < views.on.length; i++ ) { |
| 38 | + views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) ); |
| 39 | + } |
| 40 | + for ( var i = 0; i < views.off.length; i++ ) { |
| 41 | + views.off[i].clearSelection(); |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +es.TableBlockCellView.prototype.clearSelection = function( range ) { |
31 | 46 | for ( var i = 0; i < this.items.length; i++ ) { |
32 | | - if ( this.items[i].$.offset().top >= position.top ) { |
33 | | - break; |
34 | | - } |
35 | | - blockView = this.items[i]; |
| 47 | + this.items[i].clearSelection(); |
36 | 48 | } |
37 | | - |
38 | | - return blockView.list.items.offsetOf( blockView ) + blockView.getOffsetFromPosition( position ); |
39 | 49 | }; |
40 | 50 | |
41 | 51 | /** |
— | — | @@ -48,28 +58,30 @@ |
49 | 59 | }; |
50 | 60 | |
51 | 61 | /** |
52 | | - * Render content. |
| 62 | + * Gets the offset of a position. |
53 | 63 | * |
54 | 64 | * @method |
| 65 | + * @param position {es.Position} Position to translate |
| 66 | + * @returns {Integer} Offset nearest to position |
55 | 67 | */ |
56 | | -es.TableBlockCellView.prototype.renderContent = function() { |
| 68 | +es.TableBlockCellView.prototype.getOffsetFromPosition = function( position ) { |
| 69 | + if ( this.items.length === 0 ) { |
| 70 | + return 0; |
| 71 | + } |
| 72 | + |
| 73 | + var blockView = this.items[0]; |
| 74 | + |
57 | 75 | for ( var i = 0; i < this.items.length; i++ ) { |
58 | | - this.items[i].renderContent(); |
| 76 | + if ( this.items[i].$.offset().top >= position.top ) { |
| 77 | + break; |
| 78 | + } |
| 79 | + blockView = this.items[i]; |
59 | 80 | } |
| 81 | + |
| 82 | + return blockView.list.items.offsetOf( blockView ) + blockView.getOffsetFromPosition( position ); |
60 | 83 | }; |
61 | 84 | |
62 | 85 | /** |
63 | | - * Gets offset within content of position. |
64 | | - * |
65 | | - * @method |
66 | | - * @param position {es.Position} Position to get offset for |
67 | | - * @returns {Integer} Offset nearest to position |
68 | | - */ |
69 | | -es.TableBlockCellView.prototype.getContentOffset = function( position ) { |
70 | | - // TODO |
71 | | -}; |
72 | | - |
73 | | -/** |
74 | 86 | * Gets rendered position of offset within content. |
75 | 87 | * |
76 | 88 | * @method |
— | — | @@ -81,29 +93,6 @@ |
82 | 94 | }; |
83 | 95 | |
84 | 96 | /** |
85 | | - * Draw selection around a given range. |
86 | | - * |
87 | | - * @method |
88 | | - * @param range {es.Range} Range of content to draw selection around |
89 | | - */ |
90 | | -es.TableBlockCellView.prototype.drawSelection = function( range ) { |
91 | | - var views = this.items.select( range, null, true ); |
92 | | - |
93 | | - for ( var i = 0; i < views.on.length; i++ ) { |
94 | | - views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) ); |
95 | | - } |
96 | | - for ( var i = 0; i < views.off.length; i++ ) { |
97 | | - views.off[i].clearSelection(); |
98 | | - } |
99 | | -}; |
100 | | - |
101 | | -es.TableBlockCellView.prototype.clearSelection = function( range ) { |
102 | | - for ( var i = 0; i < this.items.length; i++ ) { |
103 | | - this.items[i].clearSelection(); |
104 | | - } |
105 | | -}; |
106 | | - |
107 | | -/** |
108 | 97 | * Gets HTML rendering of block. |
109 | 98 | * |
110 | 99 | * @method |
— | — | @@ -112,7 +101,7 @@ |
113 | 102 | */ |
114 | 103 | es.TableBlockCellView.prototype.getHtml = function( options ) { |
115 | 104 | return es.Html.makeTag( 'td', this.model.attributes, this.documentView.getHtml() ); |
116 | | -} |
| 105 | +}; |
117 | 106 | |
118 | 107 | /* Inheritance */ |
119 | 108 | |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js |
— | — | @@ -16,30 +16,6 @@ |
17 | 17 | /* Methods */ |
18 | 18 | |
19 | 19 | /** |
20 | | - * Gets the offset of a position. |
21 | | - * |
22 | | - * @method |
23 | | - * @param position {es.Position} Position to translate |
24 | | - * @returns {Integer} Offset nearest to position |
25 | | - */ |
26 | | -es.TableBlockView.prototype.getOffsetFromPosition = function( position ) { |
27 | | - if ( this.items.length === 0 ) { |
28 | | - return 0; |
29 | | - } |
30 | | - |
31 | | - var rowView = this.items[0]; |
32 | | - |
33 | | - for ( var i = 0; i < this.items.length; i++ ) { |
34 | | - if ( this.items[i].$.offset().top >= position.top ) { |
35 | | - break; |
36 | | - } |
37 | | - rowView = this.items[i]; |
38 | | - } |
39 | | - |
40 | | - return rowView.list.items.offsetOf( rowView ) + rowView.getOffsetFromPosition( position ); |
41 | | -}; |
42 | | - |
43 | | -/** |
44 | 20 | * Render content. |
45 | 21 | * |
46 | 22 | * @method |
— | — | @@ -51,28 +27,6 @@ |
52 | 28 | }; |
53 | 29 | |
54 | 30 | /** |
55 | | - * Gets offset within content of position. |
56 | | - * |
57 | | - * @method |
58 | | - * @param position {es.Position} Position to get offset for |
59 | | - * @returns {Integer} Offset nearest to position |
60 | | - */ |
61 | | -es.TableBlockView.prototype.getContentOffset = function( position ) { |
62 | | - // TODO |
63 | | -}; |
64 | | - |
65 | | -/** |
66 | | - * Gets rendered position of offset within content. |
67 | | - * |
68 | | - * @method |
69 | | - * @param offset {Integer} Offset to get position for |
70 | | - * @returns {es.Position} Position of offset |
71 | | - */ |
72 | | -es.TableBlockView.prototype.getRenderedPosition = function( offset ) { |
73 | | - // TODO |
74 | | -}; |
75 | | - |
76 | | -/** |
77 | 31 | * Draw selection around a given range. |
78 | 32 | * |
79 | 33 | * @method |
— | — | @@ -106,6 +60,41 @@ |
107 | 61 | }; |
108 | 62 | |
109 | 63 | /** |
| 64 | + * Gets the offset of a position. |
| 65 | + * |
| 66 | + * @method |
| 67 | + * @param position {es.Position} Position to translate |
| 68 | + * @returns {Integer} Offset nearest to position |
| 69 | + */ |
| 70 | +es.TableBlockView.prototype.getOffsetFromPosition = function( position ) { |
| 71 | + if ( this.items.length === 0 ) { |
| 72 | + return 0; |
| 73 | + } |
| 74 | + |
| 75 | + var rowView = this.items[0]; |
| 76 | + |
| 77 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 78 | + if ( this.items[i].$.offset().top >= position.top ) { |
| 79 | + break; |
| 80 | + } |
| 81 | + rowView = this.items[i]; |
| 82 | + } |
| 83 | + |
| 84 | + return rowView.list.items.offsetOf( rowView ) + rowView.getOffsetFromPosition( position ); |
| 85 | +}; |
| 86 | + |
| 87 | +/** |
| 88 | + * Gets rendered position of offset within content. |
| 89 | + * |
| 90 | + * @method |
| 91 | + * @param offset {Integer} Offset to get position for |
| 92 | + * @returns {es.Position} Position of offset |
| 93 | + */ |
| 94 | +es.TableBlockView.prototype.getRenderedPosition = function( offset ) { |
| 95 | + // TODO |
| 96 | +}; |
| 97 | + |
| 98 | +/** |
110 | 99 | * Gets HTML rendering of block. |
111 | 100 | * |
112 | 101 | * @method |
— | — | @@ -116,9 +105,9 @@ |
117 | 106 | return es.Html.makeTag( 'table', this.model.attributes, $.map( this.items, function( view ) { |
118 | 107 | return view.getHtml(); |
119 | 108 | } ).join( '' ) ); |
120 | | -} |
| 109 | +}; |
121 | 110 | |
122 | 111 | /* Inheritance */ |
123 | 112 | |
124 | 113 | es.extend( es.TableBlockView, es.ViewList ); |
125 | | -es.extend( es.TableBlockView, es.BlockView ); |
| 114 | +es.extend( es.TableBlockView, es.BlockView ); |
\ No newline at end of file |