Remove recently introduced code blocks for small conditional statements.

This commit is contained in:
Jürg Lehni 2011-05-15 17:59:37 +01:00
parent 40c988b313
commit 6e0e31480a

View file

@ -25,9 +25,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
this._firstMove = true; this._firstMove = true;
this._count = 0; this._count = 0;
this._downCount = 0; this._downCount = 0;
for (var i in handlers) { for (var i in handlers)
this[i] = handlers[i]; this[i] = handlers[i];
}
}, },
/** /**
@ -59,10 +58,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
}, },
getFixedDistance: function() { getFixedDistance: function() {
if (this._minDistance == this._maxDistance) { return this._minDistance == this._maxDistance
return this._minDistance; ? this._minDistance : null;
}
return null;
}, },
setFixedDistance: function(distance) { setFixedDistance: function(distance) {
@ -77,9 +74,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
var minDist = minDistance != null ? minDistance : 0; var minDist = minDistance != null ? minDistance : 0;
var vector = pt.subtract(this._point); var vector = pt.subtract(this._point);
var distance = vector.getLength(); var distance = vector.getLength();
if (distance < minDist) { if (distance < minDist)
return false; return false;
}
// Produce a new point on the way to pt if pt is further away // Produce a new point on the way to pt if pt is further away
// than maxDistance // than maxDistance
var maxDist = maxDistance != null ? maxDistance : 0; var maxDist = maxDistance != null ? maxDistance : 0;
@ -91,9 +87,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
} }
} }
} }
if (needsChange && pt.equals(this._point)) { if (needsChange && pt.equals(this._point))
return false; return false;
}
} }
this._lastPoint = this._point; this._lastPoint = this._point;
this._point = pt; this._point = pt;
@ -118,9 +113,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
switch (type) { switch (type) {
case 'mousedown': case 'mousedown':
this.updateEvent(type, pt, null, null, true, false, false); this.updateEvent(type, pt, null, null, true, false, false);
if (this.onMouseDown) { if (this.onMouseDown)
this.onMouseDown(new ToolEvent(this, type, event)); this.onMouseDown(new ToolEvent(this, type, event));
}
break; break;
case 'mousedrag': case 'mousedrag':
// In order for idleInterval drag events to work, we need to not // In order for idleInterval drag events to work, we need to not
@ -135,9 +129,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
matchMaxDistance = false; matchMaxDistance = false;
while (this.updateEvent(type, pt, this.minDistance, while (this.updateEvent(type, pt, this.minDistance,
this.maxDistance, false, needsChange, matchMaxDistance)) { this.maxDistance, false, needsChange, matchMaxDistance)) {
if (this.onMouseDrag) { if (this.onMouseDrag)
this.onMouseDrag(new ToolEvent(this, type, event)); this.onMouseDrag(new ToolEvent(this, type, event));
}
needsChange = true; needsChange = true;
matchMaxDistance = true; matchMaxDistance = true;
} }
@ -148,15 +141,13 @@ var ToolHandler = this.ToolHandler = Base.extend({
if ((this._point.x != pt.x || this._point.y != pt.y) if ((this._point.x != pt.x || this._point.y != pt.y)
&& this.updateEvent('mousedrag', pt, this.minDistance, && this.updateEvent('mousedrag', pt, this.minDistance,
this.maxDistance, false, false, false)) { this.maxDistance, false, false, false)) {
if (this.onMouseDrag) { if (this.onMouseDrag)
this.onMouseDrag(new ToolEvent(this, type, event)); this.onMouseDrag(new ToolEvent(this, type, event));
}
} }
this.updateEvent(type, pt, null, this.maxDistance, false, this.updateEvent(type, pt, null, this.maxDistance, false,
false, false); false, false);
if (this.onMouseUp) { if (this.onMouseUp)
this.onMouseUp(new ToolEvent(this, type, event)); this.onMouseUp(new ToolEvent(this, type, event));
}
// Start with new values for 'mousemove' // Start with new values for 'mousemove'
this.updateEvent(type, pt, null, null, true, false, false); this.updateEvent(type, pt, null, null, true, false, false);
this._firstMove = true; this._firstMove = true;
@ -164,9 +155,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
case 'mousemove': case 'mousemove':
while (this.updateEvent(type, pt, this.minDistance, while (this.updateEvent(type, pt, this.minDistance,
this.maxDistance, this._firstMove, true, false)) { this.maxDistance, this._firstMove, true, false)) {
if (this.onMouseMove) { if (this.onMouseMove)
this.onMouseMove(new ToolEvent(this, type, event)); this.onMouseMove(new ToolEvent(this, type, event));
}
this._firstMove = false; this._firstMove = false;
} }
break; break;