mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
Fix context icon update method
Change-Id: I1100e53a0bf4364d6435f648b06ce0be7851e8db
This commit is contained in:
parent
6b2fb7b2e0
commit
b31a25c12c
|
@ -145,26 +145,23 @@ ve.ce.Surface.prototype.clearPollData = function() {
|
|||
};
|
||||
|
||||
ve.ce.Surface.prototype.onSelect = function( range ) {
|
||||
var _this = this;
|
||||
var oldSelection = this.model.getSelection();
|
||||
|
||||
if ( this.selectionInterval === null ) {
|
||||
this.selectionInterval = setInterval( check, 500 );
|
||||
}
|
||||
|
||||
function check(){
|
||||
var newSelection = _this.model.getSelection();
|
||||
|
||||
if ( ve.compareObjects( oldSelection, newSelection) ) {
|
||||
_this.contextView.set();
|
||||
clearInterval( _this.selectionInterval );
|
||||
var _this = this,
|
||||
selection = this.model.getSelection();
|
||||
|
||||
function update() {
|
||||
if ( _this.contextView ) {
|
||||
if ( selection.getLength() > 0 ) {
|
||||
_this.contextView.set();
|
||||
} else {
|
||||
_this.contextView.clear();
|
||||
}
|
||||
}
|
||||
if ( newSelection.getLength() === 0 ) {
|
||||
_this.contextView.clear();
|
||||
clearInterval( _this.selectionInterval );
|
||||
}
|
||||
|
||||
_this.updateSelectionTimeout = undefined;
|
||||
}
|
||||
if ( this.updateSelectionTimeout !== undefined ) {
|
||||
return;
|
||||
}
|
||||
this.updateSelectionTimeout = setTimeout( update, 750 );
|
||||
};
|
||||
|
||||
ve.ce.Surface.prototype.onTransact = function( tx ) {
|
||||
|
|
Loading…
Reference in a new issue