r99400 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99399‎ | r99400 | r99401 >
Date:14:29, 10 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Make synth demo understand new wikidom structure
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.HeadingBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockCellModel.js (modified) (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.HeadingBlockView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/models/es.DocumentModel.js
@@ -26,12 +26,10 @@
2727 es.DocumentModel.newFromPlainObject = function( obj ) {
2828 var types = es.BlockModel.constructors;
2929 return new es.DocumentModel(
30 - // Blocks - if given, convert all plain "block" objects to es.WikiDom* objects
31 - !$.isArray( obj.blocks ) ? [] : $.map( obj.blocks, function( block ) {
32 - return es.BlockModel.newFromPlainObject( block );
33 - } ),
34 - // Attributes - if given, make a deep copy of attributes
35 - !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes )
 30+ // children - if given, convert all plain "child" objects to es.WikiDom* objects
 31+ !$.isArray( obj.children ) ? [] : $.map( obj.children, function( child ) {
 32+ return es.BlockModel.newFromPlainObject( child );
 33+ } )
3634 );
3735 };
3836
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockCellModel.js
@@ -29,7 +29,7 @@
3030 es.TableBlockCellModel.newFromPlainObject = function( obj ) {
3131 return new es.TableBlockCellModel(
3232 // Blocks - if given, convert all plain "block" objects to es.WikiDom* objects
33 - !$.isArray( obj.blocks ) ? [] : $.map( obj.blocks, function( block ) {
 33+ !$.isArray( obj.children ) ? [] : $.map( obj.children, function( block ) {
3434 return es.BlockModel.newFromPlainObject( block );
3535 } ),
3636 // Attributes - if given, make a deep copy of attributes
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js
@@ -33,7 +33,7 @@
3434 es.TableBlockModel.newFromPlainObject = function( obj ) {
3535 return new es.TableBlockModel(
3636 // Cells - if given, convert plain row objects to es.TableBlockRowModel objects
37 - !$.isArray( obj.rows ) ? [] : $.map( obj.rows, function( row ) {
 37+ !$.isArray( obj.children ) ? [] : $.map( obj.children, function( row ) {
3838 return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row )
3939 } ),
4040 // Attributes - if given, make a deep copy of attributes
Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js
@@ -36,10 +36,10 @@
3737 if ( !$.isArray( styles ) ) {
3838 styles = [];
3939 }
40 - styles.push( obj.style || 'bullet' );
 40+ styles.push( obj.attributes.style || 'bullet' );
4141 var items = [];
42 - if ( $.isArray( obj.items ) ) {
43 - $.each( obj.items, function( i, item ) {
 42+ if ( $.isArray( obj.children ) ) {
 43+ $.each( obj.children, function( i, item ) {
4444 if ( $.isPlainObject( item.content ) ) {
4545 items.push(
4646 new es.ListBlockItemModel(
@@ -48,8 +48,8 @@
4949 )
5050 );
5151 }
52 - if ( $.isArray( item.lists ) ) {
53 - $.each( item.lists, function( i, list ) {
 52+ if ( $.isArray( item.children ) ) {
 53+ $.each( item.children, function( i, list ) {
5454 items = items.concat( es.ListBlockModel.flattenPlainObject( list, styles ) );
5555 } );
5656 }
@@ -70,7 +70,7 @@
7171 return new es.ListBlockModel(
7272 // Items - if given, convert plain "list" object from a tree structure to a flat array of
7373 // es.ListBlockItemModel objects
74 - !$.isArray( obj.items ) ? [] : es.ListBlockModel.flattenPlainObject( obj )
 74+ !$.isArray( obj.children ) ? [] : es.ListBlockModel.flattenPlainObject( obj )
7575 );
7676 };
7777
Index: trunk/parsers/wikidom/lib/synth/models/es.HeadingBlockModel.js
@@ -8,10 +8,10 @@
99 * @property content {es.ContentModel}
1010 * @property level {Integer}
1111 */
12 -es.HeadingBlockModel = function( content, level ) {
 12+es.HeadingBlockModel = function( content, attributes ) {
1313 es.BlockModel.call( this, ['hasContent', 'isAnnotatable'] );
1414 this.content = content || new es.ContentModel();
15 - this.level = level || 0;
 15+ this.attributes = attributes || {};
1616 var model = this;
1717 this.content.on( 'change', function() {
1818 model.emit( 'update' );
@@ -28,7 +28,7 @@
2929 * @param obj {Object}
3030 */
3131 es.HeadingBlockModel.newFromPlainObject = function( obj ) {
32 - return new es.HeadingBlockModel( es.ContentModel.newFromPlainObject( obj.content ), obj.level );
 32+ return new es.HeadingBlockModel( es.ContentModel.newFromPlainObject( obj.content ), obj.attributes );
3333 };
3434
3535 /* Methods */
@@ -57,7 +57,7 @@
5858 * @returns obj {Object}
5959 */
6060 es.HeadingBlockModel.prototype.getPlainObject = function() {
61 - return { 'type': 'heading', 'content': this.content.getPlainObject(), 'level': this.level };
 61+ return { 'type': 'heading', 'content': this.content.getPlainObject(), 'attributes': this.attributes };
6262 };
6363
6464 es.HeadingBlockModel.prototype.commit = function( transaction ) {
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js
@@ -31,7 +31,7 @@
3232 es.TableBlockRowModel.newFromPlainObject = function( obj ) {
3333 return new es.TableBlockRowModel(
3434 // Cells - if given, convert plain cell objects to es.TableBlockCellModel objects
35 - !$.isArray( obj.cells ) ? [] : $.map( obj.cells, function( cell ) {
 35+ !$.isArray( obj.children ) ? [] : $.map( obj.children, function( cell ) {
3636 return !$.isPlainObject( cell ) ? null
3737 : es.TableBlockCellModel.newFromPlainObject( cell )
3838 } ),
Index: trunk/parsers/wikidom/lib/synth/views/es.HeadingBlockView.js
@@ -1,5 +1,5 @@
22 es.HeadingBlockView = function( model ) {
3 - es.BlockView.call( this, model, $('<h' + model.level +'/>') );
 3+ es.BlockView.call( this, model, $('<h' + model.attributes.level +'/>') );
44 this.$.addClass( 'editSurface-headingBlock' );
55 this.contentView = new es.ContentView( this.$, this.model.content );
66 var view = this;
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js
@@ -9,7 +9,7 @@
1010 es.TableBlockRowView = function( model ) {
1111 es.ViewList.call( this, model, $( '<tr>' ) );
1212 es.ViewListItem.call( this, model, this.$ );
13 - this.$.attr( this.model.attributes );
 13+ this.$.attr( 'style', this.model.attributes['html/style'] );
1414 };
1515
1616 /* Methods */
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js
@@ -8,7 +8,7 @@
99 es.TableBlockCellView = function( model ) {
1010 es.ViewList.call( this, model, $( '<td>' ) );
1111 es.ViewListItem.call( this, model, this.$ );
12 - this.$.attr( this.model.attributes );
 12+ this.$.attr( 'style', this.model.attributes['html/style'] );
1313 };
1414
1515 /* Methods */
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js
@@ -9,7 +9,7 @@
1010 es.TableBlockView = function( model ) {
1111 es.ViewList.call( this, model, $( '<table>' ) );
1212 es.BlockView.call( this, model, this.$ );
13 - this.$.attr( this.model.attributes );
 13+ this.$.attr( 'style', this.model.attributes['html/style'] );
1414 this.$.addClass( 'editSurface-tableBlock' );
1515 };
1616

Status & tagging log