r92072 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92071‎ | r92072 | r92073 >
Date:18:09, 13 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Handle mouseMove and mouseUp on document instead of surface. Attach and disattach those events based on input being focused. Rename document to doc, to avoid confusing it with window.document.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -15,33 +15,28 @@
1616 /**
1717 *
1818 * @param $container
19 - * @param document
 19+ * @param doc
2020 * @returns {Surface}
2121 */
22 -function Surface( $container, document ) {
 22+function Surface( $container, doc ) {
2323 var surface = this;
2424
2525 this.$ = $container.addClass( 'editSurface' );
26 - this.document = document;
 26+ this.doc = doc;
2727 this.rendered = false;
2828 this.location = null;
2929 this.selection = new Selection();
3030 this.selecting = false;
3131 this.keydownTimeout = null;
3232 this.initialHorizontalCursorPosition = null;
33 -
 33+
 34+ // MouseDown on surface
3435 this.$.bind({
3536 'mousedown' : function(e) {
3637 return surface.onMouseDown( e );
37 - },
38 - 'mousemove' : function(e) {
39 - return surface.onMouseMove( e );
40 - },
41 - 'mouseup' : function(e) {
42 - return surface.onMouseUp( e );
4338 }
4439 });
45 -
 40+
4641 // Selection
4742 this.$ranges = $( '<div class="editSurface-ranges"></div>' ).prependTo( this.$ );
4843 this.$rangeStart = $( '<div class="editSurface-range"></div>' ).appendTo( this.$ranges );
@@ -51,7 +46,7 @@
5247 // Cursor
5348 this.cursor = new Cursor();
5449 this.$.after( this.cursor.$ );
55 -
 50+
5651 // Hidden input
5752 this.$input = $( '<input class="editSurface-input" />' )
5853 .prependTo( this.$ )
@@ -62,11 +57,23 @@
6358 'keyup' : function( e ) {
6459 return surface.onKeyUp( e );
6560 },
 61+ 'focus' : function() {
 62+ $(document).bind({
 63+ 'mousemove.es' : function(e) {
 64+ return surface.onMouseMove( e );
 65+ },
 66+ 'mouseup.es' : function(e) {
 67+ return surface.onMouseUp( e );
 68+ }
 69+ });
 70+ },
6671 'blur': function( e ) {
 72+ $(document).unbind('mousemove.es');
 73+ $(document).unbind('mouseup.es');
6774 surface.cursor.hide();
6875 }
6976 });
70 -
 77+
7178 // First render
7279 this.render();
7380 }
@@ -425,10 +432,10 @@
426433 Surface.prototype.render = function( from ) {
427434 if ( !this.rendered ) {
428435 this.rendered = true;
429 - this.$.append( this.document.$ );
430 - this.document.renderBlocks();
 436+ this.$.append( this.doc.$ );
 437+ this.doc.renderBlocks();
431438 } else {
432 - this.document.updateBlocks();
 439+ this.doc.updateBlocks();
433440 }
434441 };
435442
@@ -455,7 +462,7 @@
456463 } else {
457464 // Multiple block annotation
458465 for ( var i = from.block.getIndex(), end = to.block.getIndex(); i <= end; i++ ) {
459 - var block = this.document.blocks[i];
 466+ var block = this.doc.blocks[i];
460467 if ( block === from.block ) {
461468 // From offset to length
462469 block.annotateContent( annotation, from.offset, block.getLength() );

Status & tagging log