r100764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100763‎ | r100764 | r100765 >
Date:23:58, 25 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Add reference to SurfaceView in DocumentView. Add dimenstions property in SurfaceView which it automatically updated (based on resize and scroll events).
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
@@ -9,11 +9,10 @@
1010 this.model = model;
1111
1212 // Initialize document view
13 - this.documentView = new es.DocumentView( this.model.getDocument() );
 13+ this.documentView = new es.DocumentView( this.model.getDocument(), this );
1414 this.$.append( this.documentView.$ );
1515
1616 // Interaction state
17 - this.width = null;
1817 this.mouse = {
1918 selecting: false,
2019 clicks: 0,
@@ -90,21 +89,36 @@
9190 return surfaceView.onPaste( e );
9291 }
9392 } ).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+ };
94102
95103 // Re-render when resizing horizontally
96 - $(window).resize( function() {
 104+ $( window ).resize( function() {
97105 surfaceView.hideCursor();
 106+ surfaceView.dimensions.height = surfaceView.$.height();
98107 var width = surfaceView.$.width();
99 - if ( surfaceView.width !== width ) {
100 - surfaceView.width = width;
 108+ if ( surfaceView.dimensions.width !== width ) {
 109+ surfaceView.dimensions.width = width;
101110 surfaceView.documentView.renderContent();
102111 }
103112 } );
104113
105 - // First render
106 - this.documentView.renderContent();
 114+ $( window ).scroll( function() {
 115+ surfaceView.dimensions.scrollTop = $( window ).scrollTop()
 116+ } );
107117 };
108118
 119+es.SurfaceView.prototype.getDimensions = function() {
 120+ return this.dimensions;
 121+};
 122+
109123 es.SurfaceView.prototype.onKeyDown = function( e ) {
110124 switch ( e.keyCode ) {
111125 case 16: // Shift
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js
@@ -5,9 +5,10 @@
66 * @extends {es.ViewList}
77 * @constructor
88 */
9 -es.DocumentView = function( documentModel ) {
 9+es.DocumentView = function( documentModel, surfaceView ) {
1010 es.ViewList.call( this, documentModel );
11 - this.$.addClass( 'editSurface-document' )
 11+ this.$.addClass( 'editSurface-document' );
 12+ this.surfaceView = surfaceView;
1213 };
1314
1415 /* Methods */

Status & tagging log