http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97753
Revision: 97753
Author: tparscal
Date: 2011-09-21 18:59:06 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
More cleanup from merge
Modified Paths:
--------------
trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
Modified: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js 2011-09-21
18:49:48 UTC (rev 97752)
+++ trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js 2011-09-21
18:59:06 UTC (rev 97753)
@@ -4,11 +4,15 @@
* @class
* @constructor
*/
-es.SurfaceView = function( $container, surfaceModel ) {
+es.SurfaceView = function( $container, model ) {
this.$ = $container.addClass( 'editSurface' );
- this.model = surfaceModel;
+ this.model = model;
+
+ // Initialize document view
this.documentView = new es.DocumentView( this.model.getDocument() );
this.$.append( this.documentView.$ );
+
+ // Interaction state
this.width = null;
this.mouse = {
'selecting': false,
@@ -30,25 +34,13 @@
}
};
- // Selection
- this.$ranges = $( '<div class="editSurface-ranges"></div>' ).prependTo(
this.$ );
- this.$rangeStart = $( '<div class="editSurface-range"></div>'
).appendTo( this.$ranges );
- this.$rangeFill = $( '<div class="editSurface-range"></div>'
).appendTo( this.$ranges );
- this.$rangeEnd = $( '<div class="editSurface-range"></div>' ).appendTo(
this.$ranges );
-
// Cursor
this.blinkInterval = null;
this.$cursor = $( '<div class="editSurface-cursor"></div>' ).appendTo(
this.$ );
- // Resize
- var surfaceView = this;
- $(window).resize( function() {
- var width = surfaceView.$.width();
- if ( surfaceView.width !== width ) {
- surfaceView.width = width;
- surfaceView.documentView.renderContent();
- }
- } );
+ // References for use in closures
+ var surfaceView = this,
+ $document = $(document);
// MouseDown on surface
this.$.bind( {
@@ -58,12 +50,11 @@
} );
// Hidden input
- var $document = $(document);
this.$input = $( '<input class="editSurface-input" />' )
.prependTo( this.$ )
.bind( {
'focus' : function() {
- $(document).bind({
+ $document.bind({
'mousemove.editSurface' : function(e) {
return surfaceView.onMouseMove(
e );
},
@@ -93,9 +84,14 @@
}
} );
+ // Re-render when resizing horizontally
$(window).resize( function() {
- surfaceView.view.hideCursor();
- surfaceView.view.renderContent();
+ surfaceView.hideCursor();
+ var width = surfaceView.$.width();
+ if ( surfaceView.width !== width ) {
+ surfaceView.width = width;
+ surfaceView.documentView.renderContent();
+ }
} );
// First render
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs