Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js |
— | — | @@ -9,11 +9,10 @@ |
10 | 10 | this.model = model; |
11 | 11 | |
12 | 12 | // Initialize document view |
13 | | - this.documentView = new es.DocumentView( this.model.getDocument() ); |
| 13 | + this.documentView = new es.DocumentView( this.model.getDocument(), this ); |
14 | 14 | this.$.append( this.documentView.$ ); |
15 | 15 | |
16 | 16 | // Interaction state |
17 | | - this.width = null; |
18 | 17 | this.mouse = { |
19 | 18 | selecting: false, |
20 | 19 | clicks: 0, |
— | — | @@ -90,21 +89,36 @@ |
91 | 90 | return surfaceView.onPaste( e ); |
92 | 91 | } |
93 | 92 | } ).focus(); |
| 93 | + |
| 94 | + // First render |
| 95 | + this.documentView.renderContent(); |
| 96 | + |
| 97 | + this.dimensions = { |
| 98 | + width: this.$.width(), |
| 99 | + height: this.$.height(), |
| 100 | + scrollTop: $(window).scrollTop() |
| 101 | + }; |
94 | 102 | |
95 | 103 | // Re-render when resizing horizontally |
96 | | - $(window).resize( function() { |
| 104 | + $( window ).resize( function() { |
97 | 105 | surfaceView.hideCursor(); |
| 106 | + surfaceView.dimensions.height = surfaceView.$.height(); |
98 | 107 | var width = surfaceView.$.width(); |
99 | | - if ( surfaceView.width !== width ) { |
100 | | - surfaceView.width = width; |
| 108 | + if ( surfaceView.dimensions.width !== width ) { |
| 109 | + surfaceView.dimensions.width = width; |
101 | 110 | surfaceView.documentView.renderContent(); |
102 | 111 | } |
103 | 112 | } ); |
104 | 113 | |
105 | | - // First render |
106 | | - this.documentView.renderContent(); |
| 114 | + $( window ).scroll( function() { |
| 115 | + surfaceView.dimensions.scrollTop = $( window ).scrollTop() |
| 116 | + } ); |
107 | 117 | }; |
108 | 118 | |
| 119 | +es.SurfaceView.prototype.getDimensions = function() { |
| 120 | + return this.dimensions; |
| 121 | +}; |
| 122 | + |
109 | 123 | es.SurfaceView.prototype.onKeyDown = function( e ) { |
110 | 124 | switch ( e.keyCode ) { |
111 | 125 | case 16: // Shift |
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js |
— | — | @@ -5,9 +5,10 @@ |
6 | 6 | * @extends {es.ViewList} |
7 | 7 | * @constructor |
8 | 8 | */ |
9 | | -es.DocumentView = function( documentModel ) { |
| 9 | +es.DocumentView = function( documentModel, surfaceView ) { |
10 | 10 | es.ViewList.call( this, documentModel ); |
11 | | - this.$.addClass( 'editSurface-document' ) |
| 11 | + this.$.addClass( 'editSurface-document' ); |
| 12 | + this.surfaceView = surfaceView; |
12 | 13 | }; |
13 | 14 | |
14 | 15 | /* Methods */ |