give a popup that is created by a feature a reference back to that feature. thanks a million to tschaub for the lightning and helpful review (Closes #949)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4134 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -185,6 +185,7 @@ OpenLayers.Feature = OpenLayers.Class({
|
||||
this.data.popupContentHTML,
|
||||
anchor,
|
||||
closeBox);
|
||||
this.popup.feature = this;
|
||||
}
|
||||
return this.popup;
|
||||
},
|
||||
@@ -198,6 +199,7 @@ OpenLayers.Feature = OpenLayers.Class({
|
||||
* should also be able to override the destruction
|
||||
*/
|
||||
destroyPopup: function() {
|
||||
this.popup.feature = null;
|
||||
this.popup.destroy()
|
||||
},
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
}
|
||||
|
||||
function test_04_Feature_createPopup(t) {
|
||||
t.plan(15);
|
||||
t.plan(17);
|
||||
|
||||
//no lonlat
|
||||
var f = {
|
||||
@@ -144,6 +144,7 @@
|
||||
ret = OpenLayers.Feature.prototype.createPopup.apply(f, [g_CloseBox]);
|
||||
|
||||
t.ok((ret == f.popup) && (f.popup != null), "a valid popup has been set and returned")
|
||||
t.ok( f.popup.feature == f, "popup's 'feature' property correctly set");
|
||||
|
||||
|
||||
//valid lonlat with anchor
|
||||
@@ -154,13 +155,15 @@
|
||||
g_ExpectedAnchor = f.marker.icon;
|
||||
ret = OpenLayers.Feature.prototype.createPopup.apply(f, [g_CloseBox]);
|
||||
t.ok((ret == f.popup) && (f.popup != null), "a valid popup has been set and returned")
|
||||
t.ok( f.popup.feature == f, "popup's 'feature' property correctly set");
|
||||
}
|
||||
|
||||
function test_04_Feature_destroyPopup(t) {
|
||||
t.plan(1);
|
||||
t.plan(2);
|
||||
|
||||
var f = {
|
||||
'popup': {
|
||||
'feature': {},
|
||||
'destroy': function() {
|
||||
t.ok(true, "default destroyPopup() calls popup.destroy");
|
||||
}
|
||||
@@ -168,6 +171,7 @@
|
||||
};
|
||||
|
||||
OpenLayers.Feature.prototype.destroyPopup.apply(f, []);
|
||||
t.ok(f.popup.feature == null, "popup's 'feature' property nullified on destroy");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user