mark Element.getDimensions as deprecated and remove the workaround in Map.getCurrentSize. p=bbinet, r=me (closes #2414)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10125 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -93,6 +93,7 @@ OpenLayers.Element = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* APIFunction: getDimensions
|
* APIFunction: getDimensions
|
||||||
|
* *Deprecated*. Returns dimensions of the element passed in.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* element - {DOMElement}
|
* element - {DOMElement}
|
||||||
@@ -112,12 +113,13 @@ OpenLayers.Element = {
|
|||||||
var els = element.style;
|
var els = element.style;
|
||||||
var originalVisibility = els.visibility;
|
var originalVisibility = els.visibility;
|
||||||
var originalPosition = els.position;
|
var originalPosition = els.position;
|
||||||
|
var originalDisplay = els.display;
|
||||||
els.visibility = 'hidden';
|
els.visibility = 'hidden';
|
||||||
els.position = 'absolute';
|
els.position = 'absolute';
|
||||||
els.display = '';
|
els.display = '';
|
||||||
var originalWidth = element.clientWidth;
|
var originalWidth = element.clientWidth;
|
||||||
var originalHeight = element.clientHeight;
|
var originalHeight = element.clientHeight;
|
||||||
els.display = 'none';
|
els.display = originalDisplay;
|
||||||
els.position = originalPosition;
|
els.position = originalPosition;
|
||||||
els.visibility = originalVisibility;
|
els.visibility = originalVisibility;
|
||||||
return {width: originalWidth, height: originalHeight};
|
return {width: originalWidth, height: originalHeight};
|
||||||
|
|||||||
@@ -1403,12 +1403,6 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
var size = new OpenLayers.Size(this.div.clientWidth,
|
var size = new OpenLayers.Size(this.div.clientWidth,
|
||||||
this.div.clientHeight);
|
this.div.clientHeight);
|
||||||
|
|
||||||
// Workaround for the fact that hidden elements return 0 for size.
|
|
||||||
if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {
|
|
||||||
var dim = OpenLayers.Element.getDimensions(this.div);
|
|
||||||
size.w = dim.width;
|
|
||||||
size.h = dim.height;
|
|
||||||
}
|
|
||||||
if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {
|
if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {
|
||||||
size.w = parseInt(this.div.style.width);
|
size.w = parseInt(this.div.style.width);
|
||||||
size.h = parseInt(this.div.style.height);
|
size.h = parseInt(this.div.style.height);
|
||||||
|
|||||||
@@ -110,37 +110,6 @@
|
|||||||
t.ok(OpenLayers.Element.getHeight(elem) == elem.offsetHeight, "offsetHeight returned");
|
t.ok(OpenLayers.Element.getHeight(elem) == elem.offsetHeight, "offsetHeight returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Element_getDimensions(t) {
|
|
||||||
if (!t.open_window) {
|
|
||||||
t.plan(0);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
t.plan(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
//shown
|
|
||||||
t.open_window( "BaseTypes/Element.html", function( wnd ) {
|
|
||||||
t.delay_call(3, function() {
|
|
||||||
var elem = wnd.document.getElementById("elemID");
|
|
||||||
|
|
||||||
var dims = OpenLayers.Element.getDimensions(elem);
|
|
||||||
t.eq(dims.width, 50, "width correct when displayed");
|
|
||||||
t.eq(dims.height, 100, "height correct when displayed")
|
|
||||||
|
|
||||||
elem.style.display = "none";
|
|
||||||
dims = OpenLayers.Element.getDimensions(elem);
|
|
||||||
t.eq(dims.width, 50, "width correct when hidden");
|
|
||||||
t.eq(dims.height, 100, "height correct when hidden")
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//hidden
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_hasClass(t) {
|
function test_hasClass(t) {
|
||||||
t.plan(14);
|
t.plan(14);
|
||||||
var has = OpenLayers.Element.hasClass;
|
var has = OpenLayers.Element.hasClass;
|
||||||
|
|||||||
Reference in New Issue
Block a user