Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -49,26 +49,7 @@ |
50 | 50 | // MouseDown and DoubleClick on surface |
51 | 51 | this.$.on( { |
52 | 52 | 'mousedown' : function(e) { |
53 | | - if ( e.button === 0 ) { |
54 | | - if ( surfaceView.mouse.timer && surfaceView.mouse.clickPosition.near( es.Position.newFromEventScreenPosition( e ), 2 ) ) { |
55 | | - clearTimeout( surfaceView.mouse.timer ); |
56 | | - surfaceView.mouse.timer = null; |
57 | | - return surfaceView.onMouseDown( e, 3 ); |
58 | | - } else { |
59 | | - surfaceView.mouse.delta = new Date().getTime() - surfaceView.mouse.clickTime; |
60 | | - surfaceView.mouse.clickTime += surfaceView.mouse.delta; |
61 | | - return surfaceView.onMouseDown( e, 1 ); |
62 | | - } |
63 | | - } |
64 | | - }, |
65 | | - 'dblclick' : function(e) { |
66 | | - if ( e.button === 0 ) { |
67 | | - surfaceView.mouse.timer = setTimeout( function () { |
68 | | - surfaceView.mouse.timer = null; |
69 | | - }, surfaceView.mouse.delta * 1.25 ); |
70 | | - surfaceView.mouse.clickPosition = es.Position.newFromEventScreenPosition( e ); |
71 | | - return surfaceView.onMouseDown( e, 2 ); |
72 | | - } |
| 53 | + return surfaceView.onMouseDown( e ); |
73 | 54 | } |
74 | 55 | } ); |
75 | 56 | |
— | — | @@ -128,42 +109,43 @@ |
129 | 110 | this.documentView.on('update', function() {alert(1);}); |
130 | 111 | }; |
131 | 112 | |
132 | | -es.SurfaceView.prototype.onMouseDown = function( e, clicks ) { |
133 | | - switch ( clicks ) { |
134 | | - case 1: |
135 | | - this.mouse.selecting = true; |
136 | | - this.selection.to = this.documentView.getOffsetFromEvent( e ); |
137 | | - |
138 | | - if ( this.keyboard.keys.shift ) { |
| 113 | +es.SurfaceView.prototype.onMouseDown = function( e ) { |
| 114 | + if ( e.button === 0 ) { |
| 115 | + switch ( e.originalEvent.detail ) { |
| 116 | + case 1: // single click |
| 117 | + this.mouse.selecting = true; |
| 118 | + this.selection.to = this.documentView.getOffsetFromEvent( e ); |
| 119 | + if ( this.keyboard.keys.shift ) { |
| 120 | + this.documentView.drawSelection( this.selection ); |
| 121 | + this.hideCursor(); |
| 122 | + } else { |
| 123 | + this.documentView.clearSelection(); |
| 124 | + this.selection.from = this.selection.to; |
| 125 | + var position = es.Position.newFromEventPagePosition( e ), |
| 126 | + nodeView = this.documentView.getNodeFromOffset( this.selection.to, false ); |
| 127 | + this.cursor.initialBias = position.left > nodeView.$.offset().left; |
| 128 | + this.showCursor(); |
| 129 | + } |
| 130 | + break; |
| 131 | + case 2: // double click |
| 132 | + this.selection = this.documentView.model.getWordBoundaries( |
| 133 | + this.documentView.getOffsetFromEvent( e ) |
| 134 | + ); |
139 | 135 | this.documentView.drawSelection( this.selection ); |
140 | 136 | this.hideCursor(); |
141 | | - } else { |
142 | | - this.documentView.clearSelection(); |
143 | | - this.selection.from = this.selection.to; |
144 | | - var position = es.Position.newFromEventPagePosition( e ), |
145 | | - nodeView = this.documentView.getNodeFromOffset( this.selection.to, false ); |
146 | | - this.cursor.initialBias = position.left > nodeView.$.offset().left; |
147 | | - this.showCursor(); |
148 | | - } |
149 | | - break; |
150 | | - case 2: |
151 | | - this.selection = this.documentView.model.getWordBoundaries( |
152 | | - this.documentView.getOffsetFromEvent( e ) |
153 | | - ); |
154 | | - this.documentView.drawSelection( this.selection ); |
155 | | - this.hideCursor(); |
156 | | - break; |
157 | | - case 3: |
158 | | - var node = this.documentView.getNodeFromOffset( |
159 | | - this.documentView.getOffsetFromEvent( e ) |
160 | | - ); |
161 | | - this.selection.from = this.documentView.getOffsetFromNode( node, false ); |
162 | | - this.selection.to = this.selection.from + node.getElementLength(); |
163 | | - this.documentView.drawSelection( this.selection ); |
164 | | - this.hideCursor(); |
165 | | - break; |
| 137 | + break; |
| 138 | + break; |
| 139 | + default: // 3 and more |
| 140 | + var node = this.documentView.getNodeFromOffset( |
| 141 | + this.documentView.getOffsetFromEvent( e ) |
| 142 | + ); |
| 143 | + this.selection.from = this.documentView.getOffsetFromNode( node, false ); |
| 144 | + this.selection.to = this.selection.from + node.getElementLength() - 1; |
| 145 | + this.documentView.drawSelection( this.selection ); |
| 146 | + this.hideCursor(); |
| 147 | + break; |
| 148 | + } |
166 | 149 | } |
167 | | - |
168 | 150 | if ( !this.$input.is( ':focus' ) ) { |
169 | 151 | this.$input.focus().select(); |
170 | 152 | } |