Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | this.model = model; |
18 | 18 | this.selection = new es.Range(); |
19 | 19 | this.previousSelection = null; |
| 20 | + this.mac = navigator.userAgent.match(/mac/i) ? true : false; |
20 | 21 | |
21 | 22 | this.model.getDocument().on( 'update', function() { |
22 | 23 | _this.emit( 'update' ); |
— | — | @@ -65,9 +66,9 @@ |
66 | 67 | keydownTimeout: null, |
67 | 68 | keys: { |
68 | 69 | shift: false, |
69 | | - control: false, |
70 | | - command: false, |
71 | | - alt: false |
| 70 | + //control: false, |
| 71 | + //command: false, |
| 72 | + //alt: false |
72 | 73 | } |
73 | 74 | }; |
74 | 75 | |
— | — | @@ -251,15 +252,15 @@ |
252 | 253 | this.keyboard.selecting = true; |
253 | 254 | break; |
254 | 255 | case 17: // Control |
255 | | - this.keyboard.keys.control = true; |
| 256 | + //this.keyboard.keys.control = true; |
256 | 257 | break; |
257 | 258 | case 18: // Alt |
258 | | - this.keyboard.keys.alt = true; |
| 259 | + //this.keyboard.keys.alt = true; |
259 | 260 | break; |
260 | 261 | case 91: // Left Command in WebKit |
261 | 262 | case 93: // Right Command in WebKit |
262 | 263 | case 224: // Command in FireFox |
263 | | - this.keyboard.keys.command = true; |
| 264 | + //this.keyboard.keys.command = true; |
264 | 265 | break; |
265 | 266 | case 36: // Home |
266 | 267 | this.moveCursor( 'left', 'line' ); |
— | — | @@ -268,36 +269,67 @@ |
269 | 270 | this.moveCursor( 'right', 'line' ); |
270 | 271 | break; |
271 | 272 | case 37: // Left arrow |
272 | | - if ( this.keyboard.keys.command ) { |
273 | | - this.moveCursor( 'left', 'line' ); |
274 | | - } else if ( this.keyboard.keys.control || this.keyboard.keys.alt ) { |
275 | | - this.moveCursor( 'left', 'word' ); |
| 273 | + if ( !this.mac ) { |
| 274 | + if ( e.ctrlKey ) { |
| 275 | + this.moveCursor( 'left', 'word' ); |
| 276 | + } else { |
| 277 | + this.moveCursor( 'left', 'char' ); |
| 278 | + } |
276 | 279 | } else { |
277 | | - this.moveCursor( 'left', 'char' ); |
| 280 | + if ( e.metaKey || e.ctrlKey ) { |
| 281 | + this.moveCursor( 'left', 'line' ); |
| 282 | + } else if ( e.altKey ) { |
| 283 | + this.moveCursor( 'left', 'word' ); |
| 284 | + } else { |
| 285 | + this.moveCursor( 'left', 'char' ); |
| 286 | + } |
278 | 287 | } |
279 | 288 | break; |
280 | 289 | case 38: // Up arrow |
281 | | - if ( this.keyboard.keys.control || this.keyboard.keys.alt ) { |
282 | | - this.moveCursor( 'up', 'unit' ); |
| 290 | + if ( !this.mac ) { |
| 291 | + if ( e.ctrlKey ) { |
| 292 | + this.moveCursor( 'up', 'unit' ); |
| 293 | + } else { |
| 294 | + this.moveCursor( 'up', 'char' ); |
| 295 | + } |
283 | 296 | } else { |
284 | | - this.moveCursor( 'up', 'char' ); |
| 297 | + if ( e.altKey ) { |
| 298 | + this.moveCursor( 'up', 'unit' ); |
| 299 | + } else { |
| 300 | + this.moveCursor( 'up', 'char' ); |
| 301 | + } |
285 | 302 | } |
286 | | - |
287 | 303 | break; |
288 | 304 | case 39: // Right arrow |
289 | | - if ( this.keyboard.keys.command ) { |
290 | | - this.moveCursor( 'right', 'line' ); |
291 | | - } else if ( this.keyboard.keys.control || this.keyboard.keys.alt ) { |
292 | | - this.moveCursor( 'right', 'word' ); |
| 305 | + if ( !this.mac ) { |
| 306 | + if ( e.ctrlKey ) { |
| 307 | + this.moveCursor( 'right', 'word' ); |
| 308 | + } else { |
| 309 | + this.moveCursor( 'right', 'char' ); |
| 310 | + } |
293 | 311 | } else { |
294 | | - this.moveCursor( 'right', 'char' ); |
| 312 | + if ( e.metaKey || e.ctrlKey ) { |
| 313 | + this.moveCursor( 'right', 'line' ); |
| 314 | + } else if ( e.altKey ) { |
| 315 | + this.moveCursor( 'right', 'word' ); |
| 316 | + } else { |
| 317 | + this.moveCursor( 'right', 'char' ); |
| 318 | + } |
295 | 319 | } |
296 | 320 | break; |
297 | 321 | case 40: // Down arrow |
298 | | - if ( this.keyboard.keys.control || this.keyboard.keys.alt ) { |
299 | | - this.moveCursor( 'down', 'unit' ); |
| 322 | + if ( !this.mac ) { |
| 323 | + if ( e.ctrlKey ) { |
| 324 | + this.moveCursor( 'down', 'unit' ); |
| 325 | + } else { |
| 326 | + this.moveCursor( 'down', 'char' ); |
| 327 | + } |
300 | 328 | } else { |
301 | | - this.moveCursor( 'down', 'char' ); |
| 329 | + if ( e.altKey ) { |
| 330 | + this.moveCursor( 'down', 'unit' ); |
| 331 | + } else { |
| 332 | + this.moveCursor( 'down', 'char' ); |
| 333 | + } |
302 | 334 | } |
303 | 335 | break; |
304 | 336 | case 8: // Backspace |
— | — | @@ -347,15 +379,15 @@ |
348 | 380 | } |
349 | 381 | break; |
350 | 382 | case 17: // Control |
351 | | - this.keyboard.keys.control = false; |
| 383 | + //this.keyboard.keys.control = false; |
352 | 384 | break; |
353 | 385 | case 18: // Alt |
354 | | - this.keyboard.keys.alt = false; |
| 386 | + //this.keyboard.keys.alt = false; |
355 | 387 | break; |
356 | 388 | case 91: // Left Command in WebKit |
357 | 389 | case 93: // Right Command in WebKit |
358 | 390 | case 224: // Command in FireFox |
359 | | - this.keyboard.keys.command = false; |
| 391 | + //this.keyboard.keys.command = false; |
360 | 392 | break; |
361 | 393 | default: |
362 | 394 | break; |