r96619 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96618‎ | r96619 | r96620 >
Date:21:58, 8 September 2011
Author:inez
Status:deferred
Tags:
Comment:
List block code preparation
Modified paths:
  • /trunk/parsers/wikidom/demos/synth/es.js (modified) (history)
  • /trunk/parsers/wikidom/demos/synth/index.html (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js (added) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js (added) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
@@ -9,6 +9,7 @@
1010 * @property styles {Array}
1111 */
1212 es.ListBlockItemModel = function( content, styles ) {
 13+ es.ModelContainerItem.call( this, 'list' );
1314 this.content = content || null;
1415 this.styles = styles || ['bullet'];
1516 };
@@ -41,6 +42,10 @@
4243 * @method
4344 * @returns {Integer}
4445 */
45 -es.TableBlockRowModel.prototype.getLength = function() {
 46+es.ListBlockItemModel.prototype.getLength = function() {
4647 return this.cells.getLength();
4748 };
 49+
 50+/* Inheritance */
 51+
 52+es.extend( es.ListBlockItemModel, es.ModelContainerItem );
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js
@@ -8,7 +8,8 @@
99 */
1010 es.ListBlockModel = function( items ) {
1111 es.BlockModel.call( this, ['hasContent', 'isAnnotatable', 'isAggregate'] );
12 - this.items = new es.ContentSeries( items || [] );
 12+ es.ModelContainer.call( this );
 13+ this.items = new es.AggregateArray( items || [] );
1314 };
1415
1516 /* Static Methods */
@@ -45,7 +46,7 @@
4647 }
4748 if ( $.isArray( item.lists ) ) {
4849 $.each( item.lists, function( i, list ) {
49 - items = items.concat( es.ListBlockList.flattenList( list, styles ) );
 50+ items = items.concat( es.ListBlockModel.flattenPlainObject( list, styles ) );
5051 } );
5152 }
5253 } );
@@ -106,8 +107,9 @@
107108 };
108109
109110 // Register constructor
110 -es.BlockModel.constructors['list'] = es.ListBlockModel;
 111+es.BlockModel.constructors['list'] = es.ListBlockModel.newFromPlainObject
111112
112113 /* Inheritance */
113114
114115 es.extend( es.ListBlockModel, es.BlockModel );
 116+es.extend( es.ListBlockModel, es.ModelContainer );
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js
@@ -0,0 +1,37 @@
 2+/**
 3+ * Creates an es.ParagraphBlockView object.
 4+ */
 5+es.ListBlockItemView = function( model ) {
 6+ es.BlockView.call( this, model, 'item' );
 7+ this.contentView = new es.ContentView( this.$, this.model.content );
 8+};
 9+
 10+/**
 11+ * Render content.
 12+ */
 13+es.ListBlockItemView.prototype.renderContent = function() {
 14+ this.contentView.render();
 15+};
 16+
 17+/**
 18+ * Gets offset within content of position.
 19+ */
 20+es.ListBlockItemView.getContentOffset = function( position ) {
 21+ return this.contentView.getOffset( position );
 22+};
 23+
 24+/**
 25+ * Gets rendered position of offset within content.
 26+ */
 27+es.ListBlockItemView.getRenderedPosition = function( offset ) {
 28+ return this.contentView.getPosition( position );
 29+};
 30+
 31+/**
 32+ * Gets rendered line index of offset within content.
 33+ */
 34+es.ListBlockItemView.getRenderedLineIndex = function( offset ) {
 35+ return this.contentView.getLineIndex( position );
 36+};
 37+
 38+es.extend( es.ListBlockItemView, es.BlockView );
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js
@@ -0,0 +1,39 @@
 2+/**
 3+ * Creates an es.ParagraphBlockView object.
 4+ */
 5+es.ListBlockView = function( model ) {
 6+ es.ViewContainer.call( this, model, 'list' );
 7+ es.ViewContainerItem.call( this, model, 'list' );
 8+ this.contentView = new es.ContentView( this.$, this.model.content );
 9+};
 10+
 11+/**
 12+ * Render content.
 13+ */
 14+es.ListBlockView.prototype.renderContent = function() {
 15+ this.contentView.render();
 16+};
 17+
 18+/**
 19+ * Gets offset within content of position.
 20+ */
 21+es.ListBlockView.getContentOffset = function( position ) {
 22+ return this.contentView.getOffset( position );
 23+};
 24+
 25+/**
 26+ * Gets rendered position of offset within content.
 27+ */
 28+es.ListBlockView.getRenderedPosition = function( offset ) {
 29+ return this.contentView.getPosition( position );
 30+};
 31+
 32+/**
 33+ * Gets rendered line index of offset within content.
 34+ */
 35+es.ListBlockView.getRenderedLineIndex = function( offset ) {
 36+ return this.contentView.getLineIndex( position );
 37+};
 38+
 39+es.extend( es.ListBlockView, es.ViewContainer );
 40+es.extend( es.ListBlockView, es.ViewContainerItem );
