r97753 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97752‎ | r97753 | r97754 >
Date:18:59, 21 September 2011
Author:tparscal
Status:deferred
Tags:
Comment:
More cleanup from merge
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
@@ -4,11 +4,15 @@
55 * @class
66 * @constructor
77 */
8 -es.SurfaceView = function( $container, surfaceModel ) {
 8+es.SurfaceView = function( $container, model ) {
99 this.$ = $container.addClass( 'editSurface' );
10 - this.model = surfaceModel;
 10+ this.model = model;
 11+
 12+ // Initialize document view
1113 this.documentView = new es.DocumentView( this.model.getDocument() );
1214 this.$.append( this.documentView.$ );
 15+
 16+ // Interaction state
1317 this.width = null;
1418 this.mouse = {
1519 'selecting': false,
@@ -30,25 +34,13 @@
3135 }
3236 };
3337
34 - // Selection
35 - this.$ranges = $( '<div class="editSurface-ranges"></div>' ).prependTo( this.$ );
36 - this.$rangeStart = $( '<div class="editSurface-range"></div>' ).appendTo( this.$ranges );
37 - this.$rangeFill = $( '<div class="editSurface-range"></div>' ).appendTo( this.$ranges );
38 - this.$rangeEnd = $( '<div class="editSurface-range"></div>' ).appendTo( this.$ranges );
39 -
4038 // Cursor
4139 this.blinkInterval = null;
4240 this.$cursor = $( '<div class="editSurface-cursor"></div>' ).appendTo( this.$ );
4341
44 - // Resize
45 - var surfaceView = this;
46 - $(window).resize( function() {
47 - var width = surfaceView.$.width();
48 - if ( surfaceView.width !== width ) {
49 - surfaceView.width = width;
50 - surfaceView.documentView.renderContent();
51 - }
52 - } );
 42+ // References for use in closures
 43+ var surfaceView = this,
 44+ $document = $(document);
5345
5446 // MouseDown on surface
5547 this.$.bind( {
@@ -58,12 +50,11 @@
5951 } );
6052
6153 // Hidden input
62 - var $document = $(document);
6354 this.$input = $( '<input class="editSurface-input" />' )
6455 .prependTo( this.$ )
6556 .bind( {
6657 'focus' : function() {
67 - $(document).bind({
 58+ $document.bind({
6859 'mousemove.editSurface' : function(e) {
6960 return surfaceView.onMouseMove( e );
7061 },
@@ -93,9 +84,14 @@
9485 }
9586 } );
9687
 88+ // Re-render when resizing horizontally
9789 $(window).resize( function() {
98 - surfaceView.view.hideCursor();
99 - surfaceView.view.renderContent();
 90+ surfaceView.hideCursor();
 91+ var width = surfaceView.$.width();
 92+ if ( surfaceView.width !== width ) {
 93+ surfaceView.width = width;
 94+ surfaceView.documentView.renderContent();
 95+ }
10096 } );
10197
10298 // First render

Status & tagging log