Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentViewBranchNode.js |
— | — | @@ -40,8 +40,8 @@ |
41 | 41 | if ( nodes.length && this.children[i] === nodes[0].node ) { |
42 | 42 | for ( var j = 0; j < nodes.length; j++ ) { |
43 | 43 | nodes[j].node.drawSelection( nodes[j].range ); |
44 | | - i++; |
45 | 44 | } |
| 45 | + i += nodes.length - 1; |
46 | 46 | } else { |
47 | 47 | this.children[i].clearSelection(); |
48 | 48 | } |
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -68,10 +68,10 @@ |
69 | 69 | $document.off( '.es-surfaceView' ); |
70 | 70 | $document.on({ |
71 | 71 | 'mousemove.es-surfaceView': function(e) { |
72 | | - //return surfaceView.onMouseMove( e ); |
| 72 | + return surfaceView.onMouseMove( e ); |
73 | 73 | }, |
74 | 74 | 'mouseup.es-surfaceView': function(e) { |
75 | | - //return surfaceView.onMouseUp( e ); |
| 75 | + return surfaceView.onMouseUp( e ); |
76 | 76 | }, |
77 | 77 | 'keydown.es-surfaceView': function( e ) { |
78 | 78 | return surfaceView.onKeyDown( e ); |
— | — | @@ -114,16 +114,49 @@ |
115 | 115 | }; |
116 | 116 | |
117 | 117 | es.SurfaceView.prototype.onMouseDown = function( e ) { |
118 | | - var position = es.Position.newFromEventPagePosition( e ), |
119 | | - offset = this.documentView.getOffsetFromEvent( e ), |
120 | | - nodeView = this.documentView.getNodeFromOffset( offset, false ); |
121 | | - this.showCursor( offset, position.left > nodeView.$.offset().left ); |
| 118 | + if ( e.button === 0 /* left mouse button */ ) { |
| 119 | + var position = es.Position.newFromEventPagePosition( e ), |
| 120 | + offset = this.documentView.getOffsetFromEvent( e ), |
| 121 | + nodeView = this.documentView.getNodeFromOffset( offset, false ); |
| 122 | + this.showCursor( offset, position.left > nodeView.$.offset().left ); |
| 123 | + this.mouse.selecting = true; |
| 124 | + if ( !this.keyboard.keys.shift ) { |
| 125 | + this.selection.from = offset; |
| 126 | + } |
| 127 | + this.selection.to = offset; |
| 128 | + this.drawSelection(); |
| 129 | + } |
122 | 130 | if ( !this.$input.is( ':focus' ) ) { |
123 | 131 | this.$input.focus().select(); |
124 | 132 | } |
| 133 | + this.cursor.initialLeft = null; |
125 | 134 | return false; |
126 | 135 | }; |
127 | 136 | |
| 137 | +es.SurfaceView.prototype.onMouseMove = function( e ) { |
| 138 | + if ( e.button === 0 /* left mouse button */ && this.mouse.selecting ) { |
| 139 | + this.hideCursor(); |
| 140 | + this.selection.to = this.documentView.getOffsetFromEvent( e ); |
| 141 | + if ( !this.drawSelection() ) { |
| 142 | + this.showCursor(); |
| 143 | + } |
| 144 | + } |
| 145 | +}; |
| 146 | + |
| 147 | +es.SurfaceView.prototype.onMouseUp = function( e ) { |
| 148 | + if ( e.button === 0 /* left mouse button */ && this.selection.to ) { |
| 149 | + if ( this.drawSelection() ) { |
| 150 | + this.hideCursor(); |
| 151 | + } |
| 152 | + } |
| 153 | + this.mouse.selecting = false; |
| 154 | +}; |
| 155 | + |
| 156 | +es.SurfaceView.prototype.drawSelection = function() { |
| 157 | + this.documentView.drawSelection( new es.Range( this.selection.from, this.selection.to ) ); |
| 158 | + return this.selection.from !== this.selection.to; |
| 159 | +}; |
| 160 | + |
128 | 161 | es.SurfaceView.prototype.onKeyDown = function( e ) { |
129 | 162 | switch ( e.keyCode ) { |
130 | 163 | case 16: // Shift |