[OpenLayers-Commits] r11818 - in sandbox/tschaub/canvas: .
lib/OpenLayers/Handler lib/OpenLayers/Strategy tests/Handler
tests/Strategy
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Mar 30 19:38:32 EDT 2011
Author: tschaub
Date: 2011-03-30 16:38:31 -0700 (Wed, 30 Mar 2011)
New Revision: 11818
Modified:
sandbox/tschaub/canvas/
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Drag.js
sandbox/tschaub/canvas/lib/OpenLayers/Strategy/Filter.js
sandbox/tschaub/canvas/tests/Handler/Click.html
sandbox/tschaub/canvas/tests/Handler/Drag.html
sandbox/tschaub/canvas/tests/Strategy/Filter.html
Log:
Merge r11803:11817 from trunk.
Property changes on: sandbox/tschaub/canvas
___________________________________________________________________
Modified: svn:mergeinfo
- /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:10737-11416,11422-11762,11766-11802
+ /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:10737-11416,11422-11762,11766-11817
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js 2011-03-30 23:38:31 UTC (rev 11818)
@@ -515,6 +515,8 @@
this.clearTimer();
this.down = null;
this.first = null;
+ this.last = null;
+ this.touch = false;
deactivated = true;
}
return deactivated;
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Handler/Drag.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Drag.js 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Drag.js 2011-03-30 23:38:31 UTC (rev 11818)
@@ -145,6 +145,7 @@
};
}
},
+
/**
* Method: dragstart
@@ -507,6 +508,7 @@
deactivate: function() {
var deactivated = false;
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
+ this.touch = false;
this.started = false;
this.dragging = false;
this.start = null;
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Strategy/Filter.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Strategy/Filter.js 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Strategy/Filter.js 2011-03-30 23:38:31 UTC (rev 11818)
@@ -138,17 +138,19 @@
// cache now contains features to remove from layer
if (this.cache.length > 0) {
this.caching = true;
- this.layer.removeFeatures(this.cache.slice(), {silent: true});
+ this.layer.removeFeatures(this.cache.slice());
this.caching = false;
}
// now look through previous cache for features to add to layer
if (previousCache.length > 0) {
var event = {features: previousCache};
this.handleAdd(event);
- // event has features to add to layer
- this.caching = true;
- this.layer.addFeatures(event.features, {silent: true});
- this.caching = false;
+ if (event.features.length > 0) {
+ // event has features to add to layer
+ this.caching = true;
+ this.layer.addFeatures(event.features);
+ this.caching = false;
+ }
}
},
Modified: sandbox/tschaub/canvas/tests/Handler/Click.html
===================================================================
--- sandbox/tschaub/canvas/tests/Handler/Click.html 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/tests/Handler/Click.html 2011-03-30 23:38:31 UTC (rev 11818)
@@ -410,7 +410,7 @@
}
function test_Handler_Click_deactivate(t) {
- t.plan(4);
+ t.plan(6);
var control = {
map: new OpenLayers.Map('map')
};
@@ -422,6 +422,8 @@
handler.active = true;
handler.down = true;
handler.timerId = true;
+ handler.touch = true;
+ handler.last = true;
deactivated = handler.deactivate();
t.ok(deactivated,
"deactivate returns true if the handler was active already");
@@ -429,6 +431,11 @@
"deactivate sets down to null");
t.eq(handler.timerId, null,
"deactivate sets timerId to null");
+ t.eq(handler.touch, false,
+ "deactivate sets touch to false");
+ t.eq(handler.last, null,
+ "deactivate sets last to null");
+
}
function test_Handler_Click_mouseup(t) {
Modified: sandbox/tschaub/canvas/tests/Handler/Drag.html
===================================================================
--- sandbox/tschaub/canvas/tests/Handler/Drag.html 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/tests/Handler/Drag.html 2011-03-30 23:38:31 UTC (rev 11818)
@@ -416,7 +416,7 @@
}
function test_Handler_Drag_deactivate(t) {
- t.plan(6);
+ t.plan(7);
var map = new OpenLayers.Map('map');
var control = new OpenLayers.Control();
map.addControl(control);
@@ -427,6 +427,7 @@
"deactivate returns false if the handler was not already active");
handler.active = true;
handler.dragging = true;
+ handler.touch = true;
deactivated = handler.deactivate();
t.ok(deactivated,
"deactivate returns true if the handler was active already");
@@ -437,7 +438,9 @@
t.ok(handler.start == null,
"deactivate sets start to null");
t.ok(handler.last == null,
- "deactivate sets start to null");
+ "deactivate sets last to null");
+ t.ok(!handler.touch,
+ "deactivate sets touch to false");
}
function test_interval_timer_after_mouseup(t) {
Modified: sandbox/tschaub/canvas/tests/Strategy/Filter.html
===================================================================
--- sandbox/tschaub/canvas/tests/Strategy/Filter.html 2011-03-30 23:35:42 UTC (rev 11817)
+++ sandbox/tschaub/canvas/tests/Strategy/Filter.html 2011-03-30 23:38:31 UTC (rev 11818)
@@ -70,7 +70,7 @@
function test_setFilter(t) {
- t.plan(7);
+ t.plan(13);
var strategy = new OpenLayers.Strategy.Filter({filter: filter});
var layer = new OpenLayers.Layer.Vector(null, {
@@ -84,24 +84,43 @@
center: new OpenLayers.LonLat(0, 0),
zoom: 1
});
+
+ var log = [];
+ layer.events.on({
+ beforefeaturesadded: function(event) {
+ log.push(event.type);
+ },
+ beforefeaturesremoved: function(event) {
+ log.push(event.type);
+ }
+ })
- // add all features
+ // a) add all features
+ log = [];
layer.addFeatures(features);
- t.eq(features.length, 20, "collection of 20 features")
- t.eq(layer.features.length, 10, "layer got 10 with filter 'index < 10'");
- t.eq(strategy.cache.length, 10, "strategy cached 10 with filter 'index < 10'");
+ t.eq(features.length, 20, "a) collection of 20 features")
+ t.eq(layer.features.length, 10, "a) layer got 10 with filter 'index < 10'");
+ t.eq(strategy.cache.length, 10, "a) strategy cached 10 with filter 'index < 10'");
+ t.eq(log.length, 1, "a) one event logged");
+ t.eq(log[0], "beforefeaturesadded", "a) beforefeaturesadded fired");
- // update filter
+ // b) update filter
+ log = [];
filter.value = 5;
strategy.setFilter(filter);
- t.eq(layer.features.length, 5, "layer got 5 with filter 'index < 5'");
- t.eq(strategy.cache.length, 15, "strategy cached 15 with filter 'index < 5'");
+ t.eq(layer.features.length, 5, "b) layer got 5 with filter 'index < 5'");
+ t.eq(strategy.cache.length, 15, "b) strategy cached 15 with filter 'index < 5'");
+ t.eq(log.length, 1, "b) one event logged");
+ t.eq(log[0], "beforefeaturesremoved", "b) beforefeaturesremoved fired");
- // update filter
+ // c) update filter
+ log = [];
filter.value = 15;
strategy.setFilter(filter);
- t.eq(layer.features.length, 15, "layer got 15 with filter 'index < 15'");
- t.eq(strategy.cache.length, 5, "strategy cached 5 with filter 'index < 15'");
+ t.eq(layer.features.length, 15, "c) layer got 15 with filter 'index < 15'");
+ t.eq(strategy.cache.length, 5, "c) strategy cached 5 with filter 'index < 15'");
+ t.eq(log.length, 1, "c) one event logged");
+ t.eq(log[0], "beforefeaturesadded", "c) beforefeaturesadded fired");
map.destroy();
More information about the Commits
mailing list