Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | // Inheritance |
15 | 15 | es.DocumentModelNode.call( this, length ); |
16 | 16 | |
| 17 | + this.rebuildChildNodes(); |
| 18 | + |
17 | 19 | // Properties |
18 | 20 | this.data = $.isArray( data ) ? data : []; |
19 | 21 | this.attributes = $.isPlainObject( attributes ) ? attributes : {}; |
— | — | @@ -28,31 +30,6 @@ |
29 | 31 | /* Static Methods */ |
30 | 32 | |
31 | 33 | /** |
32 | | - * Checks if a data at a given offset is content. |
33 | | - * |
34 | | - * @static |
35 | | - * @method |
36 | | - * @param {Integer} offset Offset in data to check |
37 | | - * @returns {Boolean} If data at offset is content |
38 | | - */ |
39 | | -es.DocumentModel.isContent = function( offset ) { |
40 | | - return typeof this.data[offset] === 'string' || $.isArray( this.data[offset] ); |
41 | | -}; |
42 | | - |
43 | | -/** |
44 | | - * Checks if a data at a given offset is an element. |
45 | | - * |
46 | | - * @static |
47 | | - * @method |
48 | | - * @param {Integer} offset Offset in data to check |
49 | | - * @returns {Boolean} If data at offset is an element |
50 | | - */ |
51 | | -es.DocumentModel.isElement = function( offset ) { |
52 | | - // TODO: Is there a safer way to check if it's a plain object without sacrificing speed? |
53 | | - return this.data[offset].type !== undefined; |
54 | | -}; |
55 | | - |
56 | | -/** |
57 | 34 | * Creates a document model from a plain object. |
58 | 35 | * |
59 | 36 | * @static |
— | — | @@ -175,6 +152,56 @@ |
176 | 153 | /* Methods */ |
177 | 154 | |
178 | 155 | /** |
| 156 | + * Checks if a data at a given offset is content. |
| 157 | + * |
| 158 | + * @static |
| 159 | + * @method |
| 160 | + * @param {Integer} offset Offset in data to check |
| 161 | + * @returns {Boolean} If data at offset is content |
| 162 | + */ |
| 163 | +es.DocumentModel.prototype.isContent = function( offset ) { |
| 164 | + return typeof this.data[offset] === 'string' || $.isArray( this.data[offset] ); |
| 165 | +}; |
| 166 | + |
| 167 | +/** |
| 168 | + * Checks if a data at a given offset is an element. |
| 169 | + * |
| 170 | + * @static |
| 171 | + * @method |
| 172 | + * @param {Integer} offset Offset in data to check |
| 173 | + * @returns {Boolean} If data at offset is an element |
| 174 | + */ |
| 175 | +es.DocumentModel.prototype.isElement = function( offset ) { |
| 176 | + // TODO: Is there a safer way to check if it's a plain object without sacrificing speed? |
| 177 | + return this.data[offset].type !== undefined; |
| 178 | +}; |
| 179 | + |
| 180 | +/** |
| 181 | + * Creates a document view for this model. |
| 182 | + * |
| 183 | + * @returns {es.DocumentView} |
| 184 | + */ |
| 185 | +es.DocumentModel.prototype.createView = function() { |
| 186 | + // return new es.DocumentView( this ); |
| 187 | +}; |
| 188 | + |
| 189 | +/** |
| 190 | + * Regenerates child nodes from content data. |
| 191 | + */ |
| 192 | +es.DocumentModel.prototype.rebuildChildNodes = function() { |
| 193 | + // Remove child nodes |
| 194 | + this.splice( 0, this.length ); |
| 195 | + // Build a tree of models, which is a space partitioning data structure |
| 196 | + for ( var i = 0; i < this.data.length; i++ ) { |
| 197 | + if ( this.data[i].type !== undefined ) { |
| 198 | + // It's an element |
| 199 | + } else { |
| 200 | + // It's content |
| 201 | + } |
| 202 | + } |
| 203 | +}; |
| 204 | + |
| 205 | +/** |
179 | 206 | * Gets copy of the document data. |
180 | 207 | * |
181 | 208 | * @method |
Index: trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js |
— | — | @@ -9,6 +9,17 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/* Methods */ |
| 14 | + |
| 15 | +/** |
| 16 | + * Creates a table row view for this model. |
| 17 | + * |
| 18 | + * @returns {es.TableRowView} |
| 19 | + */ |
| 20 | +es.TableRowModel.prototype.createView = function() { |
| 21 | + // return new es.TableRowView( this ); |
| 22 | +}; |
| 23 | + |
13 | 24 | /* Registration */ |
14 | 25 | |
15 | 26 | es.DocumentModel.nodeModels.tableRow = es.TableRowModel; |
Index: trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js |
— | — | @@ -9,6 +9,15 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/** |
| 14 | + * Creates a paragraph view for this model. |
| 15 | + * |
| 16 | + * @returns {es.ParagraphView} |
| 17 | + */ |
| 18 | +es.ParagraphModel.prototype.createView = function() { |
| 19 | + // return new es.ParagraphView( this ); |
| 20 | +}; |
| 21 | + |
13 | 22 | /* Registration */ |
14 | 23 | |
15 | 24 | es.DocumentModel.nodeModels.paragraph = es.ParagraphModel; |
Index: trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js |
— | — | @@ -9,6 +9,15 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/** |
| 14 | + * Creates a table cell view for this model. |
| 15 | + * |
| 16 | + * @returns {es.TableCellView} |
| 17 | + */ |
| 18 | +es.TableCellModel.prototype.createView = function() { |
| 19 | + // return new es.TableCellView( this ); |
| 20 | +}; |
| 21 | + |
13 | 22 | /* Registration */ |
14 | 23 | |
15 | 24 | es.DocumentModel.nodeModels.tableCell = es.TableCellModel; |
Index: trunk/parsers/wikidom/lib/hype/models/es.TableModel.js |
— | — | @@ -9,6 +9,15 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/** |
| 14 | + * Creates a table view for this model. |
| 15 | + * |
| 16 | + * @returns {es.TableView} |
| 17 | + */ |
| 18 | +es.TableModel.prototype.createView = function() { |
| 19 | + // return new es.TableView( this ); |
| 20 | +}; |
| 21 | + |
13 | 22 | /* Registration */ |
14 | 23 | |
15 | 24 | es.DocumentModel.nodeModels.table = es.TableModel; |
Index: trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js |
— | — | @@ -9,6 +9,15 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/** |
| 14 | + * Creates a list item view for this model. |
| 15 | + * |
| 16 | + * @returns {es.ListItemView} |
| 17 | + */ |
| 18 | +es.ListItemModel.prototype.createView = function() { |
| 19 | + // return new es.ListItemView( this ); |
| 20 | +}; |
| 21 | + |
13 | 22 | /* Registration */ |
14 | 23 | |
15 | 24 | es.DocumentModel.nodeModels.listItem = es.ListItemModel; |
Index: trunk/parsers/wikidom/lib/hype/models/es.ListModel.js |
— | — | @@ -9,6 +9,15 @@ |
10 | 10 | es.DocumentModelNode.call( this, length ); |
11 | 11 | }; |
12 | 12 | |
| 13 | +/** |
| 14 | + * Creates a list view for this model. |
| 15 | + * |
| 16 | + * @returns {es.ListView} |
| 17 | + */ |
| 18 | +es.ListModel.prototype.createView = function() { |
| 19 | + // return new es.ListView( this ); |
| 20 | +}; |
| 21 | + |
13 | 22 | /* Registration */ |
14 | 23 | |
15 | 24 | es.DocumentModel.nodeModels.list = es.listModel; |