Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | * Creates an es.ListBlockItemView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewListItem} |
6 | 7 | * @constructor |
7 | 8 | */ |
8 | 9 | es.ListBlockItemView = function( model ) { |
— | — | @@ -21,48 +22,62 @@ |
22 | 23 | } ); |
23 | 24 | }; |
24 | 25 | |
| 26 | +/* Methods */ |
| 27 | + |
| 28 | + |
25 | 29 | /** |
26 | 30 | * Render content. |
| 31 | + * |
| 32 | + * @method |
27 | 33 | */ |
28 | 34 | es.ListBlockItemView.prototype.renderContent = function() { |
29 | 35 | this.contentView.render(); |
30 | 36 | }; |
31 | 37 | |
32 | | -es.ListBlockItemView.prototype.setNumber = function( number ) { |
33 | | - this.$icon.text( number + '.' ); |
34 | | -}; |
35 | | - |
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 |
38 | 44 | */ |
39 | | -es.ListBlockItemView.getContentOffset = function( position ) { |
| 45 | +es.ListBlockItemView.prototype.getContentOffset = function( position ) { |
40 | 46 | return this.contentView.getOffset( position ); |
41 | 47 | }; |
42 | 48 | |
43 | 49 | /** |
44 | 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 |
45 | 55 | */ |
46 | | -es.ListBlockItemView.getRenderedPosition = function( offset ) { |
| 56 | +es.ListBlockItemView.prototype.getRenderedPosition = function( offset ) { |
47 | 57 | return this.contentView.getPosition( position ); |
48 | 58 | }; |
49 | 59 | |
50 | 60 | /** |
51 | | - * Gets rendered line index of offset within content. |
| 61 | + * Draw selection around a given range. |
| 62 | + * |
| 63 | + * @method |
| 64 | + * @param range {es.Range} Range of content to draw selection around |
52 | 65 | */ |
53 | | -es.ListBlockItemView.getRenderedLineIndex = function( offset ) { |
54 | | - return this.contentView.getLineIndex( position ); |
| 66 | +es.ListBlockItemView.prototype.drawSelection = function( range ) { |
| 67 | + this.contentView.drawSelection( range ); |
55 | 68 | }; |
56 | 69 | |
| 70 | +/** |
| 71 | + * Gets length of contents. |
| 72 | + * |
| 73 | + * @method |
| 74 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 75 | + */ |
57 | 76 | es.ListBlockItemView.prototype.getLength = function() { |
58 | 77 | return this.model.getLength(); |
59 | 78 | }; |
60 | 79 | |
61 | | -es.ListBlockItemView.prototype.drawSelection = function( range ) { |
62 | | - this.contentView.drawSelection( range ); |
63 | | -}; |
64 | | - |
65 | 80 | /** |
66 | | - * Gets HTML rendering of item. |
| 81 | + * Gets HTML rendering of block. |
67 | 82 | * |
68 | 83 | * @method |
69 | 84 | * @param options {Object} List of options, see es.DocumentView.getHtml for details |
— | — | @@ -74,6 +89,15 @@ |
75 | 90 | { 'class': this.$.attr( 'class' ) }, |
76 | 91 | this.contentView.getHtml() |
77 | 92 | ); |
| 93 | +} |
| 94 | + |
| 95 | +/** |
| 96 | + * Sets the number label of the item, used for unordered lists |
| 97 | + * |
| 98 | + * @method |
| 99 | + */ |
| 100 | +es.ListBlockItemView.prototype.setNumber = function( number ) { |
| 101 | + this.$icon.text( number + '.' ); |
78 | 102 | }; |
79 | 103 | |
80 | 104 | /* Inheritance */ |
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | * Creates an es.ListBlockView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewList} |
| 7 | + * @extends {es.BlockView} |
6 | 8 | * @constructor |
7 | 9 | */ |
8 | 10 | es.ListBlockView = function( model ) { |
— | — | @@ -14,8 +16,12 @@ |
15 | 17 | } ); |
16 | 18 | }; |
17 | 19 | |
| 20 | +/* Methods */ |
| 21 | + |
18 | 22 | /** |
19 | 23 | * Render content. |
| 24 | + * |
| 25 | + * @method |
20 | 26 | */ |
21 | 27 | es.ListBlockView.prototype.renderContent = function() { |
22 | 28 | for ( var i = 0; i < this.items.length; i++ ) { |
— | — | @@ -23,47 +29,34 @@ |
24 | 30 | } |
25 | 31 | }; |
26 | 32 | |
27 | | -es.ListBlockView.prototype.enumerate = function() { |
28 | | - var itemLevel, |
29 | | - levels = []; |
30 | | - |
31 | | - for ( var i = 0; i < this.items.length; i++ ) { |
32 | | - itemLevel = this.items[i].model.getLevel(); |
33 | | - levels = levels.slice(0, itemLevel + 1); |
34 | | - if ( this.items[i].model.getStyle() === 'number' ) { |
35 | | - if ( !levels[itemLevel] ) { |
36 | | - levels[itemLevel] = 0; |
37 | | - } |
38 | | - this.items[i].setNumber( ++levels[itemLevel] ); |
39 | | - } |
40 | | - } |
41 | | -}; |
42 | | - |
43 | 33 | /** |
44 | 34 | * Gets offset within content of position. |
| 35 | + * |
| 36 | + * @method |
| 37 | + * @param position {es.Position} Position to get offset for |
| 38 | + * @returns {Integer} Offset nearest to position |
45 | 39 | */ |
46 | | -es.ListBlockView.getContentOffset = function( position ) { |
47 | | - //return this.contentView.getOffset( position ); |
| 40 | +es.ListBlockView.prototype.getContentOffset = function( position ) { |
| 41 | + // TODO |
48 | 42 | }; |
49 | 43 | |
50 | 44 | /** |
51 | 45 | * Gets rendered position of offset within content. |
| 46 | + * |
| 47 | + * @method |
| 48 | + * @param offset {Integer} Offset to get position for |
| 49 | + * @returns {es.Position} Position of offset |
52 | 50 | */ |
53 | | -es.ListBlockView.getRenderedPosition = function( offset ) { |
54 | | - //return this.contentView.getPosition( position ); |
| 51 | +es.ListBlockView.prototype.getRenderedPosition = function( offset ) { |
| 52 | + // TODO |
55 | 53 | }; |
56 | 54 | |
57 | 55 | /** |
58 | | - * Gets rendered line index of offset within content. |
| 56 | + * Draw selection around a given range. |
| 57 | + * |
| 58 | + * @method |
| 59 | + * @param range {es.Range} Range of content to draw selection around |
59 | 60 | */ |
60 | | -es.ListBlockView.getRenderedLineIndex = function( offset ) { |
61 | | - //return this.contentView.getLineIndex( position ); |
62 | | -}; |
63 | | - |
64 | | -es.ListBlockView.prototype.getLength = function() { |
65 | | - return this.model.items.getLengthOfItems(); |
66 | | -}; |
67 | | - |
68 | 61 | es.ListBlockView.prototype.drawSelection = function( range ) { |
69 | 62 | var selectedViews = this.items.select( range ); |
70 | 63 | for ( var i = 0; i < selectedViews.length; i++ ) { |
— | — | @@ -74,6 +67,16 @@ |
75 | 68 | }; |
76 | 69 | |
77 | 70 | /** |
| 71 | + * Gets length of contents. |
| 72 | + * |
| 73 | + * @method |
| 74 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 75 | + */ |
| 76 | +es.ListBlockView.prototype.getLength = function() { |
| 77 | + return this.model.items.getLengthOfItems(); |
| 78 | +}; |
| 79 | + |
| 80 | +/** |
78 | 81 | * Gets HTML rendering of block. |
79 | 82 | * |
80 | 83 | * @method |
— | — | @@ -90,6 +93,27 @@ |
91 | 94 | ); |
92 | 95 | }; |
93 | 96 | |
| 97 | +/** |
| 98 | + * Set the number labels of all ordered list items. |
| 99 | + * |
| 100 | + * @method |
| 101 | + */ |
| 102 | +es.ListBlockView.prototype.enumerate = function() { |
| 103 | + var itemLevel, |
| 104 | + levels = []; |
| 105 | + |
| 106 | + for ( var i = 0; i < this.items.length; i++ ) { |
| 107 | + itemLevel = this.items[i].model.getLevel(); |
| 108 | + levels = levels.slice(0, itemLevel + 1); |
| 109 | + if ( this.items[i].model.getStyle() === 'number' ) { |
| 110 | + if ( !levels[itemLevel] ) { |
| 111 | + levels[itemLevel] = 0; |
| 112 | + } |
| 113 | + this.items[i].setNumber( ++levels[itemLevel] ); |
| 114 | + } |
| 115 | + } |
| 116 | +}; |
| 117 | + |
94 | 118 | /* Inheritance */ |
95 | 119 | |
96 | 120 | es.extend( es.ListBlockView, es.ViewList ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.BlockView.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * Creates an es.BlockView object. |
4 | 4 | * |
5 | 5 | * @class |
6 | | - * @extends {es.DomContainerItem} |
| 6 | + * @extends {es.ViewListItem} |
7 | 7 | * @abstract |
8 | 8 | * @constructor |
9 | 9 | * @param typeName {String} Name of block type (optional, default: "block") |
— | — | @@ -14,6 +14,8 @@ |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Render content. |
| 18 | + * |
| 19 | + * @method |
18 | 20 | */ |
19 | 21 | es.BlockView.prototype.renderContent = function() { |
20 | 22 | throw 'BlockView.renderContent not implemented in this subclass.'; |
— | — | @@ -21,32 +23,57 @@ |
22 | 24 | |
23 | 25 | /** |
24 | 26 | * Gets offset within content of position. |
| 27 | + * |
| 28 | + * @method |
| 29 | + * @param position {es.Position} Position to get offset for |
| 30 | + * @returns {Integer} Offset nearest to position |
25 | 31 | */ |
26 | | -es.BlockView.getContentOffset = function( position ) { |
| 32 | +es.BlockView.prototype.getContentOffset = function( position ) { |
27 | 33 | throw 'BlockView.getContentOffset not implemented in this subclass.'; |
28 | 34 | }; |
29 | 35 | |
30 | 36 | /** |
31 | 37 | * Gets rendered position of offset within content. |
| 38 | + * |
| 39 | + * @method |
| 40 | + * @param offset {Integer} Offset to get position for |
| 41 | + * @returns {es.Position} Position of offset |
32 | 42 | */ |
33 | | -es.BlockView.getRenderedPosition = function( offset ) { |
| 43 | +es.BlockView.prototype.getRenderedPosition = function( offset ) { |
34 | 44 | throw 'BlockView.getRenderedPosition not implemented in this subclass.'; |
35 | 45 | }; |
36 | 46 | |
37 | 47 | /** |
38 | | - * Gets rendered line index of offset within content. |
| 48 | + * Draw selection around a given range. |
| 49 | + * |
| 50 | + * @method |
| 51 | + * @param range {es.Range} Range of content to draw selection around |
39 | 52 | */ |
40 | | -es.BlockView.getRenderedLineIndex = function( offset ) { |
41 | | - throw 'BlockView.getRenderedLineIndex not implemented in this subclass.'; |
| 53 | +es.BlockView.prototype.drawSelection = function( range ) { |
| 54 | + throw 'BlockView.drawSelection not implemented in this subclass.'; |
42 | 55 | }; |
43 | 56 | |
44 | 57 | /** |
45 | | - * Gets range of content in a rendered line which an offset is within. |
| 58 | + * Gets length of contents. |
| 59 | + * |
| 60 | + * @method |
| 61 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
46 | 62 | */ |
47 | | -es.BlockView.getRenderedLineRange = function( offset ) { |
48 | | - throw 'BlockView.getRenderedLineRange not implemented in this subclass.'; |
| 63 | +es.BlockView.prototype.getLength = function() { |
| 64 | + throw 'BlockView.getLength not implemented in this subclass.'; |
49 | 65 | }; |
50 | 66 | |
| 67 | +/** |
| 68 | + * Gets HTML rendering of block. |
| 69 | + * |
| 70 | + * @method |
| 71 | + * @param options {Object} List of options, see es.DocumentView.getHtml for details |
| 72 | + * @returns {String} HTML data |
| 73 | + */ |
| 74 | +es.BlockView.prototype.getHtml = function( options ) { |
| 75 | + throw 'BlockView.getHtml not implemented in this subclass.'; |
| 76 | +} |
| 77 | + |
51 | 78 | /* Inheritance */ |
52 | 79 | |
53 | 80 | es.extend( es.BlockView, es.ViewListItem ); |
Index: trunk/parsers/wikidom/lib/synth/views/es.ContentView.js |
— | — | @@ -196,6 +196,12 @@ |
197 | 197 | |
198 | 198 | /* Methods */ |
199 | 199 | |
| 200 | +/** |
| 201 | + * Draws selection around a given range of content. |
| 202 | + * |
| 203 | + * @method |
| 204 | + * @param range {es.Range} Range to draw selection around |
| 205 | + */ |
200 | 206 | es.ContentView.prototype.drawSelection = function( range ) { |
201 | 207 | range.normalize(); |
202 | 208 | |
— | — | @@ -242,6 +248,13 @@ |
243 | 249 | } |
244 | 250 | }; |
245 | 251 | |
| 252 | +/** |
| 253 | + * Gets the index of the rendered line a given offset is within. |
| 254 | + * |
| 255 | + * @method |
| 256 | + * @param offset {Integer} Offset to get line for |
| 257 | + * @returns {Integer} Index of rendered lin offset is within |
| 258 | + */ |
246 | 259 | es.ContentView.prototype.getLineIndex = function( offset ) { |
247 | 260 | for ( var i = 0; i < this.lines.length; i++ ) { |
248 | 261 | if ( this.lines[i].range.containsOffset( offset ) ) { |
— | — | @@ -256,10 +269,11 @@ |
257 | 270 | * |
258 | 271 | * Position is assumed to be local to the container the text is being flowed in. |
259 | 272 | * |
| 273 | + * @method |
260 | 274 | * @param position {Object} Position to find offset for |
261 | 275 | * @param position.left {Integer} Horizontal position in pixels |
262 | 276 | * @param position.top {Integer} Vertical position in pixels |
263 | | - * @return {Integer} Offset within content model nearest the given coordinates |
| 277 | + * @returns {Integer} Offset within content model nearest the given coordinates |
264 | 278 | */ |
265 | 279 | es.ContentView.prototype.getOffset = function( position ) { |
266 | 280 | // Empty content model shortcut |
— | — | @@ -325,11 +339,12 @@ |
326 | 340 | /** |
327 | 341 | * Gets position coordinates of a given offset. |
328 | 342 | * |
329 | | - * Offsets are boundaries between plain or annotated characters within content model. Results are given in |
330 | | - * left, top and bottom positions, which could be used to draw a cursor, highlighting, etc. |
| 343 | + * Offsets are boundaries between plain or annotated characters within content model. Results are |
| 344 | + * given in left, top and bottom positions, which could be used to draw a cursor, highlighting, etc. |
331 | 345 | * |
| 346 | + * @method |
332 | 347 | * @param offset {Integer} Offset within content model |
333 | | - * @return {Object} Object containing left, top and bottom properties, each positions in pixels as |
| 348 | + * @returns {Object} Object containing left, top and bottom properties, each positions in pixels as |
334 | 349 | * well as a line index |
335 | 350 | */ |
336 | 351 | es.ContentView.prototype.getPosition = function( offset ) { |
— | — | @@ -398,6 +413,8 @@ |
399 | 414 | |
400 | 415 | /** |
401 | 416 | * Updates the word boundary cache, which is used for word fitting. |
| 417 | + * |
| 418 | + * @method |
402 | 419 | */ |
403 | 420 | es.ContentView.prototype.scanBoundaries = function() { |
404 | 421 | /* |
— | — | @@ -439,6 +456,9 @@ |
440 | 457 | * In cases where a single word is too long to fit on a line, the word will be "virtually" wrapped, |
441 | 458 | * causing them to be fragmented. Word fragments are rendered on their own lines, except for their |
442 | 459 | * remainder, which is combined with whatever proceeding words can fit on the same line. |
| 460 | + * |
| 461 | + * @method |
| 462 | + * @param limit {Integer} Maximum number of iterations to render before yeilding |
443 | 463 | */ |
444 | 464 | es.ContentView.prototype.renderIteration = function( limit ) { |
445 | 465 | var rs = this.renderState, |
— | — | @@ -520,6 +540,7 @@ |
521 | 541 | * allowing rendering to be interrupted and restarted if changes to content model are happening before |
522 | 542 | * rendering of all lines is complete. |
523 | 543 | * |
| 544 | + * @method |
524 | 545 | * @param offset {Integer} Offset to re-render from, if possible (not yet implemented) |
525 | 546 | */ |
526 | 547 | es.ContentView.prototype.render = function( offset ) { |
— | — | @@ -591,6 +612,7 @@ |
592 | 613 | /** |
593 | 614 | * Adds a line containing a given range of text to the end of the DOM and the "lines" array. |
594 | 615 | * |
| 616 | + * @method |
595 | 617 | * @param range {es.Range} Range of data within content model to append |
596 | 618 | * @param start {Integer} Beginning of text range for line |
597 | 619 | * @param end {Integer} Ending of text range for line |
— | — | @@ -641,10 +663,11 @@ |
642 | 664 | * starting with [offset .. limit], which usually results in reducing the end position in all but |
643 | 665 | * the last line, and in most cases more than 3 times, before changing directions. |
644 | 666 | * |
| 667 | + * @method |
645 | 668 | * @param range {es.Range} Range of data within content model to try to fit |
646 | 669 | * @param ruler {HTMLElement} Element to take measurements with |
647 | 670 | * @param width {Integer} Maximum width to allow the line to extend to |
648 | | - * @return {Integer} Last index within "words" that contains a word that fits |
| 671 | + * @returns {Integer} Last index within "words" that contains a word that fits |
649 | 672 | */ |
650 | 673 | es.ContentView.prototype.fitWords = function( range, ruler, width ) { |
651 | 674 | var offset = range.start, |
— | — | @@ -696,10 +719,11 @@ |
697 | 720 | * used to detect when the first character was too long to fit on a line. In such cases the result |
698 | 721 | * will contain the index of the first character and it's width. |
699 | 722 | * |
| 723 | + * @method |
700 | 724 | * @param range {es.Range} Range of data within content model to try to fit |
701 | 725 | * @param ruler {HTMLElement} Element to take measurements with |
702 | 726 | * @param width {Integer} Maximum width to allow the line to extend to |
703 | | - * @return {Integer} Last index within "text" that contains a character that fits |
| 727 | + * @returns {Integer} Last index within "text" that contains a character that fits |
704 | 728 | */ |
705 | 729 | es.ContentView.prototype.fitCharacters = function( range, ruler, width ) { |
706 | 730 | var offset = range.start, |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | * Creates an es.TableBlockRowView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewList} |
| 7 | + * @extends {es.ViewListItem} |
6 | 8 | * @constructor |
7 | 9 | */ |
8 | 10 | es.TableBlockRowView = function( model ) { |
— | — | @@ -10,8 +12,12 @@ |
11 | 13 | this.$.attr( this.model.attributes ); |
12 | 14 | }; |
13 | 15 | |
| 16 | +/* Methods */ |
| 17 | + |
14 | 18 | /** |
15 | 19 | * Render content. |
| 20 | + * |
| 21 | + * @method |
16 | 22 | */ |
17 | 23 | es.TableBlockRowView.prototype.renderContent = function() { |
18 | 24 | for ( var i = 0; i < this.items.length; i++ ) { |
— | — | @@ -19,10 +25,34 @@ |
20 | 26 | } |
21 | 27 | }; |
22 | 28 | |
23 | | -es.TableBlockRowView.prototype.getLength = function() { |
24 | | - return this.items.getLengthOfItems(); |
| 29 | +/** |
| 30 | + * Gets offset within content of position. |
| 31 | + * |
| 32 | + * @method |
| 33 | + * @param position {es.Position} Position to get offset for |
| 34 | + * @returns {Integer} Offset nearest to position |
| 35 | + */ |
| 36 | +es.TableBlockRowView.prototype.getContentOffset = function( position ) { |
| 37 | + // TODO |
25 | 38 | }; |
26 | 39 | |
| 40 | +/** |
| 41 | + * Gets rendered position of offset within content. |
| 42 | + * |
| 43 | + * @method |
| 44 | + * @param offset {Integer} Offset to get position for |
| 45 | + * @returns {es.Position} Position of offset |
| 46 | + */ |
| 47 | +es.TableBlockRowView.prototype.getRenderedPosition = function( offset ) { |
| 48 | + // TODO |
| 49 | +}; |
| 50 | + |
| 51 | +/** |
| 52 | + * Draw selection around a given range. |
| 53 | + * |
| 54 | + * @method |
| 55 | + * @param range {es.Range} Range of content to draw selection around |
| 56 | + */ |
27 | 57 | es.TableBlockRowView.prototype.drawSelection = function( range ) { |
28 | 58 | var selectedViews = this.items.select( range ); |
29 | 59 | for ( var i = 0; i < selectedViews.length; i++ ) { |
— | — | @@ -33,9 +63,19 @@ |
34 | 64 | }; |
35 | 65 | |
36 | 66 | /** |
37 | | - * Gets HTML rendering of row. |
| 67 | + * Gets length of contents. |
38 | 68 | * |
39 | 69 | * @method |
| 70 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 71 | + */ |
| 72 | +es.TableBlockRowView.prototype.getLength = function() { |
| 73 | + return this.items.getLengthOfItems(); |
| 74 | +}; |
| 75 | + |
| 76 | +/** |
| 77 | + * Gets HTML rendering of block. |
| 78 | + * |
| 79 | + * @method |
40 | 80 | * @param options {Object} List of options, see es.DocumentView.getHtml for details |
41 | 81 | * @returns {String} HTML data |
42 | 82 | */ |
— | — | @@ -43,7 +83,7 @@ |
44 | 84 | return es.Html.makeTag( 'tr', this.model.attributes, $.map( this.items, function( view ) { |
45 | 85 | return view.getHtml(); |
46 | 86 | } ).join( '' ) ); |
47 | | -}; |
| 87 | +} |
48 | 88 | |
49 | 89 | /* Inheritance */ |
50 | 90 | |
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | * Creates an es.DocumentView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewList} |
6 | 7 | * @constructor |
7 | 8 | */ |
8 | 9 | es.DocumentView = function( documentModel ) { |
— | — | @@ -9,8 +10,12 @@ |
10 | 11 | this.$.addClass( 'editSurface-document' ) |
11 | 12 | }; |
12 | 13 | |
| 14 | +/* Methods */ |
| 15 | + |
13 | 16 | /** |
14 | 17 | * Render content. |
| 18 | + * |
| 19 | + * @method |
15 | 20 | */ |
16 | 21 | es.DocumentView.prototype.renderContent = function() { |
17 | 22 | for ( var i = 0; i < this.items.length; i++ ) { |
— | — | @@ -18,6 +23,34 @@ |
19 | 24 | } |
20 | 25 | }; |
21 | 26 | |
| 27 | +/** |
| 28 | + * Gets offset within content of position. |
| 29 | + * |
| 30 | + * @method |
| 31 | + * @param position {es.Position} Position to get offset for |
| 32 | + * @returns {Integer} Offset nearest to position |
| 33 | + */ |
| 34 | +es.DocumentView.prototype.getContentOffset = function( position ) { |
| 35 | + // TODO |
| 36 | +}; |
| 37 | + |
| 38 | +/** |
| 39 | + * Gets rendered position of offset within content. |
| 40 | + * |
| 41 | + * @method |
| 42 | + * @param offset {Integer} Offset to get position for |
| 43 | + * @returns {es.Position} Position of offset |
| 44 | + */ |
| 45 | +es.DocumentView.prototype.getRenderedPosition = function( offset ) { |
| 46 | + // TODO |
| 47 | +}; |
| 48 | + |
| 49 | +/** |
| 50 | + * Draw selection around a given range. |
| 51 | + * |
| 52 | + * @method |
| 53 | + * @param range {es.Range} Range of content to draw selection around |
| 54 | + */ |
22 | 55 | es.DocumentView.prototype.drawSelection = function( range ) { |
23 | 56 | var selectedViews = this.items.select( range ); |
24 | 57 | for ( var i = 0; i < selectedViews.length; i++ ) { |
— | — | @@ -27,7 +60,13 @@ |
28 | 61 | } |
29 | 62 | }; |
30 | 63 | |
31 | | -es.DocumentView.prototype.getLength = function( ) { |
| 64 | +/** |
| 65 | + * Gets length of contents. |
| 66 | + * |
| 67 | + * @method |
| 68 | + * @returns {Integer} Length of content, including virtual spaces between blocks |
| 69 | + */ |
| 70 | +es.DocumentView.prototype.getLength = function() { |
32 | 71 | return this.items.getLengthOfItems(); |
33 | 72 | }; |
34 | 73 | |
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | * Creates an es.ParagraphBlockView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.BlockView} |
6 | 7 | * @constructor |
7 | 8 | */ |
8 | 9 | es.ParagraphBlockView = function( model ) { |
— | — | @@ -16,8 +17,12 @@ |
17 | 18 | } ); |
18 | 19 | }; |
19 | 20 | |
| 21 | +/* Methods */ |
| 22 | + |
20 | 23 | /** |
21 | 24 | * Render content. |
| 25 | + * |
| 26 | + * @method |
22 | 27 | */ |
23 | 28 | es.ParagraphBlockView.prototype.renderContent = function() { |
24 | 29 | this.contentView.render(); |
— | — | @@ -25,33 +30,46 @@ |
26 | 31 | |
27 | 32 | /** |
28 | 33 | * Gets offset within content of position. |
| 34 | + * |
| 35 | + * @method |
| 36 | + * @param position {es.Position} Position to get offset for |
| 37 | + * @returns {Integer} Offset nearest to position |
29 | 38 | */ |
30 | | -es.ParagraphBlockView.getContentOffset = function( position ) { |
| 39 | +es.ParagraphBlockView.prototype.getContentOffset = function( position ) { |
31 | 40 | return this.contentView.getOffset( position ); |
32 | 41 | }; |
33 | 42 | |
34 | 43 | /** |
35 | 44 | * Gets rendered position of offset within content. |
| 45 | + * |
| 46 | + * @method |
| 47 | + * @param offset {Integer} Offset to get position for |
| 48 | + * @returns {es.Position} Position of offset |
36 | 49 | */ |
37 | | -es.ParagraphBlockView.getRenderedPosition = function( offset ) { |
| 50 | +es.ParagraphBlockView.prototype.getRenderedPosition = function( offset ) { |
38 | 51 | return this.contentView.getPosition( position ); |
39 | 52 | }; |
40 | 53 | |
41 | 54 | /** |
42 | | - * Gets rendered line index of offset within content. |
| 55 | + * Draw selection around a given range. |
| 56 | + * |
| 57 | + * @method |
| 58 | + * @param range {es.Range} Range of content to draw selection around |
43 | 59 | */ |
44 | | -es.ParagraphBlockView.getRenderedLineIndex = function( offset ) { |
45 | | - return this.contentView.getLineIndex( position ); |
| 60 | +es.ParagraphBlockView.prototype.drawSelection = function( range ) { |
| 61 | + this.contentView.drawSelection( range ); |
46 | 62 | }; |
47 | 63 | |
| 64 | +/** |
| 65 | + * Gets length of contents. |
| 66 | + * |
| 67 | + * @method |
| 68 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 69 | + */ |
48 | 70 | es.ParagraphBlockView.prototype.getLength = function() { |
49 | 71 | return this.model.getContentLength(); |
50 | 72 | }; |
51 | 73 | |
52 | | -es.ParagraphBlockView.prototype.drawSelection = function( range ) { |
53 | | - this.contentView.drawSelection( range ); |
54 | | -}; |
55 | | - |
56 | 74 | /** |
57 | 75 | * Gets HTML rendering of block. |
58 | 76 | * |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | * Creates an es.TableBlockCellView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewListItem} |
6 | 7 | * @constructor |
7 | 8 | */ |
8 | 9 | es.TableBlockCellView = function( model ) { |
— | — | @@ -11,31 +12,69 @@ |
12 | 13 | this.$.attr( this.model.attributes ); |
13 | 14 | }; |
14 | 15 | |
| 16 | +/* Methods */ |
| 17 | + |
15 | 18 | /** |
16 | 19 | * Render content. |
| 20 | + * |
| 21 | + * @method |
17 | 22 | */ |
18 | 23 | es.TableBlockCellView.prototype.renderContent = function() { |
19 | 24 | this.documentView.renderContent(); |
20 | 25 | }; |
21 | 26 | |
22 | | -es.TableBlockCellView.prototype.getLength = function() { |
23 | | - return this.documentView.getLength(); |
| 27 | +/** |
| 28 | + * Gets offset within content of position. |
| 29 | + * |
| 30 | + * @method |
| 31 | + * @param position {es.Position} Position to get offset for |
| 32 | + * @returns {Integer} Offset nearest to position |
| 33 | + */ |
| 34 | +es.TableBlockCellView.prototype.getContentOffset = function( position ) { |
| 35 | + // TODO |
24 | 36 | }; |
25 | 37 | |
| 38 | +/** |
| 39 | + * Gets rendered position of offset within content. |
| 40 | + * |
| 41 | + * @method |
| 42 | + * @param offset {Integer} Offset to get position for |
| 43 | + * @returns {es.Position} Position of offset |
| 44 | + */ |
| 45 | +es.TableBlockCellView.prototype.getRenderedPosition = function( offset ) { |
| 46 | + // TODO |
| 47 | +}; |
| 48 | + |
| 49 | +/** |
| 50 | + * Draw selection around a given range. |
| 51 | + * |
| 52 | + * @method |
| 53 | + * @param range {es.Range} Range of content to draw selection around |
| 54 | + */ |
26 | 55 | es.TableBlockCellView.prototype.drawSelection = function( range ) { |
27 | 56 | this.documentView.drawSelection( range ); |
28 | 57 | }; |
29 | 58 | |
30 | 59 | /** |
31 | | - * Gets HTML rendering of cell. |
| 60 | + * Gets length of contents. |
32 | 61 | * |
33 | 62 | * @method |
| 63 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 64 | + */ |
| 65 | +es.TableBlockCellView.prototype.getLength = function() { |
| 66 | + return this.documentView.getLength(); |
| 67 | +}; |
| 68 | + |
| 69 | +/** |
| 70 | + * Gets HTML rendering of block. |
| 71 | + * |
| 72 | + * @method |
34 | 73 | * @param options {Object} List of options, see es.DocumentView.getHtml for details |
35 | 74 | * @returns {String} HTML data |
36 | 75 | */ |
37 | 76 | es.TableBlockCellView.prototype.getHtml = function( options ) { |
38 | 77 | return es.Html.makeTag( 'td', this.model.attributes, this.documentView.getHtml() ); |
39 | | -}; |
| 78 | +} |
40 | 79 | |
41 | 80 | /* Inheritance */ |
42 | 81 | |
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | * Creates an es.TableBlockView object. |
4 | 4 | * |
5 | 5 | * @class |
| 6 | + * @extends {es.ViewList} |
| 7 | + * @extends {es.BlockView} |
6 | 8 | * @constructor |
7 | 9 | */ |
8 | 10 | es.TableBlockView = function( model ) { |
— | — | @@ -11,8 +13,12 @@ |
12 | 14 | this.$.addClass( 'editSurface-tableBlock' ); |
13 | 15 | }; |
14 | 16 | |
| 17 | +/* Methods */ |
| 18 | + |
15 | 19 | /** |
16 | 20 | * Render content. |
| 21 | + * |
| 22 | + * @method |
17 | 23 | */ |
18 | 24 | es.TableBlockView.prototype.renderContent = function() { |
19 | 25 | for ( var i = 0; i < this.items.length; i++ ) { |
— | — | @@ -20,10 +26,34 @@ |
21 | 27 | } |
22 | 28 | }; |
23 | 29 | |
24 | | -es.TableBlockView.prototype.getLength = function() { |
25 | | - return this.items.getLengthOfItems(); |
| 30 | +/** |
| 31 | + * Gets offset within content of position. |
| 32 | + * |
| 33 | + * @method |
| 34 | + * @param position {es.Position} Position to get offset for |
| 35 | + * @returns {Integer} Offset nearest to position |
| 36 | + */ |
| 37 | +es.TableBlockView.prototype.getContentOffset = function( position ) { |
| 38 | + // TODO |
26 | 39 | }; |
27 | 40 | |
| 41 | +/** |
| 42 | + * Gets rendered position of offset within content. |
| 43 | + * |
| 44 | + * @method |
| 45 | + * @param offset {Integer} Offset to get position for |
| 46 | + * @returns {es.Position} Position of offset |
| 47 | + */ |
| 48 | +es.TableBlockView.prototype.getRenderedPosition = function( offset ) { |
| 49 | + // TODO |
| 50 | +}; |
| 51 | + |
| 52 | +/** |
| 53 | + * Draw selection around a given range. |
| 54 | + * |
| 55 | + * @method |
| 56 | + * @param range {es.Range} Range of content to draw selection around |
| 57 | + */ |
28 | 58 | es.TableBlockView.prototype.drawSelection = function( range ) { |
29 | 59 | var selectedViews = this.items.select( range ); |
30 | 60 | for ( var i = 0; i < selectedViews.length; i++ ) { |
— | — | @@ -34,6 +64,16 @@ |
35 | 65 | }; |
36 | 66 | |
37 | 67 | /** |
| 68 | + * Gets length of contents. |
| 69 | + * |
| 70 | + * @method |
| 71 | + * @returns {Integer} Length of content, including any virtual spaces within the block |
| 72 | + */ |
| 73 | +es.TableBlockView.prototype.getLength = function() { |
| 74 | + return this.items.getLengthOfItems(); |
| 75 | +}; |
| 76 | + |
| 77 | +/** |
38 | 78 | * Gets HTML rendering of block. |
39 | 79 | * |
40 | 80 | * @method |
— | — | @@ -44,7 +84,7 @@ |
45 | 85 | return es.Html.makeTag( 'table', this.model.attributes, $.map( this.items, function( view ) { |
46 | 86 | return view.getHtml(); |
47 | 87 | } ).join( '' ) ); |
48 | | -}; |
| 88 | +} |
49 | 89 | |
50 | 90 | /* Inheritance */ |
51 | 91 | |