JSDOC, coding standards

git-svn-id: http://svn.openlayers.org/trunk/openlayers@74 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-17 02:08:21 +00:00
parent 029683e84e
commit d260d7c3ae
+41 -14
View File
@@ -1,34 +1,50 @@
/**
* @class
*/
OpenLayers.Control.LayerSwitcher = Class.create(); OpenLayers.Control.LayerSwitcher = Class.create();
OpenLayers.Control.LayerSwitcher.prototype = OpenLayers.Control.LayerSwitcher.prototype =
Object.extend( new OpenLayers.Control(), { Object.extend( new OpenLayers.Control(), {
/**
* @constructor
*/
initialize: function() { initialize: function() {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
}, },
/**
* @type DOMElement
*/
draw: function() { draw: function() {
// initialize our internal div // initialize our internal div
OpenLayers.Control.prototype.draw.apply(this); OpenLayers.Control.prototype.draw.apply(this);
this.map.events.register("addlayer", this, this.redraw); this.map.events.register("addlayer", this, this.redraw);
return this.redraw(); return this.redraw();
}, },
/**
* @type DOMElement
*/
redraw: function() { redraw: function() {
var pixel = new OpenLayers.Pixel(this.map.div.clientWidth-200,4); var pixel = new OpenLayers.Pixel(this.map.div.clientWidth - 200, 4);
this.div.innerHTML = ""; this.div.innerHTML = "";
for(i=0; i<this.map.layers.length; i++) { for(i=0; i < this.map.layers.length; i++) {
var div = $('LayerControl_layer'+i); var div = $('LayerControl_layer' + i);
if (!div) { if (!div) {
div = OpenLayers.Util.createDiv("LayerControl_layer"+i,pixel,new OpenLayers.Size(200,20)); div = OpenLayers.Util.createDiv("LayerControl_layer" + i,
pixel,
new OpenLayers.Size(200, 20));
div.innerHTML = this.map.layers[i].name; div.innerHTML = this.map.layers[i].name;
var status = this.map.layers[i].getVisibility(); var status = this.map.layers[i].getVisibility();
if (!status) { if (!status) {
div.style.backgroundColor="black"; div.style.backgroundColor = "black";
div.style.color="white"; div.style.color = "white";
} else { } else {
div.style.backgroundColor="white"; div.style.backgroundColor = "white";
div.style.color="black"; div.style.color = "black";
} }
div.style.padding="5px"; div.style.padding = "5px";
div.layerid = i; div.layerid = i;
div.map = this.map; div.map = this.map;
div.ondblclick = this.doubleClick.bindAsEventListener(div); div.ondblclick = this.doubleClick.bindAsEventListener(div);
@@ -39,19 +55,30 @@ OpenLayers.Control.LayerSwitcher.prototype =
} }
return this.div; return this.div;
}, },
/**
* @param {event} evt
*/
singleClick: function(evt) { singleClick: function(evt) {
var status = this.map.layers[this.layerid].getVisibility(); var status = this.map.layers[this.layerid].getVisibility();
this.map.layers[this.layerid].setVisibility(!status); this.map.layers[this.layerid].setVisibility(!status);
if (status) { if (status) {
this.style.backgroundColor="black"; this.style.backgroundColor = "black";
this.style.color="white"; this.style.color = "white";
} else { } else {
this.style.backgroundColor="white"; this.style.backgroundColor = "white";
this.style.color="black"; this.style.color = "black";
} }
Event.stop(evt); Event.stop(evt);
}, },
/**
* @param {event} evt
*/
doubleClick: function(evt) { doubleClick: function(evt) {
Event.stop(evt); Event.stop(evt);
} },
/** @type String */
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
}); });