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:
@@ -14,9 +14,10 @@ OpenLayers.Util = new Object();
|
|||||||
* @param {String} position
|
* @param {String} position
|
||||||
* @param {String} border
|
* @param {String} border
|
||||||
* @param {String} overflow
|
* @param {String} overflow
|
||||||
|
* @param {float} opacity Fractional value (0.0 - 1.0)
|
||||||
*/
|
*/
|
||||||
OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
||||||
border, overflow) {
|
border, overflow, opacity) {
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
element.id = id;
|
element.id = id;
|
||||||
@@ -38,6 +39,10 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
|||||||
if (overflow) {
|
if (overflow) {
|
||||||
element.style.overflow = overflow;
|
element.style.overflow = overflow;
|
||||||
}
|
}
|
||||||
|
if (opacity) {
|
||||||
|
element.style.opacity = opacity;
|
||||||
|
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -253,7 +253,7 @@
|
|||||||
|
|
||||||
function test_09_Util_modifyDOMElement(t) {
|
function test_09_Util_modifyDOMElement(t) {
|
||||||
|
|
||||||
t.plan( 8 );
|
t.plan( 10 );
|
||||||
|
|
||||||
var id = "boo";
|
var id = "boo";
|
||||||
var px = new OpenLayers.Pixel(5,5);
|
var px = new OpenLayers.Pixel(5,5);
|
||||||
@@ -261,11 +261,12 @@
|
|||||||
var position = "absolute";
|
var position = "absolute";
|
||||||
var border = "1px solid";
|
var border = "1px solid";
|
||||||
var overflow = "hidden";
|
var overflow = "hidden";
|
||||||
|
var opacity = 1/2;
|
||||||
|
|
||||||
var element = document.createElement("div");
|
var element = document.createElement("div");
|
||||||
|
|
||||||
OpenLayers.Util.modifyDOMElement(element, id, px, sz,
|
OpenLayers.Util.modifyDOMElement(element, id, px, sz, position,
|
||||||
position, border, overflow);
|
border, overflow, opacity);
|
||||||
|
|
||||||
t.eq( element.id, id, "element.id set correctly");
|
t.eq( element.id, id, "element.id set correctly");
|
||||||
t.eq( element.style.left, px.x + "px", "element.style.left 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.eq( element.style.position, position, "element.style.position set correctly");
|
||||||
t.ok( (element.style.border.indexOf(border) != -1), "element.style.border 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.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) {
|
function test_09_Util_modifyAlphaImageDiv(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user