r91577 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91576‎ | r91577 | r91578 >
Date:18:21, 6 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Better handling of mousedown in Surface
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -8,26 +8,41 @@
99 this.$ = $container;
1010 this.document = document;
1111 this.rendered = false;
 12+ this.location = null;
1213 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+ }
2221 });
2322 }
2423
 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+
2539 /**
2640 * Moves the cursor to a new location.
2741 *
2842 * @param location {Location} Location to move the cursor to
2943 */
3044 Surface.prototype.setCursor = function( location ) {
31 - //
 45+ this.location = location;
 46+ // ...
3247 };
3348
3449 /**

Status & tagging log