diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index c2ebd6945c..94c4eec041 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -47,12 +47,6 @@ OpenLayers.Popup = OpenLayers.Class({ */ div: null, - /** - * Property: contentSize - * {} the width and height of the content. - */ - contentSize: null, - /** * Property: size * {} the width and height of the popup. @@ -177,26 +171,24 @@ OpenLayers.Popup = OpenLayers.Class({ * an identifier will be automatically generated. * lonlat - {} The position on the map the popup will * be shown. - * contentSize - {} The size of the content. + * size - {} The size of the popup. * contentHTML - {String} The HTML content 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, contentSize, contentHTML, closeBox, closeBoxCallback) { + initialize:function(id, lonlat, size, contentHTML, closeBox, closeBoxCallback) { if (id == null) { id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); } this.id = id; this.lonlat = lonlat; - - this.contentSize = (contentSize != null) ? contentSize + this.size = (size != null) ? size : new OpenLayers.Size( OpenLayers.Popup.WIDTH, OpenLayers.Popup.HEIGHT); - if (contentHTML != null) { this.contentHTML = contentHTML; } @@ -214,7 +206,7 @@ OpenLayers.Popup = OpenLayers.Class({ "hidden"); var id = this.div.id + "_contentDiv"; - this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(), + this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(), null, "relative"); this.contentDiv.className = 'olPopupContent'; this.groupDiv.appendChild(this.contentDiv); @@ -306,8 +298,8 @@ OpenLayers.Popup = OpenLayers.Class({ } this.moveTo(px); - if (!this.autoSize && !this.size) { - this.setSize(this.contentSize); + if (!this.autoSize) { + this.setSize(this.size); } this.setBackgroundColor(); this.setOpacity(); @@ -398,8 +390,10 @@ OpenLayers.Popup = OpenLayers.Class({ * size - {} the new size of the popup's contents div * (in pixels). */ - setSize:function(contentSize) { - this.size = contentSize.clone(); + setSize:function(size) { + this.size = size; + + var contentSize = this.size.clone(); // if our contentDiv has a css 'padding' set on it by a stylesheet, we // must add that to the desired "size". @@ -427,8 +421,8 @@ 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") { - this.contentSize.w += contentDivPadding.left + contentDivPadding.right; - this.contentSize.h += contentDivPadding.bottom + contentDivPadding.top; + contentSize.w += contentDivPadding.left + contentDivPadding.right; + contentSize.h += contentDivPadding.bottom + contentDivPadding.top; } if (this.div != null) { diff --git a/lib/OpenLayers/Popup/Anchored.js b/lib/OpenLayers/Popup/Anchored.js index 432d7c7b0d..a452b9dc27 100644 --- a/lib/OpenLayers/Popup/Anchored.js +++ b/lib/OpenLayers/Popup/Anchored.js @@ -164,15 +164,12 @@ OpenLayers.Popup.Anchored = */ calculateNewPx:function(px) { var newPx = px.offset(this.anchor.offset); - - //use contentSize if size is not already set - var size = this.size || this.contentSize; var top = (this.relativePosition.charAt(0) == 't'); - newPx.y += (top) ? -size.h : this.anchor.size.h; + newPx.y += (top) ? -this.size.h : this.anchor.size.h; var left = (this.relativePosition.charAt(1) == 'l'); - newPx.x += (left) ? -size.w : this.anchor.size.w; + newPx.x += (left) ? -this.size.w : this.anchor.size.w; return newPx; }, diff --git a/tests/Popup.html b/tests/Popup.html index e12f0876eb..8f24b4715f 100644 --- a/tests/Popup.html +++ b/tests/Popup.html @@ -16,7 +16,7 @@ t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers.Popup"), "valid default popupid"); var firstID = popup.id; - t.ok(popup.contentSize.equals(size), "good default popup.size"); + t.ok(popup.size.equals(size), "good default popup.size"); t.eq(popup.contentHTML, "", "good default popup.contentHTML"); t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor"); t.eq(popup.opacity, OpenLayers.Popup.OPACITY, "good default popup.opacity"); @@ -54,7 +54,7 @@ t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" ); t.eq(popup.id, id, "popup.id set correctly"); t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly"); - t.ok(popup.contentSize.equals(sz), "popup.size set correctly"); + t.ok(popup.size.equals(sz), "popup.size set correctly"); t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly"); // test that a browser event is registered on click on popup closebox