Index: trunk/parsers/wikidom/demos/synth/es.js
@@ -37,6 +37,106 @@
3838 {
3939 'type': 'paragraph',
4040 'content': { 'text': 'The soft returns are usually placed after the ends of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a hyphen.\nWord wrap following hyphens is sometimes not desired, and can be avoided by using a so-called non-breaking hyphen instead of a regular hyphen. On the other hand, when using word processors, invisible hyphens, called soft hyphens, can also be inserted inside words so that word wrap can occur following the soft hyphens.\nSometimes, word wrap is not desirable between words. In such cases, word wrap can usually be avoided by using a hard space or non-breaking space between the words, instead of regular spaces.\nOccasionallyThereAreWordsThatAreSoLongTheyExceedTheWidthOfTheLineAndEndUpWrappingBetweenMultipleLines.\nText might have\ttabs\tin it too. Not all text will end in a line breaking character' }
 41+ },
 42+ {
 43+ 'type': 'list',
 44+ 'style': 'number',
 45+ 'items': [
 46+ {
 47+ 'content': { 'text': 'Operating Systems' },
 48+ 'lists': [
 49+ {
 50+ 'style': 'bullet',
 51+ 'items': [
 52+ {
 53+ 'content': { 'text': 'Linux' },
 54+ 'lists': [
 55+ {
 56+ 'style': 'bullet',
 57+ 'items': [
 58+ {
 59+ 'content': { 'text': 'Ubuntu' },
 60+ 'lists': [
 61+ {
 62+ 'style': 'bullet',
 63+ 'items': [
 64+ {
 65+ 'content': {
 66+ 'text': 'Desktop: Intuitive office apps, safe and fast web browsing, and seamless integration. Ubuntu brings the very best technologies straight to the desktop.',
 67+ 'annotations': [
 68+ // "[citation needed 2]" should be super
 69+ {
 70+ 'type': 'template',
 71+ 'data': {
 72+ 'html': '<sup><small><a href="#">[citation needed 2]</a></small></sup>'
 73+ },
 74+ 'range': { 'start': 85, 'end': 86 }
 75+ }
 76+ ]
 77+ }
 78+ },
 79+ { 'content': { 'text': 'Server: Secure, fast and powerful, Ubuntu Server is transforming IT environments worldwide. Realise the full potential of your infrastructure with a reliable, easy-to-integrate technology platform. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. Lorem ipsum.. ' } },
 80+ { 'content': { 'text': 'Cloud: Ubuntu cloud computing puts you in control of your IT infrastructure. It helps you access computing power as and when you need it so you can meet user demand more effectively.' } }
 81+ ]
 82+ }
 83+ ]
 84+ },
 85+ { 'content': { 'text': 'Fedora' } },
 86+ { 'content': { 'text': 'Gentoo' } }
 87+ ]
 88+ }
 89+ ]
 90+ },
 91+ { 'content': { 'text': 'Windows' } },
 92+ { 'content': { 'text': 'Mac' } }
 93+ ]
 94+ }
 95+ ]
 96+ },
 97+ {
 98+ 'content': {
 99+ 'text': 'Second item',
 100+ 'annotations': [
 101+ {
 102+ 'type': 'italic',
 103+ 'range': {
 104+ 'start': 0,
 105+ 'end': 6
 106+ }
 107+ }
 108+ ]
 109+ }
 110+ },
 111+ {
 112+ 'content': {
 113+ 'text': 'Third item',
 114+ 'annotations': [
 115+ {
 116+ 'type': 'bold',
 117+ 'range': {
 118+ 'start': 0,
 119+ 'end': 5
 120+ }
 121+ }
 122+ ]
 123+ }
 124+ },
 125+ {
 126+ 'content': {
 127+ 'text': 'Fourth item',
 128+ 'annotations': [
 129+ {
 130+ 'type': 'ilink',
 131+ 'range': {
 132+ 'start': 7,
 133+ 'end': 11
 134+ },
 135+ 'data': { 'title': 'User:JohnDoe' }
 136+ }
 137+ ]
 138+ }
 139+ }
 140+ ]
41141 }
42142 ] } );
43143 var surface = new es.SurfaceView( $('#es-editor'), doc );
Index: trunk/parsers/wikidom/demos/synth/index.html
@@ -65,10 +65,14 @@
6666 <script src="../../lib/synth/models/es.DocumentModel.js"></script>
6767 <script src="../../lib/synth/models/es.BlockModel.js"></script>
6868 <script src="../../lib/synth/models/es.ContentModel.js"></script>
 69+ <script src="../../lib/synth/models/es.ListBlockItemModel.js"></script>
 70+ <script src="../../lib/synth/models/es.ListBlockModel.js"></script>
6971 <script src="../../lib/synth/models/es.ParagraphBlockModel.js"></script>
7072 <script src="../../lib/synth/views/es.BlockView.js"></script>
7173 <script src="../../lib/synth/views/es.ContentView.js"></script>
7274 <script src="../../lib/synth/views/es.DocumentView.js"></script>
 75+ <script src="../../lib/synth/views/es.ListBlockItemView.js"></script>
 76+ <script src="../../lib/synth/views/es.ListBlockView.js"></script>
7377 <script src="../../lib/synth/views/es.ParagraphBlockView.js"></script>
7478 <script src="../../lib/synth/views/es.SurfaceView.js"></script>
7579

Status & tagging log