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

Revision: 96619
Author:   inez
Date:     2011-09-08 21:58:49 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
List block code preparation

Modified Paths:
--------------
    trunk/parsers/wikidom/demos/synth/es.js
    trunk/parsers/wikidom/demos/synth/index.html
    trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
    trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js

Added Paths:
-----------
    trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js
    trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js

Modified: trunk/parsers/wikidom/demos/synth/es.js
===================================================================
--- trunk/parsers/wikidom/demos/synth/es.js     2011-09-08 21:21:26 UTC (rev 
96618)
+++ trunk/parsers/wikidom/demos/synth/es.js     2011-09-08 21:58:49 UTC (rev 
96619)
@@ -37,6 +37,106 @@
                {
                        'type': 'paragraph',
                        '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' }
+               },
+               {
+                       'type': 'list',
+                       'style': 'number',
+                       'items': [
+                               {
+                                       'content': { 'text': 'Operating 
Systems' },
+                                       'lists': [
+                                               {
+                                                       'style': 'bullet',
+                                                       'items': [
+                                                               {
+                                                                       
'content': { 'text': 'Linux' },
+                                                                       
'lists': [
+                                                                               
{
+                                                                               
        'style': 'bullet',
+                                                                               
        'items': [
+                                                                               
                {
+                                                                               
                        'content': { 'text': 'Ubuntu' },
+                                                                               
                        'lists': [
+                                                                               
                                {
+                                                                               
                                        'style': 'bullet',
+                                                                               
                                        'items': [
+                                                                               
                                                {
+                                                                               
                                                        'content': {
+                                                                               
                                                                'text': 
'Desktop: Intuitive office apps, safe and fast web browsing, and seamless 
integration.  Ubuntu brings the very best technologies straight to the 
desktop.',
+                                                                               
                                                                'annotations': [
+                                                                               
                                                                        // 
"[citation needed 2]" should be super
+                                                                               
                                                                        {
+                                                                               
                                                                                
'type': 'template',
+                                                                               
                                                                                
'data': {
+                                                                               
                                                                                
        'html': '<sup><small><a href="#">[citation needed 2]</a></small></sup>'
+                                                                               
                                                                                
},
+                                                                               
                                                                                
'range': { 'start': 85, 'end': 86 }
+                                                                               
                                                                        }
+                                                                               
                                                                ]
+                                                                               
                                                        }
+                                                                               
                                                },
+                                                                               
                                                { '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.. ' } },
+                                                                               
                                                { '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.' } }
+                                                                               
                                        ]
+                                                                               
                                }
+                                                                               
                        ]
+                                                                               
                },
+                                                                               
                { 'content': { 'text': 'Fedora' } },
+                                                                               
                { 'content': { 'text': 'Gentoo' } }
+                                                                               
        ]
+                                                                               
}
+                                                                       ]
+                                                               },
+                                                               { 'content': { 
'text': 'Windows' } },
+                                                               { 'content': { 
'text': 'Mac' } }
+                                                       ]
+                                               }
+                                       ]
+                               },
+                               {
+                                       'content': {
+                                               'text': 'Second item',
+                                               'annotations': [
+                                                       {
+                                                               'type': 
'italic',
+                                                               'range': {
+                                                                       
'start': 0,
+                                                                       'end': 6
+                                                               }
+                                                       }
+                                               ]
+                                       }
+                               },
+                               {
+                                       'content': {
+                                               'text': 'Third item',
+                                               'annotations': [
+                                                       {
+                                                               'type': 'bold',
+                                                               'range': {
+                                                                       
'start': 0,
+                                                                       'end': 5
+                                                               }
+                                                       }
+                                               ]
+                                       }
+                               },
+                               {
+                                       'content': {
+                                               'text': 'Fourth item',
+                                               'annotations': [
+                                                       {
+                                                               'type': 'ilink',
+                                                               'range': {
+                                                                       
'start': 7,
+                                                                       'end': 
11
+                                                               },
+                                                               'data': { 
'title': 'User:JohnDoe' }
+                                                       }
+                                               ]
+                                       }
+                               }
+                       ]
                }
        ] } );
        var surface = new es.SurfaceView( $('#es-editor'), doc );

Modified: trunk/parsers/wikidom/demos/synth/index.html
===================================================================
--- trunk/parsers/wikidom/demos/synth/index.html        2011-09-08 21:21:26 UTC 
(rev 96618)
+++ trunk/parsers/wikidom/demos/synth/index.html        2011-09-08 21:58:49 UTC 
(rev 96619)
@@ -65,10 +65,14 @@
                <script 
src="../../lib/synth/models/es.DocumentModel.js"></script>
                <script src="../../lib/synth/models/es.BlockModel.js"></script>
                <script 
src="../../lib/synth/models/es.ContentModel.js"></script>
+               <script 
src="../../lib/synth/models/es.ListBlockItemModel.js"></script>
+               <script 
src="../../lib/synth/models/es.ListBlockModel.js"></script>
                <script 
