Index: trunk/parsers/wikidom/lib/hype/models/es.SurfaceModel.js |
— | — | @@ -0,0 +1,7 @@ |
| 2 | +es.SurfaceModel = function( doc) { |
| 3 | + this.doc = doc; |
| 4 | +}; |
| 5 | + |
| 6 | +es.SurfaceModel.prototype.getDocument = function() { |
| 7 | + return this.doc; |
| 8 | +}; |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/hype/bases/es.ViewNode.js |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | |
42 | 42 | // Append existing model children |
43 | 43 | for ( var i = 0; i < model.length; i++ ) { |
44 | | - node.onPush( model[i] ); |
| 44 | + node.onAfterPush( model[i] ); |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Observe and mimic changes on model |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | return node; |
59 | 59 | }; |
60 | 60 | |
61 | | -es.ViewNode.onAfterPush = function( childModel ) { |
| 61 | +es.ViewNode.prototype.onAfterPush = function( childModel ) { |
62 | 62 | var childView = childModel.createView(); |
63 | 63 | this.emit( 'beforePush', childView ); |
64 | 64 | childView.attach( this ); |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | this.emit( 'update' ); |
70 | 70 | }; |
71 | 71 | |
72 | | -es.ViewNode.onAfterUnshift = function( childModel ) { |
| 72 | +es.ViewNode.prototype.onAfterUnshift = function( childModel ) { |
73 | 73 | var childView = childModel.createView(); |
74 | 74 | this.emit( 'beforeUnshift', childView ); |
75 | 75 | childView.attach( this ); |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | this.emit( 'update' ); |
81 | 81 | }; |
82 | 82 | |
83 | | -es.ViewNode.onAfterPop = function() { |
| 83 | +es.ViewNode.prototype.onAfterPop = function() { |
84 | 84 | this.emit( 'beforePop' ); |
85 | 85 | var childView = this.pop(); |
86 | 86 | childView.detach(); |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | this.emit( 'update' ); |
91 | 91 | }; |
92 | 92 | |
93 | | -es.ViewNode.onAfterShift = function() { |
| 93 | +es.ViewNode.prototype.onAfterShift = function() { |
94 | 94 | this.emit( 'beforeShift' ); |
95 | 95 | var childView = this.shift(); |
96 | 96 | childView.detach(); |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | this.emit( 'update' ); |
101 | 101 | }; |
102 | 102 | |
103 | | -es.ViewNode.onAfterSplice = function( index, howmany ) { |
| 103 | +es.ViewNode.prototype.onAfterSplice = function( index, howmany ) { |
104 | 104 | var args = Array.prototype.slice( arguments, 0 ); |
105 | 105 | this.emit.apply( ['beforeSplice'].concat( args ) ); |
106 | 106 | this.$.children() |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | this.emit( 'update' ); |
115 | 115 | }; |
116 | 116 | |
117 | | -es.ViewNode.onAfterSort = function() { |
| 117 | +es.ViewNode.prototype.onAfterSort = function() { |
118 | 118 | this.emit( 'beforeSort' ); |
119 | 119 | for ( var i = 0; i < this.model.length; i++ ) { |
120 | 120 | for ( var j = 0; j < this.length; j++ ) { |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | this.emit( 'update' ); |
131 | 131 | }; |
132 | 132 | |
133 | | -es.ViewNode.onAfterReverse = function() { |
| 133 | +es.ViewNode.prototype.onAfterReverse = function() { |
134 | 134 | this.emit( 'beforeReverse' ); |
135 | 135 | this.reverse(); |
136 | 136 | this.$.children().each( function() { |
Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentModelNode.js |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | * @param {Integer} adjustment Amount to adjust content length by |
100 | 100 | * @throws Invalid adjustment error if resulting length is less than 0 |
101 | 101 | */ |
102 | | -es.DocumentModelNode.prototype.adjustContentLength = function( adjustment ) { |
| 102 | +es.DocumentModelNode.prototype.adjustContentLength = function( adjustment, quiet ) { |
103 | 103 | this.contentLength += adjustment; |
104 | 104 | // Make sure the adjustment was sane |
105 | 105 | if ( this.contentLength < 0 ) { |
— | — | @@ -108,8 +108,11 @@ |
109 | 109 | throw 'Invalid adjustment error. Content length can not be less than 0.'; |
110 | 110 | } |
111 | 111 | if ( this.parent ) { |
112 | | - this.parent.adjustContentLength( adjustment ); |
| 112 | + this.parent.adjustContentLength( adjustment, true ); |
113 | 113 | } |
| 114 | + if ( !quiet ) { |
| 115 | + this.emit( 'update' ); |
| 116 | + } |
114 | 117 | }; |
115 | 118 | |
116 | 119 | /** |
Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +es.SurfaceView = function( $container, model ) { |
| 3 | + this.$ = $container.addClass( 'editSurface' ); |
| 4 | + this.$window = $( window ); |
| 5 | + this.model = model; |
| 6 | + |
| 7 | + // Initialize document view |
| 8 | + this.documentView = new es.DocumentView( this.model.getDocument(), this ); |
| 9 | + this.$.append( this.documentView.$ ); |
| 10 | + |
| 11 | + // First render |
| 12 | + this.documentView.renderContent(); |
| 13 | +}; |
\ No newline at end of file |
Index: trunk/parsers/wikidom/lib/hype/views/es.ContentView.js |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | * @property {Object} renderState |
25 | 25 | */ |
26 | 26 | es.ContentView = function( $container, model ) { |
| 27 | + es.EventEmitter.call( this ); |
27 | 28 | this.$ = $container; |
28 | 29 | this.model = model; |
29 | 30 | this.boundaries = []; |
Index: trunk/parsers/wikidom/lib/hype/views/es.DocumentView.js |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +es.DocumentView = function( documentModel, surfaceView ) { |
| 3 | + var node = $.extend( new es.DocumentViewBranchNode( documentModel ), this ); |
| 4 | + node.$.addClass( 'editSurface-document' ); |
| 5 | + node.surfaceView = surfaceView; |
| 6 | + return node; |
| 7 | +}; |
\ No newline at end of file |
Index: trunk/parsers/wikidom/demos/hype/es.js |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +$(document).ready( function() { |
| 3 | + window.wikiDom = { |
| 4 | + 'type': 'document', |
| 5 | + 'children': [ |
| 6 | + { |
| 7 | + 'type': 'paragraph', |
| 8 | + 'content': { 'text': 'Test 1' } |
| 9 | + }, |
| 10 | + { |
| 11 | + 'type': 'paragraph', |
| 12 | + 'content': { 'text': 'Test 22' } |
| 13 | + }, |
| 14 | + { |
| 15 | + 'type': 'paragraph', |
| 16 | + 'content': { 'text': 'Test 333' } |
| 17 | + } |
| 18 | + ] |
| 19 | + }; |
| 20 | + window.doc = es.DocumentModel.newFromPlainObject( window.wikiDom ); |
| 21 | + window.surfaceModel = new es.SurfaceModel( window.doc ); |
| 22 | + window.surfaceView = new es.SurfaceView( $( '#es-editor' ), window.surfaceModel ); |
| 23 | +} ); |
Index: trunk/parsers/wikidom/demos/hype/index.html |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +<!DOCTYPE html> |
| 3 | + |
| 4 | +<html> |
| 5 | + <head> |
| 6 | + <title>EditSurface Demo</title> |
| 7 | + </head> |
| 8 | + <body> |
| 9 | + <div id="es-editor"> |
| 10 | + |
| 11 | + </div> |
| 12 | + |
| 13 | + <!-- EditSurface --> |
| 14 | + <script src="../../lib/jquery.js"></script> |
| 15 | + <script src="../../lib/hype/es.js"></script> |
| 16 | + <script src="../../lib/hype/es.Range.js"></script> |
| 17 | + <script src="../../lib/hype/es.Transaction.js"></script> |
| 18 | + |
| 19 | + <!-- Bases --> |
| 20 | + <script src="../../lib/hype/bases/es.EventEmitter.js"></script> |
| 21 | + <script src="../../lib/hype/bases/es.ModelNode.js"></script> |
| 22 | + <script src="../../lib/hype/bases/es.ViewNode.js"></script> |
| 23 | + <script src="../../lib/hype/bases/es.DocumentNode.js"></script> |
| 24 | + <script src="../../lib/hype/bases/es.DocumentModelNode.js"></script> |
| 25 | + <script src="../../lib/hype/bases/es.DocumentViewBranchNode.js"></script> |
| 26 | + <script src="../../lib/hype/bases/es.DocumentViewLeafNode.js"></script> |
| 27 | + |
| 28 | + <!-- Models --> |
| 29 | + <script src="../../lib/hype/models/es.SurfaceModel.js"></script> |
| 30 | + <script src="../../lib/hype/models/es.DocumentModel.js"></script> |
| 31 | + <script src="../../lib/hype/models/es.ParagraphModel.js"></script> |
| 32 | + |
| 33 | + <!-- Views --> |
| 34 | + <script src="../../lib/hype/views/es.SurfaceView.js"></script> |
| 35 | + <script src="../../lib/hype/views/es.ContentView.js"></script> |
| 36 | + <script src="../../lib/hype/views/es.DocumentView.js"></script> |
| 37 | + <script src="../../lib/hype/views/es.ParagraphView.js"></script> |
| 38 | + |
| 39 | + <!-- Demo --> |
| 40 | + <script src="es.js"></script> |
| 41 | + </body> |
| 42 | +</html> |
\ No newline at end of file |
Property changes on: trunk/parsers/wikidom/demos/hype/index.html |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 43 | + text/plain |