Fix context icon update method

Change-Id: I1100e53a0bf4364d6435f648b06ce0be7851e8db
This commit is contained in:
Rob Moen 2012-06-14 21:06:16 -07:00
parent 6b2fb7b2e0
commit b31a25c12c

View file

@ -145,26 +145,23 @@ ve.ce.Surface.prototype.clearPollData = function() {
}; };
ve.ce.Surface.prototype.onSelect = function( range ) { ve.ce.Surface.prototype.onSelect = function( range ) {
var _this = this; var _this = this,
var oldSelection = this.model.getSelection(); selection = this.model.getSelection();
if ( this.selectionInterval === null ) { function update() {
this.selectionInterval = setInterval( check, 500 ); if ( _this.contextView ) {
} if ( selection.getLength() > 0 ) {
_this.contextView.set();
function check(){ } else {
var newSelection = _this.model.getSelection(); _this.contextView.clear();
}
if ( ve.compareObjects( oldSelection, newSelection) ) {
_this.contextView.set();
clearInterval( _this.selectionInterval );
} }
if ( newSelection.getLength() === 0 ) { _this.updateSelectionTimeout = undefined;
_this.contextView.clear();
clearInterval( _this.selectionInterval );
}
} }
if ( this.updateSelectionTimeout !== undefined ) {
return;
}
this.updateSelectionTimeout = setTimeout( update, 750 );
}; };
ve.ce.Surface.prototype.onTransact = function( tx ) { ve.ce.Surface.prototype.onTransact = function( tx ) {