Files
openlayers/lib/OpenLayers/Layer/EventPane.js
crschmidt f6a50a37fc IE will not catch events on a div which has no content in it. (Why? Who
knows!) However, if we set a background on the div, it works -- but not
if that background is transparent. It has to have some thing. So, if 
we're in IE, we use our handy dandy notebook!, er, blank.gif, to populate
a background so that the EventPane will work. 

If someone can fix this, please do.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1332 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-22 18:37:05 +00:00

82 lines
2.3 KiB
JavaScript

/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer.js
* @requires OpenLayers/Util.js
*/
OpenLayers.Layer.EventPane = Class.create();
OpenLayers.Layer.EventPane.prototype =
Object.extend(new OpenLayers.Layer, {
/** EventPaned layers are always base layers, by necessity.
*
* @type Boolean */
isBaseLayer: true,
/** EventPaned layers are fixed by default.
*
* @type Boolean */
isFixed: true,
/** @type DOMElement */
pane: null,
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
if (arguments.length > 0) {
if (this.pane == null) {
this.pane = OpenLayers.Util.createDiv();
}
}
},
/** Set the map property for the layer. This is done through an accessor
* so that subclasses can override this and take special action once
* they have their map variable set.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
this.pane.style.display = this.div.style.display;
this.pane.style.width="100%";
this.pane.style.height="100%";
if (/MSIE/.test(navigator.userAgent)) {
this.pane.style.background = "url("+OpenLayers.Util.getImagesLocation()+"blank.gif)";
}
if (this.isFixed) {
this.map.viewPortDiv.appendChild(this.pane);
} else {
this.map.layerContainerDiv.appendChild(this.pane);
}
this.map.events.attachToElement(this.pane);
},
/**
* @param {Boolean} visible
* @param {Boolean} noEvent
*/
setVisibility: function(visible, noEvent) {
OpenLayers.Layer.prototype.setVisibility.apply(this, arguments);
this.pane.style.display = this.div.style.display;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.EventPane"
});