Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | // Initialize document view |
13 | 13 | this.documentView = new es.DocumentView( this.model.getDocument() ); |
14 | 14 | this.$.append( this.documentView.$ ); |
15 | | - |
| 15 | + |
16 | 16 | // Interaction state |
17 | 17 | this.width = null; |
18 | 18 | this.mouse = { |
— | — | @@ -109,6 +109,9 @@ |
110 | 110 | * @param offset {Position} Offset to be added to position |
111 | 111 | */ |
112 | 112 | es.SurfaceView.prototype.showCursor = function( position, offset ) { |
| 113 | + |
| 114 | + // TODO: test/reimplement |
| 115 | + |
113 | 116 | if ( position ) { |
114 | 117 | if ( $.isPlainObject( offset ) ) { |
115 | 118 | position.left += offset.left; |
— | — | @@ -139,45 +142,15 @@ |
140 | 143 | * @method |
141 | 144 | */ |
142 | 145 | es.SurfaceView.prototype.hideCursor = function() { |
| 146 | + |
| 147 | + // TODO: test/reimplement |
| 148 | + |
143 | 149 | if( this.blinkInterval ) { |
144 | 150 | clearInterval( this.blinkInterval ); |
145 | 151 | } |
146 | 152 | this.$cursor.hide(); |
147 | 153 | }; |
148 | 154 | |
149 | | -es.SurfaceView.prototype.getLocationFromEvent = function( e ) { |
150 | | - var $target = $( e.target ), |
151 | | - $block = $target.is( '.editSurface-block' ) |
152 | | - ? $target : $target.closest( '.editSurface-block' ); |
153 | | - // Not a block or child of a block? Find the nearest block... |
154 | | - if ( !$block.length ) { |
155 | | - var $blocks = this.$.find( '> .editSurface-document .editSurface-block' ); |
156 | | - $block = $blocks.first(); |
157 | | - $blocks.each( function() { |
158 | | - // Stop looking when mouse is above top |
159 | | - if ( e.pageY <= $(this).offset().top ) { |
160 | | - return false; |
161 | | - } |
162 | | - $block = $(this); |
163 | | - } ); |
164 | | - } |
165 | | - var block = $block.data( 'block' ), |
166 | | - blockPosition = $block.offset(); |
167 | | - return new es.Location( |
168 | | - block, |
169 | | - block.getOffset( |
170 | | - new es.Position( |
171 | | - e.pageX - blockPosition.left, |
172 | | - e.pageY - blockPosition.top |
173 | | - ) |
174 | | - ) |
175 | | - ); |
176 | | -}; |
177 | | - |
178 | | -es.SurfaceView.prototype.getLocationFromOffset = function( offset ) { |
179 | | - |
180 | | -}; |
181 | | - |
182 | 155 | es.SurfaceView.prototype.onKeyDown = function( e ) { |
183 | 156 | switch ( e.keyCode ) { |
184 | 157 | case 16: // Shift |
— | — | @@ -291,10 +264,4 @@ |
292 | 265 | |
293 | 266 | es.SurfaceView.prototype.setInputContent = function( content ) { |
294 | 267 | // TODO: Set the value of this.$input |
295 | | -}; |
296 | | - |
297 | | -/* Inheritance */ |
298 | | - |
299 | | -es.SurfaceView.prototype.getLocationFromPosition = function( position ) { |
300 | | - |
301 | | -}; |
| 268 | +}; |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/synth/views/es.BlockView.js |
— | — | @@ -13,6 +13,14 @@ |
14 | 14 | this.$.addClass( 'editSurface-block' ); |
15 | 15 | this.$.data( 'block', this ); |
16 | 16 | }; |
| 17 | +/** |
| 18 | + * Render content. |
| 19 | + * |
| 20 | + * @method |
| 21 | + */ |
| 22 | +es.BlockView.prototype.renderContent = function() { |
| 23 | + throw 'BlockView.renderContent not implemented in this subclass.'; |
| 24 | +}; |
17 | 25 | |
18 | 26 | /** |
19 | 27 | * Draw selection around a given range. |
— | — | @@ -24,28 +32,23 @@ |
25 | 33 | throw 'BlockView.drawSelection not implemented in this subclass.'; |
26 | 34 | }; |
27 | 35 | |
28 | | -es.BlockView.prototype.clearSelection = function() { |
29 | | - throw 'BlockView.clearSelection not implemented in this subclass.'; |
30 | | -}; |
31 | | - |
32 | 36 | /** |
33 | | - * Render content. |
| 37 | + * Clear selection |
34 | 38 | * |
35 | 39 | * @method |
36 | 40 | */ |
37 | | -es.BlockView.prototype.renderContent = function() { |
38 | | - throw 'BlockView.renderContent not implemented in this subclass.'; |
| 41 | +es.BlockView.prototype.clearSelection = function() { |
| 42 | + throw 'BlockView.clearSelection not implemented in this subclass.'; |
39 | 43 | }; |
40 | 44 | |
41 | 45 | /** |
42 | | - * Gets offset within content of position. |
| 46 | + * Gets length of contents. |
43 | 47 | * |
44 | 48 | * @method |
45 | | - * @param position {es.Position} Position to get offset for |
46 | | - * @returns {Integer} Offset nearest to position |
| 49 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
47 | 50 | */ |
48 | | -es.BlockView.prototype.getContentOffset = function( position ) { |
49 | | - throw 'BlockView.getContentOffset not implemented in this subclass.'; |
| 51 | +es.BlockView.prototype.getLength = function() { |
| 52 | + throw 'BlockView.getLength not implemented in this subclass.'; |
50 | 53 | }; |
51 | 54 | |
52 | 55 | /** |
— | — | @@ -60,26 +63,6 @@ |
61 | 64 | }; |
62 | 65 | |
63 | 66 | /** |
64 | | - * Draw selection around a given range. |
65 | | - * |
66 | | - * @method |
67 | | - * @param range {es.Range} Range of content to draw selection around |
68 | | - */ |
69 | | -es.BlockView.prototype.drawSelection = function( range ) { |
70 | | - throw 'BlockView.drawSelection not implemented in this subclass.'; |
71 | | -}; |
72 | | - |
73 | | -/** |
74 | | - * Gets length of contents. |
75 | | - * |
76 | | - * @method |
77 | | - * @returns {Integer} Length of content, including any virtual spaces within the block |
78 | | - */ |
79 | | -es.BlockView.prototype.getLength = function() { |
80 | | - throw 'BlockView.getLength not implemented in this subclass.'; |
81 | | -}; |
82 | | - |
83 | | -/** |
84 | 67 | * Gets HTML rendering of block. |
85 | 68 | * |
86 | 69 | * @method |
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js |
— | — | @@ -12,6 +12,50 @@ |
13 | 13 | |
14 | 14 | /* Methods */ |
15 | 15 | |
| 16 | +/** |
| 17 | + * Render content. |
| 18 | + * |
| 19 | + * @method |
| 20 | + */ |
| 21 | +es.DocumentView.prototype.renderContent = function() { |
| 22 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 23 | + this.items[i].renderContent(); |
| 24 | + } |
| 25 | +}; |
| 26 | + |
| 27 | +/** |
| 28 | + * Draw selection around a given range. |
| 29 | + * |
| 30 | + * @method |
| 31 | + * @param range {es.Range} Range of content to draw selection around |
| 32 | + */ |
| 33 | +es.DocumentView.prototype.drawSelection = function( range ) { |
| 34 | + var views = this.items.select( range, null, true ); |
| 35 | + for ( var i = 0; i < views.on.length; i++ ) { |
| 36 | + views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) ); |
| 37 | + } |
| 38 | + for ( var i = 0; i < views.off.length; i++ ) { |
| 39 | + views.off[i].clearSelection(); |
| 40 | + } |
| 41 | +}; |
| 42 | + |
| 43 | +/** |
| 44 | + * Gets length of contents. |
| 45 | + * |
| 46 | + * @method |
| 47 | + * @returns {Integer} Length of content, including virtual spaces between blocks |
| 48 | + */ |
| 49 | +es.DocumentView.prototype.getLength = function() { |
| 50 | + return this.items.getLengthOfItems(); |
| 51 | +}; |
| 52 | + |
| 53 | +/** |
| 54 | + * Get the document offset of a position created from passed DOM event |
| 55 | + * |
| 56 | + * @method |
| 57 | + * @param e {Event} Event to create es.Position from |
| 58 | + * @returns {Integer} Document offset |
| 59 | + */ |
16 | 60 | es.DocumentView.prototype.getOffsetFromEvent = function( e ) { |
17 | 61 | var $target = $( e.target ), |
18 | 62 | $block = $target.is( '.editSurface-block' ) |
— | — | @@ -31,6 +75,13 @@ |
32 | 76 | } |
33 | 77 | }; |
34 | 78 | |
| 79 | +/** |
| 80 | + * Get the document offset of a position |
| 81 | + * |
| 82 | + * @method |
| 83 | + * @param position {es.Position} Position to translate |
| 84 | + * @returns {Integer} Document offset |
| 85 | + */ |
35 | 86 | es.DocumentView.prototype.getOffsetFromPosition = function( position ) { |
36 | 87 | if ( this.items.length === 0 ) { |
37 | 88 | return 0; |
— | — | @@ -49,28 +100,6 @@ |
50 | 101 | }; |
51 | 102 | |
52 | 103 | /** |
53 | | - * Render content. |
54 | | - * |
55 | | - * @method |
56 | | - */ |
57 | | -es.DocumentView.prototype.renderContent = function() { |
58 | | - for ( var i = 0; i < this.items.length; i++ ) { |
59 | | - this.items[i].renderContent(); |
60 | | - } |
61 | | -}; |
62 | | - |
63 | | -/** |
64 | | - * Gets offset within content of position. |
65 | | - * |
66 | | - * @method |
67 | | - * @param position {es.Position} Position to get offset for |
68 | | - * @returns {Integer} Offset nearest to position |
69 | | - */ |
70 | | -es.DocumentView.prototype.getContentOffset = function( position ) { |
71 | | - // TODO |
72 | | -}; |
73 | | - |
74 | | -/** |
75 | 104 | * Gets rendered position of offset within content. |
76 | 105 | * |
77 | 106 | * @method |
— | — | @@ -82,32 +111,6 @@ |
83 | 112 | }; |
84 | 113 | |
85 | 114 | /** |
86 | | - * Draw selection around a given range. |
87 | | - * |
88 | | - * @method |
89 | | - * @param range {es.Range} Range of content to draw selection around |
90 | | - */ |
91 | | -es.DocumentView.prototype.drawSelection = function( range ) { |
92 | | - var views = this.items.select( range, null, true ); |
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 | | -/** |
102 | | - * Gets length of contents. |
103 | | - * |
104 | | - * @method |
105 | | - * @returns {Integer} Length of content, including virtual spaces between blocks |
106 | | - */ |
107 | | -es.DocumentView.prototype.getLength = function() { |
108 | | - return this.items.getLengthOfItems(); |
109 | | -}; |
110 | | - |
111 | | -/** |
112 | 115 | * Gets HTML rendering of document. |
113 | 116 | * |
114 | 117 | * @method |
— | — | @@ -126,4 +129,4 @@ |
127 | 130 | |
128 | 131 | /* Inheritance */ |
129 | 132 | |
130 | | -es.extend( es.DocumentView, es.ViewList ); |
| 133 | +es.extend( es.DocumentView, es.ViewList ); |
\ No newline at end of file |