Skip to content

Commit

Permalink
Fix bugs on silent selection and setSelectionByIds method
Browse files Browse the repository at this point in the history
  • Loading branch information
jorix committed May 1, 2012
1 parent 85c8082 commit 521aeac
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/FeaturePopups.js
Expand Up @@ -258,6 +258,13 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
*/
safeSelection: false,

/**
* Property: silentSelection
* {Boolean} Suppress "selectionchanged" event triggering during a selection
* process, internal use only.
*/
silentSelection: false,

/**
* Property: refreshDelay
* {Number} Number of accepted milliseconds of waiting between removing and
Expand Down Expand Up @@ -1128,6 +1135,7 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
savedSF[featureIds[i]] = true;
}
this.refreshSelection(foundLayer[0], silent);
this.layerObjs[layerId].selection = savedSF;
}
},

Expand All @@ -1140,6 +1148,7 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
selectCtl = this.controls.select,
_indexOf = OpenLayers.Util.indexOf,
features = layer.features;
this.silentSelection = !!silent;
this.selectingSet = true;
this.updatingSelection = true;
for (var i = 0 , len = features.length; i <len; i++) {
Expand Down Expand Up @@ -1173,7 +1182,8 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
}
this.selectingSet = false;
this.updatingSelection = false;
this.showAllSelectedFeatures(silent);
this.showAllSelectedFeatures();
this.silentSelection = false;
},

/**
Expand Down Expand Up @@ -1214,6 +1224,7 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
selectCtl = this.controls.select,
_indexOf = OpenLayers.Util.indexOf,
features = layer.selectedFeatures;
this.silentSelection = !!silent;
this.selectingSet = true;
this.updatingSelection = true;
for (var i = features.length-1; i >= 0; i--) {
Expand Down Expand Up @@ -1243,7 +1254,8 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
}
this.selectingSet = false;
this.updatingSelection = false;
this.showAllSelectedFeatures(silent);
this.showAllSelectedFeatures();
this.silentSelection = false;
},

/**
Expand Down Expand Up @@ -1321,11 +1333,8 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {

/**
* Method: showAllSelectedFeatures
*
* Parameters:
* silent - {Boolean} Supress "selectionchanged" event triggering. Default is false.
*/
showAllSelectedFeatures: function (silent) {
showAllSelectedFeatures: function () {
if (this.delayedRefresh !== null) {
window.clearTimeout(this.delayedRefresh);
this.delayedRefresh = null;
Expand Down Expand Up @@ -1354,7 +1363,7 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
invalid = true;
layerObj.selectionHash = "";
}
if (invalid && !silent) {
if (invalid && !this.silentSelection) {
layer.events.triggerEvent("selectionchanged", {
layer: layer,
selection: sFeatures
Expand All @@ -1364,7 +1373,7 @@ OpenLayers.Control.FeaturePopups = OpenLayers.Class(OpenLayers.Control, {
if (invalid) {
var feature,
response = false;
if (!silent) {
if (!this.silentSelection) {
this.events.triggerEvent("selectionchanged", {
selection: allSelFeatures
});
Expand Down

0 comments on commit 521aeac

Please sign in to comment.