added member variables for activeColor and nonActiveColor so that users can customize dynamically

git-svn-id: http://svn.openlayers.org/trunk/openlayers@132 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-18 06:06:16 +00:00
parent 233a638e3e
commit b4f80c494c

View File

@@ -21,6 +21,12 @@ OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR = "lightblue";
OpenLayers.Control.LayerSwitcher.prototype =
Object.extend( new OpenLayers.Control(), {
/** @type String */
activeColor: OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR,
/** @type String */
nonActiveColor: OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR,
/**
* @constructor
@@ -73,9 +79,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
* @param {event} evt
*/
singleClick: function(evt) {
var visible = this.layer.getVisibility();
OpenLayers.Control.LayerSwitcher.setTabActivation(this, !visible);
this.layer.setVisibility(!visible);
var div = Event.element(evt);
var layer = div.layer;
var visible = layer.getVisibility();
this.setTabActivation(div, !visible);
layer.setVisibility(!visible);
Event.stop(evt);
},
@@ -113,10 +122,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
backdropLabel.layer = layer;
// set event handlers
backdropLabel.ondblclick =
this.doubleClick.bindAsEventListener(backdropLabel);
backdropLabel.onmousedown =
this.singleClick.bindAsEventListener(backdropLabel);
backdropLabel.ondblclick = this.doubleClick.bindAsEventListener(this);
backdropLabel.onmousedown = this.singleClick.bindAsEventListener(this);
// add label to div
@@ -130,26 +137,25 @@ OpenLayers.Control.LayerSwitcher.prototype =
color: "white",
blend: false});
OpenLayers.Control.LayerSwitcher.setTabActivation(backdropLabel,
layer.getVisibility());
this.setTabActivation(backdropLabel, layer.getVisibility());
},
/**
* @private
*
* @param {DOMElement} div
* @param {Boolean} activate
*/
setTabActivation:function(div, activate) {
var color = (activate) ? this.activeColor : this.nonActiveColor;
Rico.Corner.changeColor(div, color);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
});
/**
* @private
*
* @param {bool}
*/
OpenLayers.Control.LayerSwitcher.setTabActivation = function(div, activate) {
var color = (activate) ? OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR
: OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
Rico.Corner.changeColor(div, color);
};