From 2d9c5d56285b90a093b7fcc6f8e32035049da945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inez=20Korczyn=CC=81ski?= Date: Tue, 19 Feb 2013 14:14:41 -0800 Subject: [PATCH] Very small cleanup of onCut method in ve.ce.Surface. Use ve.bind in order to change context within which callback is called - reduces a need of introducing new local variable. Change-Id: I75ece695548c87073dd22e5e7ec80057d7132d22 --- modules/ve/ce/ve.ce.Surface.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 776b38e576..7812ab67d9 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -371,28 +371,22 @@ ve.ce.Surface.prototype.onDocumentKeyUp = function ( e ) { * @param {jQuery.Event} e */ ve.ce.Surface.prototype.onCut = function ( e ) { - var surface = this; - this.surfaceObserver.stop(); - this.onCopy( e ); - - setTimeout( function () { - var selection, - tx; + setTimeout( ve.bind( function () { + var selection, tx; // We don't like how browsers cut, so let's undo it and do it ourselves. document.execCommand( 'undo', false, false ); - - selection = surface.model.getSelection(); + selection = this.model.getSelection(); // Transact - tx = ve.dm.Transaction.newFromRemoval( surface.documentView.model, selection ); - surface.model.change( tx, new ve.Range( selection.start ) ); + tx = ve.dm.Transaction.newFromRemoval( this.documentView.model, selection ); - surface.surfaceObserver.clear(); - surface.surfaceObserver.start(); - }, 1 ); + this.model.change( tx, new ve.Range( selection.start ) ); + this.surfaceObserver.clear(); + this.surfaceObserver.start(); + }, this ), 1 ); }; /**