http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98790

Revision: 98790
Author:   tparscal
Date:     2011-10-03 18:20:54 +0000 (Mon, 03 Oct 2011)
Log Message:
-----------
Added some outlines for supporting view creation

Modified Paths:
--------------
    trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
    trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js
    trunk/parsers/wikidom/lib/hype/models/es.ListModel.js
    trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js
    trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js
    trunk/parsers/wikidom/lib/hype/models/es.TableModel.js
    trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js

Modified: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-03 
18:20:54 UTC (rev 98790)
@@ -13,6 +13,8 @@
        // Inheritance
        es.DocumentModelNode.call( this, length );
        
+       this.rebuildChildNodes();
+       
        // Properties
        this.data = $.isArray( data ) ? data : [];
        this.attributes = $.isPlainObject( attributes ) ? attributes : {};
@@ -28,31 +30,6 @@
 /* Static Methods */
 
 /**
- * Checks if a data at a given offset is content.
- * 
- * @static
- * @method
- * @param {Integer} offset Offset in data to check
- * @returns {Boolean} If data at offset is content
- */
-es.DocumentModel.isContent = function( offset ) {
-       return typeof this.data[offset] === 'string' || $.isArray( 
this.data[offset] );
-};
-
-/**
- * Checks if a data at a given offset is an element.
- * 
- * @static
- * @method
- * @param {Integer} offset Offset in data to check
- * @returns {Boolean} If data at offset is an element
- */
-es.DocumentModel.isElement = function( offset ) {
-       // TODO: Is there a safer way to check if it's a plain object without 
sacrificing speed?
-       return this.data[offset].type !== undefined;
-};
-
-/**
  * Creates a document model from a plain object.
  * 
  * @static
@@ -175,6 +152,56 @@
 /* Methods */
 
 /**
+ * Checks if a data at a given offset is content.
+ * 
+ * @static
+ * @method
+ * @param {Integer} offset Offset in data to check
+ * @returns {Boolean} If data at offset is content
+ */
+es.DocumentModel.prototype.isContent = function( offset ) {
+       return typeof this.data[offset] === 'string' || $.isArray( 
this.data[offset] );
+};
+
+/**
+ * Checks if a data at a given offset is an element.
+ * 
+ * @static
+ * @method
+ * @param {Integer} offset Offset in data to check
+ * @returns {Boolean} If data at offset is an element
+ */
+es.DocumentModel.prototype.isElement = function( offset ) {
+       // TODO: Is there a safer way to check if it's a plain object without 
sacrificing speed?
+       return this.data[offset].type !== undefined;
+};
+
+/**
+ * Creates a document view for this model.
+ * 
+ * @returns {es.DocumentView}
+ */
+es.DocumentModel.prototype.createView = function() {
+       // return new es.DocumentView( this );
+};
+
+/**
+ * Regenerates child nodes from content data.
+ */
+es.DocumentModel.prototype.rebuildChildNodes = function() {
+       // Remove child nodes
+       this.splice( 0, this.length );
+       // Build a tree of models, which is a space partitioning data structure
+       for ( var i = 0; i < this.data.length; i++ ) {
+               if ( this.data[i].type !== undefined ) {
+                       // It's an element
+               } else {
+                       // It's content
+               }
+       }
+};
+
+/**
  * Gets copy of the document data.
  * 
  * @method

Modified: trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js   2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.ListItemModel.js   2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,15 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/**
+ * Creates a list item view for this model.
+ * 
+ * @returns {es.ListItemView}
+ */
+es.ListItemModel.prototype.createView = function() {
+       // return new es.ListItemView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.listItem = es.ListItemModel;

Modified: trunk/parsers/wikidom/lib/hype/models/es.ListModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.ListModel.js       2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.ListModel.js       2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,15 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/**
+ * Creates a list view for this model.
+ * 
+ * @returns {es.ListView}
+ */
+es.ListModel.prototype.createView = function() {
+       // return new es.ListView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.list = es.listModel;

Modified: trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js  2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.ParagraphModel.js  2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,15 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/**
+ * Creates a paragraph view for this model.
+ * 
+ * @returns {es.ParagraphView}
+ */
+es.ParagraphModel.prototype.createView = function() {
+       // return new es.ParagraphView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.paragraph = es.ParagraphModel;

Modified: trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js  2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.TableCellModel.js  2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,15 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/**
+ * Creates a table cell view for this model.
+ * 
+ * @returns {es.TableCellView}
+ */
+es.TableCellModel.prototype.createView = function() {
+       // return new es.TableCellView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.tableCell = es.TableCellModel;

Modified: trunk/parsers/wikidom/lib/hype/models/es.TableModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.TableModel.js      2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.TableModel.js      2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,15 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/**
+ * Creates a table view for this model.
+ * 
+ * @returns {es.TableView}
+ */
+es.TableModel.prototype.createView = function() {
+       // return new es.TableView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.table = es.TableModel;

Modified: trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js   2011-10-03 
18:18:47 UTC (rev 98789)
+++ trunk/parsers/wikidom/lib/hype/models/es.TableRowModel.js   2011-10-03 
18:20:54 UTC (rev 98790)
@@ -9,6 +9,17 @@
        es.DocumentModelNode.call( this, length );
 };
 
+/* Methods */
+
+/**
+ * Creates a table row view for this model.
+ * 
+ * @returns {es.TableRowView}
+ */
+es.TableRowModel.prototype.createView = function() {
+       // return new es.TableRowView( this );
+};
+
 /* Registration */
 
 es.DocumentModel.nodeModels.tableRow = es.TableRowModel;


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to