diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 1270e35af2..2fb891336d 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -347,17 +347,9 @@ OpenLayers.Layer = OpenLayers.Class({ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); this.div = OpenLayers.Util.createDiv(this.id); - var style = this.div.style; - style.width = "100%"; - style.height = "100%"; - style.overflow = ""; - this.div.className = "olLayerDiv"; + this.div.style.width = "100%"; + this.div.style.height = "100%"; this.div.dir = "ltr"; - if (this.opacity != null && this.opacity < 1) { - OpenLayers.Util.modifyDOMElement( - this.div, null, null, null, null, null, null, this.opacity - ); - } this.events = new OpenLayers.Events(this, this.div, this.EVENT_TYPES); @@ -370,19 +362,6 @@ OpenLayers.Layer = OpenLayers.Class({ if (this.wrapDateLine) { this.displayOutsideMaxExtent = true; } - - //TODO remove the if block below when we drop support for IE8. - if (parseInt(navigator.appVersion.split("MSIE")[1], 10) == 8) { - // Workaround for opacity handling in IE8 - also see - // .ie8-opacity-hack selectors in theme/default/style.css - this.events.register("loadend", this, function() { - var opacity = this.opacity; - if (opacity != null && opacity >= 0 && opacity < 1) { - OpenLayers.Element.addClass(this.div, "ie8-opacity-hack"); - this.div.style.filter = "alpha(opacity=" + (opacity * 100) + ")"; - } - }); - } }, /** @@ -1291,8 +1270,11 @@ OpenLayers.Layer = OpenLayers.Class({ setOpacity: function(opacity) { if (opacity != this.opacity) { this.opacity = opacity; - OpenLayers.Util.modifyDOMElement(this.div, null, null, null, - null, null, null, opacity); + for(var i=0, len=this.div.childNodes.length; i diff --git a/tests/Layer/WFS.html b/tests/Layer/WFS.html index b9f85182d2..42b566acfe 100644 --- a/tests/Layer/WFS.html +++ b/tests/Layer/WFS.html @@ -25,6 +25,22 @@ } + function test_Layer_WFS_setOpacity(t) { + t.plan(3); + + var layer = new OpenLayers.Layer.WFS(name, "url", {}); + layer.setOpacity(.5); + t.eq(layer.opacity, 0.5, "vector setOpacity didn't fail"); + var layer = new OpenLayers.Layer.WFS(name, "url", {}, {'featureClass': OpenLayers.Feature.WFS}); + var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0)); + marker.setOpacity = function() { + t.ok(true, "Marker setOpacity was called"); + } + layer.addMarker(marker); + layer.setOpacity(.6); + t.eq(layer.opacity, 0.6, "setOpacity didn't fail on markers"); + } + function test_Layer_WFS_destroy(t) { t.plan(13); diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index 557395df30..05b2adb64c 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -281,6 +281,31 @@ } + function test_Layer_WMS_setOpacity (t) { + t.plan( 5 ); + + var map = new OpenLayers.Map('map'); + map.projection = "xx"; + tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; + tParams = { layers: 'basic', + format: 'image/png'}; + tOptions = { 'opacity': '0.5' }; + var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions); + map.addLayer(tLayer); + map.zoomToMaxExtent(); + t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); + t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); + tLayer.setOpacity("0.6"); + t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); + t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); + var pixel = new OpenLayers.Pixel(5,6); + var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); + tile.draw(); + t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); + + map.destroy(); + } + function test_Layer_WMS_Reproject (t) { var validkey = (window.location.protocol == "file:") || (window.location.host == "localhost") || diff --git a/theme/default/style.css b/theme/default/style.css index 1c835d45af..3aeac29c2e 100644 --- a/theme/default/style.css +++ b/theme/default/style.css @@ -14,15 +14,6 @@ div.olLayerDiv { -khtml-user-select: none; } -/* TODO remove the two style definitions below when we drop support for IE8 */ -div.olLayerDiv.ie8-opacity-hack { - width: 9999px !important; - height: 9999px !important; -} -div.olLayerDiv.ie8-opacity-hack div, .ie8-opacity-hack img.olTileImage { - filter: inherit; -} - .olLayerGoogleCopyright { left: 2px; bottom: 2px;