r96519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96518‎ | r96519 | r96520 >
Date:23:26, 7 September 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added support for table cells to have attributes by nesting the document in another object.
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockCellModel.js (added) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js (added) (history)

Diff [purge]

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 @@
2626 */
2727 es.TableBlockModel.newFromPlainObject = function( obj ) {
2828 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
3030 !$.isArray( obj.rows ) ? [] : $.map( obj.rows, function( row ) {
3131 return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row )
3232 } ),
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js
@@ -3,10 +3,10 @@
44 *
55 * @class
66 * @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}
1111 */
1212 es.TableBlockRowModel = function( cells, attributes ) {
1313 this.cells = new es.ContentSeries( cells || [] );
@@ -14,7 +14,7 @@
1515 };
1616
1717 /**
18 - * Creates an TableBlockModel object from a plain object.
 18+ * Creates an TableBlockRowModel object from a plain object.
1919 *
2020 * @method
2121 * @static
@@ -22,9 +22,10 @@
2323 */
2424 es.TableBlockRowModel.newFromPlainObject = function( obj ) {
2525 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
2727 !$.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 )
2930 } ),
3031 // Attributes - if given, make a deep copy of attributes
3132 !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes )
@@ -44,7 +45,7 @@
4546 };
4647
4748 /**
48 - * Gets a plain list block item object.
 49+ * Gets a plain table row object.
4950 *
5051 * @method
5152 * @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 );

Status & tagging log