Ticket #1586: sizing.patch
| File sizing.patch, 11.3 kB (added by euzuro, 4 months ago) |
|---|
-
tests/Popup.html
old new 16 16 t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers.Popup"), 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, null, "good default popup.contentHTML"); 21 21 t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor"); 22 22 t.eq(popup.opacity, OpenLayers.Popup.OPACITY, "good default popup.opacity"); … … 54 54 t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" ); 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 60 60 // test that a browser event is registered on click on popup closebox -
lib/OpenLayers/Popup/FramedCloud.js
old new 203 203 * Parameters: 204 204 * id - {String} 205 205 * lonlat - {<OpenLayers.LonLat>} 206 * size - {<OpenLayers.Size>}206 * contentSize - {<OpenLayers.Size>} 207 207 * contentHTML - {String} 208 208 * anchor - {Object} Object to which we'll anchor the popup. Must expose 209 209 * a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>) … … 211 211 * closeBox - {Boolean} 212 212 * closeBoxCallback - {Function} Function to be called on closeBox click. 213 213 */ 214 initialize:function(id, lonlat, size, contentHTML, anchor, closeBox,214 initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox, 215 215 closeBoxCallback) { 216 216 217 217 this.imageSrc = OpenLayers.Util.getImagesLocation() + 'cloud-popup-relative.png'; -
lib/OpenLayers/Popup/Framed.js
old new 85 85 * Parameters: 86 86 * id - {String} 87 87 * lonlat - {<OpenLayers.LonLat>} 88 * size - {<OpenLayers.Size>}88 * contentSize - {<OpenLayers.Size>} 89 89 * contentHTML - {String} 90 90 * anchor - {Object} Object to which we'll anchor the popup. Must expose 91 91 * a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>) … … 93 93 * closeBox - {Boolean} 94 94 * closeBoxCallback - {Function} Function to be called on closeBox click. 95 95 */ 96 initialize:function(id, lonlat, size, contentHTML, anchor, closeBox,96 initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox, 97 97 closeBoxCallback) { 98 98 99 99 OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); … … 188 188 * of the popup has changed. 189 189 * 190 190 * Parameters: 191 * size - {<OpenLayers.Size>} 191 * contentSize - {<OpenLayers.Size>} the new size for the popup's 192 * contents div (in pixels). 192 193 */ 193 setSize:function( size) {194 setSize:function(contentSize) { 194 195 OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); 195 196 196 197 this.updateBlocks(); … … 296 297 this.createBlocks(); 297 298 } 298 299 299 if (this. relativePosition) {300 if (this.size && this.relativePosition) { 300 301 var position = this.positionBlocks[this.relativePosition]; 301 302 for (var i = 0; i < position.blocks.length; i++) { 302 303 -
lib/OpenLayers/Popup/AnchoredBubble.js
old new 28 28 * Parameters: 29 29 * id - {String} 30 30 * lonlat - {<OpenLayers.LonLat>} 31 * size - {<OpenLayers.Size>}31 * contentSize - {<OpenLayers.Size>} 32 32 * contentHTML - {String} 33 33 * anchor - {Object} Object to which we'll anchor the popup. Must expose 34 34 * a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>) … … 36 36 * closeBox - {Boolean} 37 37 * closeBoxCallback - {Function} Function to be called on closeBox click. 38 38 */ 39 initialize:function(id, lonlat, size, contentHTML, anchor, closeBox,39 initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox, 40 40 closeBoxCallback) { 41 41 42 42 this.padding = new OpenLayers.Bounds( … … 81 81 * APIMethod: setSize 82 82 * 83 83 * Parameters: 84 * size - {<OpenLayers.Size>} 84 * contentSize - {<OpenLayers.Size>} the new size for the popup's 85 * contents div (in pixels). 85 86 */ 86 setSize:function( size) {87 setSize:function(contentSize) { 87 88 OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); 88 89 89 90 this.setRicoCorners(); -
lib/OpenLayers/Popup/Anchored.js
old new 35 35 * Parameters: 36 36 * id - {String} 37 37 * lonlat - {<OpenLayers.LonLat>} 38 * size - {<OpenLayers.Size>}38 * contentSize - {<OpenLayers.Size>} 39 39 * contentHTML - {String} 40 40 * anchor - {Object} Object which must expose a 'size' <OpenLayers.Size> 41 41 * and 'offset' <OpenLayers.Pixel> (generally an <OpenLayers.Icon>). 42 42 * closeBox - {Boolean} 43 43 * closeBoxCallback - {Function} Function to be called on closeBox click. 44 44 */ 45 initialize:function(id, lonlat, size, contentHTML, anchor, closeBox,45 initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox, 46 46 closeBoxCallback) { 47 var newArguments = new Array(id, lonlat, size, contentHTML, closeBox, 48 closeBoxCallback); 47 var newArguments = [ 48 id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback 49 ]; 49 50 OpenLayers.Popup.prototype.initialize.apply(this, newArguments); 50 51 51 52 this.anchor = (anchor != null) ? anchor … … 108 109 * APIMethod: setSize 109 110 * 110 111 * Parameters: 111 * size - {<OpenLayers.Size>} 112 * contentSize - {<OpenLayers.Size>} the new size for the popup's 113 * contents div (in pixels). 112 114 */ 113 setSize:function( size) {115 setSize:function(contentSize) { 114 116 OpenLayers.Popup.prototype.setSize.apply(this, arguments); 115 117 116 118 if ((this.lonlat) && (this.map)) { … … 164 166 */ 165 167 calculateNewPx:function(px) { 166 168 var newPx = px.offset(this.anchor.offset); 169 170 //use contentSize if size is not already set 171 var size = this.size || this.contentSize; 167 172 168 173 var top = (this.relativePosition.charAt(0) == 't'); 169 newPx.y += (top) ? - this.size.h : this.anchor.size.h;174 newPx.y += (top) ? -size.h : this.anchor.size.h; 170 175 171 176 var left = (this.relativePosition.charAt(1) == 'l'); 172 newPx.x += (left) ? - this.size.w : this.anchor.size.w;177 newPx.x += (left) ? -size.w : this.anchor.size.w; 173 178 174 179 return newPx; 175 180 }, -
lib/OpenLayers/Popup.js
old new 48 48 div: null, 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. 53 59 */ … … 183 189 * an identifier will be automatically generated. 184 190 * lonlat - {<OpenLayers.LonLat>} The position on the map the popup will 185 191 * be shown. 186 * size - {<OpenLayers.Size>} The size of the popup.192 * contentSize - {<OpenLayers.Size>} The size of the content. 187 193 * contentHTML - {String} An HTML string to display inside the 188 194 * popup. 189 195 * closeBox - {Boolean} Whether to display a close box inside 190 196 * the popup. 191 197 * closeBoxCallback - {Function} Function to be called on closeBox click. 192 198 */ 193 initialize:function(id, lonlat, size, contentHTML, closeBox, closeBoxCallback) {199 initialize:function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) { 194 200 if (id == null) { 195 201 id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 196 202 } 197 203 198 204 this.id = id; 199 205 this.lonlat = lonlat; 200 this.size = (size != null) ? size 206 207 this.contentSize = (contentSize != null) ? contentSize 201 208 : new OpenLayers.Size( 202 209 OpenLayers.Popup.WIDTH, 203 210 OpenLayers.Popup.HEIGHT); … … 218 225 "hidden"); 219 226 220 227 var id = this.div.id + "_contentDiv"; 221 this.contentDiv = OpenLayers.Util.createDiv(id, null, this. size.clone(),228 this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(), 222 229 null, "relative"); 223 230 this.contentDiv.className = this.contentDisplayClass; 224 231 this.groupDiv.appendChild(this.contentDiv); … … 310 317 } 311 318 312 319 this.moveTo(px); 313 if (!this.autoSize ) {314 this.setSize(this. size);320 if (!this.autoSize && !this.size) { 321 this.setSize(this.contentSize); 315 322 } 316 323 this.setBackgroundColor(); 317 324 this.setOpacity(); … … 399 406 * Used to adjust the size of the popup. 400 407 * 401 408 * Parameters: 402 * size - {<OpenLayers.Size>} the new size of the popup's contents div403 * (in pixels).409 * contentSize - {<OpenLayers.Size>} the new size for the popup's 410 * contents div (in pixels). 404 411 */ 405 setSize:function(size) { 406 this.size = size; 407 408 var contentSize = this.size.clone(); 412 setSize:function(contentSize) { 413 this.size = contentSize.clone(); 409 414 410 415 // if our contentDiv has a css 'padding' set on it by a stylesheet, we 411 416 // must add that to the desired "size". … … 433 438 // div itself bigger to take its own padding into effect. this makes 434 439 // me want to shoot someone, but so it goes. 435 440 if (OpenLayers.Util.getBrowserName() == "msie") { 436 contentSize.w += contentDivPadding.left + contentDivPadding.right; 437 contentSize.h += contentDivPadding.bottom + contentDivPadding.top; 441 this.contentSize.w += 442 contentDivPadding.left + contentDivPadding.right; 443 this.contentSize.h += 444 contentDivPadding.bottom + contentDivPadding.top; 438 445 } 439 446 440 447 if (this.div != null) {
