From d5d21b1e71b70d5d578cd1a4b5575b194555d104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Wed, 30 Mar 2011 14:17:13 +0000 Subject: [PATCH] remove dependency on AnchoredBubble and Marker from Feature. r=marcjansen,bartvde,erilem (closes #1633) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11790 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Feature.js | 23 ++++++++++------------- tests/Feature.html | 11 ++++++++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 092c9c04eb..f921bc4325 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -7,8 +7,6 @@ /** * @requires OpenLayers/BaseTypes/Class.js * @requires OpenLayers/Util.js - * @requires OpenLayers/Marker.js - * @requires OpenLayers/Popup/AnchoredBubble.js */ /** @@ -53,7 +51,7 @@ OpenLayers.Feature = OpenLayers.Class({ * {} The class which will be used to instantiate * a new Popup. Default is . */ - popupClass: OpenLayers.Popup.AnchoredBubble, + popupClass: null, /** * Property: popup @@ -187,17 +185,16 @@ OpenLayers.Feature = OpenLayers.Class({ createPopup: function(closeBox) { if (this.lonlat != null) { - - var id = this.id + "_popup"; - var anchor = (this.marker) ? this.marker.icon : null; - if (!this.popup) { - this.popup = new this.popupClass(id, - this.lonlat, - this.data.popupSize, - this.data.popupContentHTML, - anchor, - closeBox); + var anchor = (this.marker) ? this.marker.icon : null; + var popupClass = this.popupClass ? + this.popupClass : OpenLayers.Popup.AnchoredBubble; + this.popup = new popupClass(this.id + "_popup", + this.lonlat, + this.data.popupSize, + this.data.popupContentHTML, + anchor, + closeBox); } if (this.data.overflow != null) { this.popup.contentDiv.style.overflow = this.data.overflow; diff --git a/tests/Feature.html b/tests/Feature.html index f4cc24a4c9..688642f4f5 100644 --- a/tests/Feature.html +++ b/tests/Feature.html @@ -7,7 +7,7 @@ var feature, layer; function test_Feature_constructor (t) { - t.plan( 7 ); + t.plan( 6 ); var layer = {}; var lonlat = new OpenLayers.LonLat(2,1); @@ -26,11 +26,10 @@ t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" ); t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" ); t.ok( feature.data.iconSize.equals(iconSize), "feature.data.iconSize set correctly" ); - t.ok( feature.popupClass == OpenLayers.Popup.AnchoredBubble, "default popupClass is AnchoredBubble"); } function test_Feature_createPopup (t) { - t.plan(1); + t.plan(3); var layer = {}; var lonlat = new OpenLayers.LonLat(2,1); var iconURL = 'http://boston.openguides.org/features/ORANGE.png'; @@ -45,6 +44,12 @@ //Safari 3 separates style overflow into overflow-x and overflow-y var prop = (OpenLayers.BROWSER_NAME == 'safari') ? 'overflowX' : 'overflow'; t.eq(popup.contentDiv.style[prop], "auto", 'overflow on popup is correct'); + t.ok( popup instanceof OpenLayers.Popup.AnchoredBubble, "popup is an AnchoredBubble by defaults"); + feature.destroyPopup(); + + feature.popupClass = OpenLayers.Popup.FramedCloud; + popup = feature.createPopup(); + t.ok( popup instanceof OpenLayers.Popup.FramedCloud, "setting feature.popupClass works"); } function test_Feature_createMarker (t) { t.plan(1);