Adding support for new generation 'framed' popups. This patch includes numerous improvements to the main popups, including the addition of autoSizing, panIntoView, and full support for overflow:auto of the contents div. Thanks go out to the CloudAmber folks, to Pierre in la belle France, to the guys at TOPP and of course, to senior cr5 for his patience and help in the last and final stretch. this is a huge improvement in the popup arena and couldn't have been done without the broad help of everyone out there in the community. Thank you everyone for making this possible. Big step for OpenLayers. (Closes #926)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6718 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1321,3 +1321,134 @@ OpenLayers.Util.getBrowserName = function() {
|
||||
|
||||
return browserName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method: getRenderedDimensions
|
||||
* Renders the contentHTML offscreen to determine actual dimensions for
|
||||
* popup sizing. As we need layout to determine dimensions the content
|
||||
* is rendered -9999px to the left and absolute to ensure the
|
||||
* scrollbars do not flicker
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>} If either the 'w' or 'h' properties is
|
||||
* specified, we fix that dimension of the div to be measured. This is
|
||||
* useful in the case where we have a limit in one dimension and must
|
||||
* therefore meaure the flow in the other dimension.
|
||||
*
|
||||
* Returns:
|
||||
* {OpenLayers.Size}
|
||||
*/
|
||||
OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) {
|
||||
|
||||
var w = h = null;
|
||||
|
||||
// create temp container div with restricted size
|
||||
var container = document.createElement("div");
|
||||
container.style.overflow= "";
|
||||
container.style.position = "absolute";
|
||||
container.style.left = "-9999px";
|
||||
|
||||
//fix a dimension, if specified.
|
||||
if (size) {
|
||||
if (size.w) {
|
||||
w = container.style.width = size.w;
|
||||
} else if (size.h) {
|
||||
h = container.style.height = size.h;
|
||||
}
|
||||
}
|
||||
|
||||
// create temp content div and assign content
|
||||
var content = document.createElement("div");
|
||||
content.innerHTML = contentHTML;
|
||||
|
||||
// add content to restricted container
|
||||
container.appendChild(content);
|
||||
|
||||
// append container to body for rendering
|
||||
document.body.appendChild(container);
|
||||
|
||||
// calculate scroll width of content and add corners and shadow width
|
||||
if (!w) {
|
||||
w = parseInt(content.scrollWidth);
|
||||
|
||||
// update container width to allow height to adjust
|
||||
container.style.width = w + "px";
|
||||
}
|
||||
// capture height and add shadow and corner image widths
|
||||
if (!h) {
|
||||
h = parseInt(content.scrollHeight);
|
||||
}
|
||||
|
||||
// remove elements
|
||||
container.removeChild(content);
|
||||
document.body.removeChild(container);
|
||||
|
||||
return new OpenLayers.Size(w, h);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: getScrollbarWidth
|
||||
* This function has been modified by the OpenLayers from the original version,
|
||||
* written by Matthew Eernisse and released under the Apache 2
|
||||
* license here:
|
||||
*
|
||||
* http://www.fleegix.org/articles/2006/05/30/getting-the-scrollbar-width-in-pixels
|
||||
*
|
||||
* It has been modified simply to cache its value, since it is physically
|
||||
* impossible that this code could ever run in more than one browser at
|
||||
* once.
|
||||
*
|
||||
* Returns:
|
||||
* {Integer}
|
||||
*/
|
||||
OpenLayers.Util.getScrollbarWidth = function() {
|
||||
|
||||
var scrollbarWidth = OpenLayers.Util._scrollbarWidth;
|
||||
|
||||
if (scrollbarWidth == null) {
|
||||
var scr = null;
|
||||
var inn = null;
|
||||
var wNoScroll = 0;
|
||||
var wScroll = 0;
|
||||
|
||||
// Outer scrolling div
|
||||
scr = document.createElement('div');
|
||||
scr.style.position = 'absolute';
|
||||
scr.style.top = '-1000px';
|
||||
scr.style.left = '-1000px';
|
||||
scr.style.width = '100px';
|
||||
scr.style.height = '50px';
|
||||
// Start with no scrollbar
|
||||
scr.style.overflow = 'hidden';
|
||||
|
||||
// Inner content div
|
||||
inn = document.createElement('div');
|
||||
inn.style.width = '100%';
|
||||
inn.style.height = '200px';
|
||||
|
||||
// Put the inner div in the scrolling div
|
||||
scr.appendChild(inn);
|
||||
// Append the scrolling div to the doc
|
||||
document.body.appendChild(scr);
|
||||
|
||||
// Width of the inner div sans scrollbar
|
||||
wNoScroll = inn.offsetWidth;
|
||||
|
||||
// Add the scrollbar
|
||||
scr.style.overflow = 'scroll';
|
||||
// Width of the inner div width scrollbar
|
||||
wScroll = inn.offsetWidth;
|
||||
|
||||
// Remove the scrolling div from the doc
|
||||
document.body.removeChild(document.body.lastChild);
|
||||
|
||||
// Pixel width of the scroller
|
||||
OpenLayers.Util._scrollbarWidth = (wNoScroll - wScroll);
|
||||
scrollbarWidth = OpenLayers.Util._scrollbarWidth;
|
||||
}
|
||||
|
||||
return scrollbarWidth;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user