diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 6132023329..2004a45591 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -185,6 +185,11 @@ OpenLayers.Feature = OpenLayers.Class({ this.data.popupContentHTML, anchor, closeBox); + + if (this.data.overflow != null) { + this.popup.contentDiv.style.overflow = this.data.overflow; + } + this.popup.feature = this; } return this.popup; diff --git a/lib/OpenLayers/Layer/Text.js b/lib/OpenLayers/Layer/Text.js index f1c13bbd25..f5dc0135f6 100644 --- a/lib/OpenLayers/Layer/Text.js +++ b/lib/OpenLayers/Layer/Text.js @@ -84,7 +84,7 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, { var vals = currLine.split('\t'); var location = new OpenLayers.LonLat(0,0); var title; var url; - var icon, iconSize, iconOffset; + var icon, iconSize, iconOffset, overflow; var set = false; for (var valIndex = 0; valIndex < vals.length; valIndex++) { if (vals[valIndex]) { @@ -116,7 +116,9 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, { title = vals[valIndex]; } else if (columns[valIndex] == 'description') { description = vals[valIndex]; - } + } else if (columns[valIndex] == 'overflow') { + overflow = vals[valIndex]; + } } } if (set) { @@ -139,6 +141,9 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, { if ((title != null) && (description != null)) { data['popupContentHTML'] = '
'+description+'
'; } + + data['overflow'] = overflow || "auto"; + var feature = new OpenLayers.Feature(this, location, data); this.features.push(feature); var marker = feature.createMarker(); diff --git a/tests/Layer/test_Text.html b/tests/Layer/test_Text.html index 014d71a129..1e54803e01 100644 --- a/tests/Layer/test_Text.html +++ b/tests/Layer/test_Text.html @@ -8,11 +8,13 @@ var datafile = "./data_Layer_Text_textfile.txt"; var datafile2 = "./data_Layer_Text_textfile_2.txt"; + var datafile_overflow = "./data_Layer_Text_textfile_overflow.txt"; // if this test is running in IE, different rules apply if (isMSIE) { datafile = "." + datafile; datafile2 = "." + datafile2; + datafile_overflow = "." + datafile_overflow; } function test_01_Layer_Text_constructor (t) { @@ -56,7 +58,7 @@ });; } function test_03_Layer_Text_events (t) { - t.plan( 4 ); + t.plan( 5 ); layer = new OpenLayers.Layer.Text('Test Layer', { location: datafile2 }); var map = new OpenLayers.Map('map'); var baseLayer = new OpenLayers.Layer.WMS("Test Layer", @@ -73,6 +75,27 @@ t.eq(map.popups.length, 1, "Popup opened correctly"); layer.markers[1].events.triggerEvent('click', event); t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly"); + t.eq(map.popups[0].contentDiv.style.overflow,"auto", "default Popup overflow correct"); + }); + } + function test_03_Layer_Text_overflow (t) { + t.plan( 4 ); + layer = new OpenLayers.Layer.Text('Test Layer', { location: datafile_overflow }); + var map = new OpenLayers.Map('map'); + var baseLayer = new OpenLayers.Layer.WMS("Test Layer", + "http://octo.metacarta.com/cgi-bin/mapserv?", + {map: "/mapdata/vmap_wms.map", layers: "basic"}); + map.addLayer(baseLayer); + map.addLayer(layer); + map.setCenter(new OpenLayers.LonLat(0,0),0); + var event = {}; + t.delay_call( 1, function() { + layer.markers[0].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "Popup opened correctly"); + t.eq(map.popups[0].contentDiv.style.overflow,"auto", "Popup overflow read from file"); + layer.markers[1].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly"); + t.eq(map.popups[0].contentDiv.style.overflow,"hidden", "Popup overflow read from file"); }); } function test_04_Layer_Text_events_nopopups (t) { diff --git a/tests/data_Layer_Text_textfile_overflow.txt b/tests/data_Layer_Text_textfile_overflow.txt new file mode 100644 index 0000000000..bb4768ec51 --- /dev/null +++ b/tests/data_Layer_Text_textfile_overflow.txt @@ -0,0 +1,3 @@ +overflow point title description image +auto 10,20 a b http://boston.openguides.org/markers/ORANGE.png +hidden 15,25 c d http://boston.openguides.org/markers/ORANGE.png diff --git a/tests/test_Feature.html b/tests/test_Feature.html index 58894a3c5b..7ce4d3f1c3 100644 --- a/tests/test_Feature.html +++ b/tests/test_Feature.html @@ -28,6 +28,21 @@ t.ok( feature.popupClass == OpenLayers.Popup.AnchoredBubble, "default popupClass is AnchoredBubble"); } + function test_02_Feature_createPopup (t) { + t.plan(1); + var layer = {}; + var lonlat = new OpenLayers.LonLat(2,1); + var iconURL = 'http://boston.openguides.org/features/ORANGE.png'; + var iconSize = new OpenLayers.Size(12, 17); + var data = { iconURL: iconURL, + iconSize: iconSize, + 'overflow':'auto' + }; + + feature = new OpenLayers.Feature(layer, lonlat, data); + popup = feature.createPopup(); + t.eq(popup.contentDiv.style.overflow, "auto", 'overflow on popup is correct'); + } function test_02_Feature_createMarker (t) { t.plan(1); t.ok(true);