src="../../lib/synth/models/es.ParagraphBlockModel.js"></script>
                <script src="../../lib/synth/views/es.BlockView.js"></script>
                <script src="../../lib/synth/views/es.ContentView.js"></script>
                <script src="../../lib/synth/views/es.DocumentView.js"></script>
+               <script 
src="../../lib/synth/views/es.ListBlockItemView.js"></script>
+               <script 
src="../../lib/synth/views/es.ListBlockView.js"></script>
                <script 
src="../../lib/synth/views/es.ParagraphBlockView.js"></script>
                <script src="../../lib/synth/views/es.SurfaceView.js"></script>
                

Modified: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js     
2011-09-08 21:21:26 UTC (rev 96618)
+++ trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js     
2011-09-08 21:58:49 UTC (rev 96619)
@@ -9,6 +9,7 @@
  * @property styles {Array}
  */
 es.ListBlockItemModel = function( content, styles ) {
+       es.ModelContainerItem.call( this, 'list' );
        this.content = content || null;
        this.styles = styles || ['bullet'];
 };
@@ -41,6 +42,10 @@
  * @method
  * @returns {Integer}
  */
-es.TableBlockRowModel.prototype.getLength = function() {
+es.ListBlockItemModel.prototype.getLength = function() {
        return this.cells.getLength();
 };
+
+/* Inheritance */
+
+es.extend( es.ListBlockItemModel, es.ModelContainerItem );
\ No newline at end of file

Modified: trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js 2011-09-08 
21:21:26 UTC (rev 96618)
+++ trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js 2011-09-08 
21:58:49 UTC (rev 96619)
@@ -8,7 +8,8 @@
  */
 es.ListBlockModel = function( items ) {
        es.BlockModel.call( this, ['hasContent', 'isAnnotatable', 
'isAggregate'] );
-       this.items = new es.ContentSeries( items || [] );
+       es.ModelContainer.call( this );
+       this.items = new es.AggregateArray( items || [] );
 };
 
 /* Static Methods */
@@ -45,7 +46,7 @@
                        }
                        if ( $.isArray( item.lists ) ) {
                                $.each( item.lists, function( i, list ) {
-                                       items = items.concat( 
es.ListBlockList.flattenList( list, styles ) );
+                                       items = items.concat( 
es.ListBlockModel.flattenPlainObject( list, styles ) );
                                } );
                        }
                } );
@@ -106,8 +107,9 @@
 };
 
 // Register constructor
-es.BlockModel.constructors['list'] = es.ListBlockModel;
+es.BlockModel.constructors['list'] = es.ListBlockModel.newFromPlainObject
 
 /* Inheritance */
 
 es.extend( es.ListBlockModel, es.BlockModel );
+es.extend( es.ListBlockModel, es.ModelContainer );

Added: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js               
                (rev 0)
+++ trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js       
2011-09-08 21:58:49 UTC (rev 96619)
@@ -0,0 +1,37 @@
+/**
+ * Creates an es.ParagraphBlockView object.
+ */
+es.ListBlockItemView = function( model ) {
+       es.BlockView.call( this, model, 'item' );
+       this.contentView = new es.ContentView( this.$, this.model.content );
+};
+
+/**
+ * Render content.
+ */
+es.ListBlockItemView.prototype.renderContent = function() {
+       this.contentView.render();
+};
+
+/**
+ * Gets offset within content of position.
+ */
+es.ListBlockItemView.getContentOffset = function( position ) {
+       return this.contentView.getOffset( position );
+};
+
+/**
+ * Gets rendered position of offset within content.
+ */
+es.ListBlockItemView.getRenderedPosition = function( offset ) {
+       return this.contentView.getPosition( position );
+};
+
+/**
+ * Gets rendered line index of offset within content.
+ */
+es.ListBlockItemView.getRenderedLineIndex = function( offset ) {
+       return this.contentView.getLineIndex( position );
+};
+
+es.extend( es.ListBlockItemView, es.BlockView );

Added: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js                   
        (rev 0)
+++ trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js   2011-09-08 
21:58:49 UTC (rev 96619)
@@ -0,0 +1,39 @@
+/**
+ * Creates an es.ParagraphBlockView object.
+ */
+es.ListBlockView = function( model ) {
+       es.ViewContainer.call( this, model, 'list' );
+       es.ViewContainerItem.call( this, model, 'list' );
+       this.contentView = new es.ContentView( this.$, this.model.content );
+};
+
+/**
+ * Render content.
+ */
+es.ListBlockView.prototype.renderContent = function() {
+       this.contentView.render();
+};
+
+/**
+ * Gets offset within content of position.
+ */
+es.ListBlockView.getContentOffset = function( position ) {
+       return this.contentView.getOffset( position );
+};
+
+/**
+ * Gets rendered position of offset within content.
+ */
+es.ListBlockView.getRenderedPosition = function( offset ) {
+       return this.contentView.getPosition( position );
+};
+
+/**
+ * Gets rendered line index of offset within content.
+ */
+es.ListBlockView.getRenderedLineIndex = function( offset ) {
+       return this.contentView.getLineIndex( position );
+};
+
+es.extend( es.ListBlockView, es.ViewContainer );
+es.extend( es.ListBlockView, es.ViewContainerItem );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to