| Index: trunk/parsers/wikidom/lib/es/es.Surface.js |
| — | — | @@ -8,26 +8,41 @@ |
| 9 | 9 | this.$ = $container; |
| 10 | 10 | this.document = document; |
| 11 | 11 | this.rendered = false; |
| | 12 | + this.location = null; |
| 12 | 13 | this.render(); |
| 13 | | - |
| 14 | | - this.$.mousedown(function(e) { |
| 15 | | - var $target = $( e.target ); |
| 16 | | - $block = $target.is( '.editSurface-block' ) ? $target : $target.closest( '.editSurface-block' ), |
| 17 | | - block = $block.data( 'block' ); |
| 18 | | - var position = new Position(e.pageX - $block.offset().left, e.pageY - $block.offset().top); |
| 19 | | - var offest = block.flow.getOffset( position ); |
| 20 | | - block.insertContent(offest, '!'); |
| 21 | | - //this.setCursor(new Location(block, offset)) |
| | 14 | + |
| | 15 | + var surface = this; |
| | 16 | + |
| | 17 | + this.$.bind({ |
| | 18 | + 'mousedown' : function(e) { |
| | 19 | + return surface.onMouseDown( e ); |
| | 20 | + } |
| 22 | 21 | }); |
| 23 | 22 | } |
| 24 | 23 | |
| | 24 | +Surface.prototype.onMouseDown = function( e ) { |
| | 25 | + var $target = $( e.target ); |
| | 26 | + $block = $target.is( '.editSurface-block' ) ? $target : $target.closest( '.editSurface-block' ), |
| | 27 | + block = $block.data( 'block' ); |
| | 28 | + |
| | 29 | + if( !block ) { |
| | 30 | + return false; |
| | 31 | + } |
| | 32 | + |
| | 33 | + var position = new Position(e.pageX - $block.offset().left, |
| | 34 | + e.pageY - $block.offset().top); |
| | 35 | + var offset = block.flow.getOffset( position ); |
| | 36 | + this.setCursor( new Location( block, offset ) ); |
| | 37 | +}; |
| | 38 | + |
| 25 | 39 | /** |
| 26 | 40 | * Moves the cursor to a new location. |
| 27 | 41 | * |
| 28 | 42 | * @param location {Location} Location to move the cursor to |
| 29 | 43 | */ |
| 30 | 44 | Surface.prototype.setCursor = function( location ) { |
| 31 | | - // |
| | 45 | + this.location = location; |
| | 46 | + // ... |
| 32 | 47 | }; |
| 33 | 48 | |
| 34 | 49 | /** |