Introduced method replacePhantoms in ve.ce.Surface in order to avoid accessing ve.ce.Surface local variable ($phantoms) from ve.ce.AlienNode

Change-Id: I9754d98175c7353f6db5306bc2ce35d6c57fdedb
This commit is contained in:
Inez Korczyński 2013-01-17 17:02:02 -08:00
parent 4aeb00dcbc
commit 94642c797d
2 changed files with 13 additions and 3 deletions

View file

@ -73,7 +73,7 @@ ve.ce.AlienNode.prototype.onMouseEnter = function () {
} )
);
} );
surface.$phantoms.empty().append( $phantoms );
surface.replacePhantoms( $phantoms );
surface.$.on( 'mousemove.phantoms', ve.bind( this.onSurfaceMouseMove, this ) );
};
@ -122,7 +122,7 @@ ve.ce.AlienNode.prototype.onSurfaceMouseMove = function ( e ) {
$target.closest( '.ve-ce-alienNode' ).length === 0
) {
surface = this.root.getSurface();
surface.$phantoms.empty();
surface.replacePhantoms( null );
surface.$.unbind( 'mousemove.phantoms' );
}
};

View file

@ -1194,6 +1194,16 @@ ve.ce.Surface.prototype.showSelection = function ( range ) {
}
};
/**
* Append passed phantoms to phantoms container after emptying it first.
*
* @method
* @param {jQuery} $phantoms Phantoms to append
*/
ve.ce.Surface.prototype.replacePhantoms = function( $phantoms ) {
this.$phantoms.empty().append( $phantoms );
};
/*! Helpers */
/**
@ -1443,4 +1453,4 @@ ve.ce.Surface.prototype.enableRendering = function () {
*/
ve.ce.Surface.prototype.disableRendering = function () {
this.renderingEnabled = false;
};
};