Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockCellModel.js |
— | — | @@ -0,0 +1,59 @@ |
| 2 | +/** |
| 3 | + * Creates an es.TableBlockRowModel object. |
| 4 | + * |
| 5 | + * @class |
| 6 | + * @constructor |
| 7 | + * @param doc {es.DocumentModel} |
| 8 | + * @param attributes {Object} |
| 9 | + * @property document {es.DocumentModel} |
| 10 | + * @property attributes {Object} |
| 11 | + */ |
| 12 | +es.TableBlockCellModel = function( doc, attributes ) { |
| 13 | + this.document = doc || null; |
| 14 | + this.attributes = attributes || {}; |
| 15 | +}; |
| 16 | + |
| 17 | +/** |
| 18 | + * Creates an TableBlockCellModel object from a plain object. |
| 19 | + * |
| 20 | + * @method |
| 21 | + * @static |
| 22 | + * @param obj {Object} |
| 23 | + */ |
| 24 | +es.TableBlockCellModel.newFromPlainObject = function( obj ) { |
| 25 | + return new es.TableBlockRowModel( |
| 26 | + // Cells - if given, convert plain document object to es.DocumentModel objects |
| 27 | + !$.isArray( obj.document ) ? null : es.DocumentModel.newFromPlainObject( obj.document ), |
| 28 | + // Attributes - if given, make a deep copy of attributes |
| 29 | + !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes ) |
| 30 | + ); |
| 31 | +}; |
| 32 | + |
| 33 | +/* Methods */ |
| 34 | + |
| 35 | +/** |
| 36 | + * Gets the length of all content. |
| 37 | + * |
| 38 | + * @method |
| 39 | + * @returns {Integer} Length of all content |
| 40 | + */ |
| 41 | +es.TableBlockRowModel.prototype.getContentLength = function() { |
| 42 | + return this.cells.getContentLength(); |
| 43 | +}; |
| 44 | + |
| 45 | +/** |
| 46 | + * Gets a plain table cell object. |
| 47 | + * |
| 48 | + * @method |
| 49 | + * @returns obj {Object} |
| 50 | + */ |
| 51 | +es.TableBlockRowModel.prototype.getPlainObject = function() { |
| 52 | + var obj = {}; |
| 53 | + if ( this.document ) { |
| 54 | + obj.document = this.document; |
| 55 | + } |
| 56 | + if ( !$.isEmptyObject( this.attributes ) ) { |
| 57 | + obj.attributes = $.extend( true, {}, this.attributes ); |
| 58 | + } |
| 59 | + return obj; |
| 60 | +}; |
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | */ |
27 | 27 | es.TableBlockModel.newFromPlainObject = function( obj ) { |
28 | 28 | return new es.TableBlockModel( |
29 | | - // Cells - if given, convert plain "item" objects to es.ListModelItem objects |
| 29 | + // Cells - if given, convert plain row objects to es.TableBlockRowModel objects |
30 | 30 | !$.isArray( obj.rows ) ? [] : $.map( obj.rows, function( row ) { |
31 | 31 | return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row ) |
32 | 32 | } ), |
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js |
— | — | @@ -3,10 +3,10 @@ |
4 | 4 | * |
5 | 5 | * @class |
6 | 6 | * @constructor |
7 | | - * @param content {es.ContentModel} |
8 | | - * @param styles {Array} |
9 | | - * @property content {es.ContentModel} |
10 | | - * @property styles {Array} |
| 7 | + * @param cells {Array} |
| 8 | + * @param attributes {Object} |
| 9 | + * @property cells {Array} |
| 10 | + * @property attributes {Object} |
11 | 11 | */ |
12 | 12 | es.TableBlockRowModel = function( cells, attributes ) { |
13 | 13 | this.cells = new es.ContentSeries( cells || [] ); |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | }; |
16 | 16 | |
17 | 17 | /** |
18 | | - * Creates an TableBlockModel object from a plain object. |
| 18 | + * Creates an TableBlockRowModel object from a plain object. |
19 | 19 | * |
20 | 20 | * @method |
21 | 21 | * @static |
— | — | @@ -22,9 +22,10 @@ |
23 | 23 | */ |
24 | 24 | es.TableBlockRowModel.newFromPlainObject = function( obj ) { |
25 | 25 | return new es.TableBlockRowModel( |
26 | | - // Cells - if given, convert plain "item" objects to es.ListModelItem objects |
| 26 | + // Cells - if given, convert plain cell objects to es.TableBlockCellModel objects |
27 | 27 | !$.isArray( obj.cells ) ? [] : $.map( obj.cells, function( cell ) { |
28 | | - return !$.isPlainObject( cell ) ? null : es.DocumentModel.newFromPlainObject( cell ) |
| 28 | + return !$.isPlainObject( cell ) ? null |
| 29 | + : es.TableBlockCellModel.newFromPlainObject( cell ) |
29 | 30 | } ), |
30 | 31 | // Attributes - if given, make a deep copy of attributes |
31 | 32 | !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes ) |
— | — | @@ -44,7 +45,7 @@ |
45 | 46 | }; |
46 | 47 | |
47 | 48 | /** |
48 | | - * Gets a plain list block item object. |
| 49 | + * Gets a plain table row object. |
49 | 50 | * |
50 | 51 | * @method |
51 | 52 | * @returns obj {Object} |
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js |
— | — | @@ -0,0 +1,9 @@ |
| 2 | +/** |
| 3 | + * |
| 4 | + */ |
| 5 | +es.ParagraphBlockView = function( model ) { |
| 6 | + es.BlockView.call( this, 'paragraph' ); |
| 7 | + this.model = model; |
| 8 | +}; |
| 9 | + |
| 10 | +es.extend( es.ParagraphBlockView, es.BlockView ); |