Util.modifyDOMElement don't update the opactity if the passed value is
evaluated as false, passing 0.0 won't work as expected. Fix it. Spotted by sebastien and reviewed by crschmidt. (Closes #1168) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5372 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -170,9 +170,12 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
||||
if (overflow) {
|
||||
element.style.overflow = overflow;
|
||||
}
|
||||
if (opacity) {
|
||||
if (parseFloat(opacity) >= 0.0 && parseFloat(opacity) < 1.0) {
|
||||
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||
element.style.opacity = opacity;
|
||||
} else if (parseFloat(opacity) == 1.0) {
|
||||
element.style.filter = '';
|
||||
element.style.opacity = '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -398,7 +401,8 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
position, border, sizing,
|
||||
opacity) {
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(div, id, px, sz);
|
||||
OpenLayers.Util.modifyDOMElement(div, id, px, sz,
|
||||
null, null, null, opacity);
|
||||
|
||||
var img = div.childNodes[0];
|
||||
|
||||
@@ -407,10 +411,6 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(img, div.id + "_innerImage", null, sz,
|
||||
"relative", border);
|
||||
if (opacity) {
|
||||
div.style.opacity = opacity;
|
||||
div.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||
}
|
||||
|
||||
if (OpenLayers.Util.alphaHack()) {
|
||||
|
||||
@@ -422,12 +422,12 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
div.style.filter = "progid:DXImageTransform.Microsoft" +
|
||||
".AlphaImageLoader(src='" + img.src + "', " +
|
||||
"sizingMethod='" + sizing + "')";
|
||||
if (div.style.opacity) {
|
||||
if (parseFloat(div.style.opacity) >= 0.0 &&
|
||||
parseFloat(div.style.opacity) < 1.0) {
|
||||
div.style.filter += " alpha(opacity=" + div.style.opacity * 100 + ")";
|
||||
}
|
||||
|
||||
img.style.filter = "progid:DXImageTransform.Microsoft" +
|
||||
".Alpha(opacity=0)";
|
||||
img.style.filter = "alpha(opacity=0)";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
"sizingMethod='" + sizing + "') alpha(opacity=50)";
|
||||
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
|
||||
|
||||
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
|
||||
filter = "alpha(opacity=0)";
|
||||
t.eq(image.style.filter, filter, "image filter set correctly");
|
||||
|
||||
} else {
|
||||
@@ -276,6 +276,47 @@
|
||||
|
||||
}
|
||||
|
||||
function test_Util_modifyDOMElement_opacity(t) {
|
||||
t.plan(8);
|
||||
|
||||
var opacity = 0.2;
|
||||
|
||||
var element = document.createElement("div");
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null, null,
|
||||
null, null, opacity);
|
||||
|
||||
t.eq(parseFloat(element.style.opacity), opacity,
|
||||
"element.style.opacity set correctly when opacity = " + opacity);
|
||||
t.eq(element.style.filter, 'alpha(opacity=' + (opacity * 100) + ')',
|
||||
"element.style.filter set correctly when opacity = " + opacity);
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null, null,
|
||||
null, null, "5");
|
||||
|
||||
t.eq(parseFloat(element.style.opacity), opacity,
|
||||
"element.style.opacity not changed if the value is incorrect");
|
||||
t.eq(element.style.filter, 'alpha(opacity=' + (opacity * 100) + ')',
|
||||
"element.style.filter not changed if the value is incorrect");
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null, null,
|
||||
null, null, "hello");
|
||||
|
||||
t.eq(parseFloat(element.style.opacity), opacity,
|
||||
"element.style.opacity not changed if the value is incorrect");
|
||||
t.eq(element.style.filter, 'alpha(opacity=' + (opacity * 100) + ')',
|
||||
"element.style.filter not changed if the value is incorrect");
|
||||
|
||||
opacity = 1.00;
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null, null,
|
||||
null, null, opacity);
|
||||
|
||||
t.eq(element.style.opacity, '',
|
||||
"element.style.opacity is removed when opacity = " + opacity);
|
||||
t.eq(element.style.filter, '',
|
||||
"element.style.filter is removed when opacity = " + opacity);
|
||||
}
|
||||
|
||||
function test_09_Util_modifyDOMElement(t) {
|
||||
t.plan( 10 );
|
||||
|
||||
@@ -367,7 +408,7 @@
|
||||
"sizingMethod='" + sizing + "') alpha(opacity=" + opacity *100 + ")";
|
||||
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
|
||||
|
||||
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
|
||||
filter = "alpha(opacity=0)";
|
||||
t.eq(image.style.filter, filter, "image filter set correctly");
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user