allow opacity to be set with OpenLayers.Util.modifyDOMElement(). added test.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1547 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-03 18:50:44 +00:00
parent 4f8c62df3f
commit 7280a6211e
2 changed files with 13 additions and 5 deletions

View File

@@ -14,9 +14,10 @@ OpenLayers.Util = new Object();
* @param {String} position
* @param {String} border
* @param {String} overflow
* @param {float} opacity Fractional value (0.0 - 1.0)
*/
OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
border, overflow) {
border, overflow, opacity) {
if (id) {
element.id = id;
@@ -38,6 +39,10 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
if (overflow) {
element.style.overflow = overflow;
}
if (opacity) {
element.style.opacity = opacity;
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
}
};
/**

View File

@@ -253,7 +253,7 @@
function test_09_Util_modifyDOMElement(t) {
t.plan( 8 );
t.plan( 10 );
var id = "boo";
var px = new OpenLayers.Pixel(5,5);
@@ -261,11 +261,12 @@
var position = "absolute";
var border = "1px solid";
var overflow = "hidden";
var opacity = 1/2;
var element = document.createElement("div");
OpenLayers.Util.modifyDOMElement(element, id, px, sz,
position, border, overflow);
OpenLayers.Util.modifyDOMElement(element, id, px, sz, position,
border, overflow, opacity);
t.eq( element.id, id, "element.id set correctly");
t.eq( element.style.left, px.x + "px", "element.style.left set correctly");
@@ -277,7 +278,9 @@
t.eq( element.style.position, position, "element.style.position set correctly");
t.ok( (element.style.border.indexOf(border) != -1), "element.style.border set correctly");
t.eq( element.style.overflow, overflow, "element.style.overflow set correctly");
t.eq( element.style.opacity, opacity + "", "elemnt.style.opacity set correctly");
var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
t.eq( element.style.filter, filterString, "element.style.filter set correctly");
}
function test_09_Util_modifyAlphaImageDiv(t) {