Adding Scroll Bars in TextFile Popup Windows via Layer.Text layer. (Closes #834)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4225 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -185,6 +185,11 @@ OpenLayers.Feature = OpenLayers.Class({
|
|||||||
this.data.popupContentHTML,
|
this.data.popupContentHTML,
|
||||||
anchor,
|
anchor,
|
||||||
closeBox);
|
closeBox);
|
||||||
|
|
||||||
|
if (this.data.overflow != null) {
|
||||||
|
this.popup.contentDiv.style.overflow = this.data.overflow;
|
||||||
|
}
|
||||||
|
|
||||||
this.popup.feature = this;
|
this.popup.feature = this;
|
||||||
}
|
}
|
||||||
return this.popup;
|
return this.popup;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
|||||||
var vals = currLine.split('\t');
|
var vals = currLine.split('\t');
|
||||||
var location = new OpenLayers.LonLat(0,0);
|
var location = new OpenLayers.LonLat(0,0);
|
||||||
var title; var url;
|
var title; var url;
|
||||||
var icon, iconSize, iconOffset;
|
var icon, iconSize, iconOffset, overflow;
|
||||||
var set = false;
|
var set = false;
|
||||||
for (var valIndex = 0; valIndex < vals.length; valIndex++) {
|
for (var valIndex = 0; valIndex < vals.length; valIndex++) {
|
||||||
if (vals[valIndex]) {
|
if (vals[valIndex]) {
|
||||||
@@ -116,7 +116,9 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
|||||||
title = vals[valIndex];
|
title = vals[valIndex];
|
||||||
} else if (columns[valIndex] == 'description') {
|
} else if (columns[valIndex] == 'description') {
|
||||||
description = vals[valIndex];
|
description = vals[valIndex];
|
||||||
}
|
} else if (columns[valIndex] == 'overflow') {
|
||||||
|
overflow = vals[valIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set) {
|
if (set) {
|
||||||
@@ -139,6 +141,9 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
|||||||
if ((title != null) && (description != null)) {
|
if ((title != null) && (description != null)) {
|
||||||
data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
|
data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data['overflow'] = overflow || "auto";
|
||||||
|
|
||||||
var feature = new OpenLayers.Feature(this, location, data);
|
var feature = new OpenLayers.Feature(this, location, data);
|
||||||
this.features.push(feature);
|
this.features.push(feature);
|
||||||
var marker = feature.createMarker();
|
var marker = feature.createMarker();
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
|
|
||||||
var datafile = "./data_Layer_Text_textfile.txt";
|
var datafile = "./data_Layer_Text_textfile.txt";
|
||||||
var datafile2 = "./data_Layer_Text_textfile_2.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 this test is running in IE, different rules apply
|
||||||
if (isMSIE) {
|
if (isMSIE) {
|
||||||
datafile = "." + datafile;
|
datafile = "." + datafile;
|
||||||
datafile2 = "." + datafile2;
|
datafile2 = "." + datafile2;
|
||||||
|
datafile_overflow = "." + datafile_overflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_01_Layer_Text_constructor (t) {
|
function test_01_Layer_Text_constructor (t) {
|
||||||
@@ -56,7 +58,7 @@
|
|||||||
});;
|
});;
|
||||||
}
|
}
|
||||||
function test_03_Layer_Text_events (t) {
|
function test_03_Layer_Text_events (t) {
|
||||||
t.plan( 4 );
|
t.plan( 5 );
|
||||||
layer = new OpenLayers.Layer.Text('Test Layer', { location: datafile2 });
|
layer = new OpenLayers.Layer.Text('Test Layer', { location: datafile2 });
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||||
@@ -73,6 +75,27 @@
|
|||||||
t.eq(map.popups.length, 1, "Popup opened correctly");
|
t.eq(map.popups.length, 1, "Popup opened correctly");
|
||||||
layer.markers[1].events.triggerEvent('click', event);
|
layer.markers[1].events.triggerEvent('click', event);
|
||||||
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
|
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) {
|
function test_04_Layer_Text_events_nopopups (t) {
|
||||||
|
|||||||
3
tests/data_Layer_Text_textfile_overflow.txt
Normal file
3
tests/data_Layer_Text_textfile_overflow.txt
Normal file
@@ -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
|
||||||
@@ -28,6 +28,21 @@
|
|||||||
t.ok( feature.popupClass == OpenLayers.Popup.AnchoredBubble, "default popupClass is AnchoredBubble");
|
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) {
|
function test_02_Feature_createMarker (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
t.ok(true);
|
t.ok(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user