Changeset 7647
- Timestamp:
- 07/31/08 16:40:00 (4 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Popup.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Popup/Anchored.js (modified) (1 diff)
- trunk/openlayers/tests/Popup.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Popup.js
r6718 r7647 49 49 50 50 /** 51 * Property: contentSize 52 * {<OpenLayers.Size>} the width and height of the content. 53 */ 54 contentSize: null, 55 56 /** 51 57 * Property: size 52 58 * {<OpenLayers.Size>} the width and height of the popup. … … 172 178 * lonlat - {<OpenLayers.LonLat>} The position on the map the popup will 173 179 * be shown. 174 * size - {<OpenLayers.Size>} The size of the popup.180 * contentSize - {<OpenLayers.Size>} The size of the content. 175 181 * contentHTML - {String} The HTML content to display inside the 176 182 * popup. … … 179 185 * closeBoxCallback - {Function} Function to be called on closeBox click. 180 186 */ 181 initialize:function(id, lonlat, size, contentHTML, closeBox, closeBoxCallback) {187 initialize:function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) { 182 188 if (id == null) { 183 189 id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); … … 186 192 this.id = id; 187 193 this.lonlat = lonlat; 188 this.size = (size != null) ? size 194 195 this.contentSize = (contentSize != null) ? contentSize 189 196 : new OpenLayers.Size( 190 197 OpenLayers.Popup.WIDTH, 191 198 OpenLayers.Popup.HEIGHT); 199 192 200 if (contentHTML != null) { 193 201 this.contentHTML = contentHTML; … … 207 215 208 216 var id = this.div.id + "_contentDiv"; 209 this.contentDiv = OpenLayers.Util.createDiv(id, null, this. size.clone(),217 this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(), 210 218 null, "relative"); 211 219 this.contentDiv.className = 'olPopupContent'; … … 299 307 300 308 this.moveTo(px); 301 if (!this.autoSize ) {302 this.setSize(this. size);309 if (!this.autoSize && !this.size) { 310 this.setSize(this.contentSize); 303 311 } 304 312 this.setBackgroundColor(); … … 391 399 * (in pixels). 392 400 */ 393 setSize:function(size) { 394 this.size = size; 395 396 var contentSize = this.size.clone(); 401 setSize:function(contentSize) { 402 this.size = contentSize.clone(); 397 403 398 404 // if our contentDiv has a css 'padding' set on it by a stylesheet, we … … 422 428 // me want to shoot someone, but so it goes. 423 429 if (OpenLayers.Util.getBrowserName() == "msie") { 424 contentSize.w += contentDivPadding.left + contentDivPadding.right;425 contentSize.h += contentDivPadding.bottom + contentDivPadding.top;430 this.contentSize.w += contentDivPadding.left + contentDivPadding.right; 431 this.contentSize.h += contentDivPadding.bottom + contentDivPadding.top; 426 432 } 427 433 trunk/openlayers/lib/OpenLayers/Popup/Anchored.js
r6911 r7647 165 165 calculateNewPx:function(px) { 166 166 var newPx = px.offset(this.anchor.offset); 167 168 //use contentSize if size is not already set 169 var size = this.size || this.contentSize; 167 170 168 171 var top = (this.relativePosition.charAt(0) == 't'); 169 newPx.y += (top) ? - this.size.h : this.anchor.size.h;172 newPx.y += (top) ? -size.h : this.anchor.size.h; 170 173 171 174 var left = (this.relativePosition.charAt(1) == 'l'); 172 newPx.x += (left) ? - this.size.w : this.anchor.size.w;175 newPx.x += (left) ? -size.w : this.anchor.size.w; 173 176 174 177 return newPx; trunk/openlayers/tests/Popup.html
r6725 r7647 17 17 "valid default popupid"); 18 18 var firstID = popup.id; 19 t.ok(popup. size.equals(size), "good default popup.size");19 t.ok(popup.contentSize.equals(size), "good default popup.size"); 20 20 t.eq(popup.contentHTML, "", "good default popup.contentHTML"); 21 21 t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor"); … … 55 55 t.eq(popup.id, id, "popup.id set correctly"); 56 56 t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly"); 57 t.ok(popup. size.equals(sz), "popup.size set correctly");57 t.ok(popup.contentSize.equals(sz), "popup.size set correctly"); 58 58 t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly"); 59 59
