Clear state of contextview when there is no selection length.

Make context update method work on single call

Change-Id: I2b7f3a31ea5ca1530f927a7e11827d583f134ffb
This commit is contained in:
Rob Moen 2012-06-14 21:13:59 -07:00
parent b31a25c12c
commit 6b8d8d24aa
2 changed files with 3 additions and 5 deletions

View file

@ -158,10 +158,7 @@ ve.ce.Surface.prototype.onSelect = function( range ) {
} }
_this.updateSelectionTimeout = undefined; _this.updateSelectionTimeout = undefined;
} }
if ( this.updateSelectionTimeout !== undefined ) { this.updateSelectionTimeout = setTimeout( update, 500 );
return;
}
this.updateSelectionTimeout = setTimeout( update, 750 );
}; };
ve.ce.Surface.prototype.onTransact = function( tx ) { ve.ce.Surface.prototype.onTransact = function( tx ) {

View file

@ -66,10 +66,11 @@ ve.ui.Toolbar.prototype.updateTools = function() {
}, startNode ); }, startNode );
} }
} }
// Update Context
if ( range.getLength() > 0 ) { if ( range.getLength() > 0 ) {
annotations = doc.getAnnotationsFromRange( range ); annotations = doc.getAnnotationsFromRange( range );
} else { } else {
// Clear context
_this.surfaceView.contextView.clear();
annotations = doc.getAnnotationsFromOffset( annotations = doc.getAnnotationsFromOffset(
doc.getNearestContentOffset( range.start - 1 ) doc.getNearestContentOffset( range.start - 1 )
); );