Fixing the sizing issues with the popups -- all this time, the 'size' parameter we were passing in to init a popup has been the *content* size, not the actual size of the popup. This confusion has stemmed from the fact that we weren't ever differentiating between the two. Now we are. Rename that parameter 'contentSize' in all the constructors. NOTE that this does not *break* API, it is merely renaming a variable. As such, no one should see any difference... other than the fact that autosized popups now stay their correct size when opened and closed repeatedly. Big thanks to jpulles for finding this bug and filing an accurate, informative, and detailed bug report. Thanks to ahocevar and crschmidt for reviewing. (Closes #1586)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7897 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -47,6 +47,12 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
*/
|
||||
div: null,
|
||||
|
||||
/**
|
||||
* Property: contentSize
|
||||
* {<OpenLayers.Size>} the width and height of the content.
|
||||
*/
|
||||
contentSize: null,
|
||||
|
||||
/**
|
||||
* Property: size
|
||||
* {<OpenLayers.Size>} the width and height of the popup.
|
||||
@@ -183,21 +189,22 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
* an identifier will be automatically generated.
|
||||
* lonlat - {<OpenLayers.LonLat>} The position on the map the popup will
|
||||
* be shown.
|
||||
* size - {<OpenLayers.Size>} The size of the popup.
|
||||
* contentSize - {<OpenLayers.Size>} The size of the content.
|
||||
* contentHTML - {String} An HTML string to display inside the
|
||||
* popup.
|
||||
* closeBox - {Boolean} Whether to display a close box inside
|
||||
* the popup.
|
||||
* closeBoxCallback - {Function} Function to be called on closeBox click.
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, closeBox, closeBoxCallback) {
|
||||
initialize:function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) {
|
||||
if (id == null) {
|
||||
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.lonlat = lonlat;
|
||||
this.size = (size != null) ? size
|
||||
|
||||
this.contentSize = (contentSize != null) ? contentSize
|
||||
: new OpenLayers.Size(
|
||||
OpenLayers.Popup.WIDTH,
|
||||
OpenLayers.Popup.HEIGHT);
|
||||
@@ -218,7 +225,7 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
"hidden");
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(),
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(),
|
||||
null, "relative");
|
||||
this.contentDiv.className = this.contentDisplayClass;
|
||||
this.groupDiv.appendChild(this.contentDiv);
|
||||
@@ -310,8 +317,8 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
}
|
||||
|
||||
this.moveTo(px);
|
||||
if (!this.autoSize) {
|
||||
this.setSize(this.size);
|
||||
if (!this.autoSize && !this.size) {
|
||||
this.setSize(this.contentSize);
|
||||
}
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
@@ -399,13 +406,11 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
* Used to adjust the size of the popup.
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>} the new size of the popup's contents div
|
||||
* (in pixels).
|
||||
* contentSize - {<OpenLayers.Size>} the new size for the popup's
|
||||
* contents div (in pixels).
|
||||
*/
|
||||
setSize:function(size) {
|
||||
this.size = size;
|
||||
|
||||
var contentSize = this.size.clone();
|
||||
setSize:function(contentSize) {
|
||||
this.size = contentSize.clone();
|
||||
|
||||
// if our contentDiv has a css 'padding' set on it by a stylesheet, we
|
||||
// must add that to the desired "size".
|
||||
@@ -433,8 +438,10 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
// div itself bigger to take its own padding into effect. this makes
|
||||
// me want to shoot someone, but so it goes.
|
||||
if (OpenLayers.Util.getBrowserName() == "msie") {
|
||||
contentSize.w += contentDivPadding.left + contentDivPadding.right;
|
||||
contentSize.h += contentDivPadding.bottom + contentDivPadding.top;
|
||||
this.contentSize.w +=
|
||||
contentDivPadding.left + contentDivPadding.right;
|
||||
this.contentSize.h +=
|
||||
contentDivPadding.bottom + contentDivPadding.top;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
|
||||
Reference in New Issue
Block a user