Fix #57. Add event handlers to the spans created by adding corners to the layer switcher tabs. (Somewhat hacky.)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@603 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -93,6 +93,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
*/
|
*/
|
||||||
singleClick: function(evt) {
|
singleClick: function(evt) {
|
||||||
var div = Event.element(evt);
|
var div = Event.element(evt);
|
||||||
|
|
||||||
|
// See comment about OL #57 fix below.
|
||||||
|
// If the click occurred on the corner spans we need
|
||||||
|
// to make sure we act on the actual label tab instead.
|
||||||
|
div = div.labelElement || div;
|
||||||
|
|
||||||
var layer = div.layer;
|
var layer = div.layer;
|
||||||
if (this.mode == "radio") {
|
if (this.mode == "radio") {
|
||||||
for(var i=0; i < this.backdrops.length; i++) {
|
for(var i=0; i < this.backdrops.length; i++) {
|
||||||
@@ -162,6 +168,14 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
color: "white",
|
color: "white",
|
||||||
blend: false});
|
blend: false});
|
||||||
|
|
||||||
|
// extend the event handlers to operate on the
|
||||||
|
// rounded corners as well. (Fixes OL #57.)
|
||||||
|
var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
|
||||||
|
|
||||||
|
for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
|
||||||
|
this._setEventHandlers(spanElements[currIdx], backdropLabel);
|
||||||
|
}
|
||||||
|
|
||||||
this.setTabActivation(backdropLabel, layer.getVisibility());
|
this.setTabActivation(backdropLabel, layer.getVisibility());
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -171,12 +185,18 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
@param {DOMElement} div
|
@param {DOMElement} div
|
||||||
@param {Boolean} activate
|
@param {Boolean} activate
|
||||||
*/
|
*/
|
||||||
_setEventHandlers : function(element) {
|
_setEventHandlers : function(element, labelDiv) {
|
||||||
|
|
||||||
// We only want to respond to a mousedown event.
|
// We only want to respond to a mousedown event.
|
||||||
element.onclick = this.ignoreEvent.bindAsEventListener(this);
|
element.onclick = this.ignoreEvent.bindAsEventListener(this);
|
||||||
element.ondblclick = this.ignoreEvent.bindAsEventListener(this);
|
element.ondblclick = this.ignoreEvent.bindAsEventListener(this);
|
||||||
element.onmousedown = this.singleClick.bindAsEventListener(this);
|
element.onmousedown = this.singleClick.bindAsEventListener(this);
|
||||||
|
|
||||||
|
// If we are operating on a corner span we need to store a
|
||||||
|
// reference to the actual tab. (See comment about OL #57 fix above.)
|
||||||
|
if (labelDiv) {
|
||||||
|
element.labelElement = labelDiv;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user