Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | * @property styles {Array} |
11 | 11 | */ |
12 | 12 | es.ListBlockItemModel = function( content, styles ) { |
| 13 | + es.ModelContainerItem.call( this, 'list' ); |
13 | 14 | this.content = content || null; |
14 | 15 | this.styles = styles || ['bullet']; |
15 | 16 | }; |
— | — | @@ -41,6 +42,10 @@ |
42 | 43 | * @method |
43 | 44 | * @returns {Integer} |
44 | 45 | */ |
45 | | -es.TableBlockRowModel.prototype.getLength = function() { |
| 46 | +es.ListBlockItemModel.prototype.getLength = function() { |
46 | 47 | return this.cells.getLength(); |
47 | 48 | }; |
| 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 @@ |
9 | 9 | */ |
10 | 10 | es.ListBlockModel = function( items ) { |
11 | 11 | 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 || [] ); |
13 | 14 | }; |
14 | 15 | |
15 | 16 | /* Static Methods */ |
— | — | @@ -45,7 +46,7 @@ |
46 | 47 | } |
47 | 48 | if ( $.isArray( item.lists ) ) { |
48 | 49 | $.each( item.lists, function( i, list ) { |
49 | | - items = items.concat( es.ListBlockList.flattenList( list, styles ) ); |
| 50 | + items = items.concat( es.ListBlockModel.flattenPlainObject( list, styles ) ); |
50 | 51 | } ); |
51 | 52 | } |
52 | 53 | } ); |
— | — | @@ -106,8 +107,9 @@ |
107 | 108 | }; |
108 | 109 | |
109 | 110 | // Register constructor |
110 | | -es.BlockModel.constructors['list'] = es.ListBlockModel; |
| 111 | +es.BlockModel.constructors['list'] = es.ListBlockModel.newFromPlainObject |
111 | 112 | |
112 | 113 | /* Inheritance */ |
113 | 114 | |
114 | 115 | 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 @@ |
38 | 38 | { |
39 | 39 | 'type': 'paragraph', |
40 | 40 | '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 | + ] |
41 | 141 | } |
42 | 142 | ] } ); |
43 | 143 | var surface = new es.SurfaceView( $('#es-editor'), doc ); |
Index: trunk/parsers/wikidom/demos/synth/index.html |
— | — | @@ -65,10 +65,14 @@ |
66 | 66 | <script src="../../lib/synth/models/es.DocumentModel.js"></script> |
67 | 67 | <script src="../../lib/synth/models/es.BlockModel.js"></script> |
68 | 68 | <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> |
69 | 71 | <script src="../../lib/synth/models/es.ParagraphBlockModel.js"></script> |
70 | 72 | <script src="../../lib/synth/views/es.BlockView.js"></script> |
71 | 73 | <script src="../../lib/synth/views/es.ContentView.js"></script> |
72 | 74 | <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> |
73 | 77 | <script src="../../lib/synth/views/es.ParagraphBlockView.js"></script> |
74 | 78 | <script src="../../lib/synth/views/es.SurfaceView.js"></script> |
75 | 79 | |