r98790 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98789‎ | r98790 | r98791 >
Date:18:20, 3 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added some outlines for supporting view creation
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.ListModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.TableModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -13,6 +13,8 @@
1414 // Inheritance
1515 es.DocumentModelNode.call( this, length );
1616
 17+ this.rebuildChildNodes();
 18+
1719 // Properties
1820 this.data = $.isArray( data ) ? data : [];
1921 this.attributes = $.isPlainObject( attributes ) ? attributes : {};
@@ -28,31 +30,6 @@
2931 /* Static Methods */
3032
3133 /**
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 -/**
5734 * Creates a document model from a plain object.
5835 *
5936 * @static
@@ -175,6 +152,56 @@
176153 /* Methods */
177154
178155 /**
 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+/**
179206 * Gets copy of the document data.
180207 *
181208 * @method
Index: trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js
@@ -9,6 +9,17 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1324 /* Registration */
1425
1526 es.DocumentModel.nodeModels.tableRow = es.TableRowModel;
Index: trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js
@@ -9,6 +9,15 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1322 /* Registration */
1423
1524 es.DocumentModel.nodeModels.paragraph = es.ParagraphModel;
Index: trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js
@@ -9,6 +9,15 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1322 /* Registration */
1423
1524 es.DocumentModel.nodeModels.tableCell = es.TableCellModel;
Index: trunk/parsers/wikidom/lib/hype/models/es.TableModel.js
@@ -9,6 +9,15 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1322 /* Registration */
1423
1524 es.DocumentModel.nodeModels.table = es.TableModel;
Index: trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js
@@ -9,6 +9,15 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1322 /* Registration */
1423
1524 es.DocumentModel.nodeModels.listItem = es.ListItemModel;
Index: trunk/parsers/wikidom/lib/hype/models/es.ListModel.js
@@ -9,6 +9,15 @@
1010 es.DocumentModelNode.call( this, length );
1111 };
1212
 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+
1322 /* Registration */
1423
1524 es.DocumentModel.nodeModels.list = es.listModel;

Status & tagging log