Add 'ascending' flag to LayerSwitcher. Update docs. Add Demo. Add tests.
Closes #256 . git-svn-id: http://svn.openlayers.org/trunk/openlayers@1539 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -43,6 +43,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
/** @type DOMElement */
|
||||
maximizeDiv: null,
|
||||
|
||||
/** @type Boolean */
|
||||
ascending: true,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
@@ -99,8 +102,10 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
var containsOverlays = false;
|
||||
|
||||
for( var i = 0; i < this.map.layers.length; i++) {
|
||||
var layer = this.map.layers[i];
|
||||
var layers = this.map.layers.slice();
|
||||
if (!this.ascending) { layers.reverse(); }
|
||||
for( var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
var baseLayer = layer.isBaseLayer;
|
||||
|
||||
if (baseLayer || layer.displayInLayerSwitcher) {
|
||||
@@ -309,14 +314,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
baseLbl.style.marginTop = "3px";
|
||||
baseLbl.style.marginLeft = "3px";
|
||||
baseLbl.style.marginBottom = "3px";
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||
/*Event.observe(this.baseLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
|
||||
|
||||
this.dataLbl = document.createElement("div");
|
||||
@@ -324,15 +327,22 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.dataLbl.style.marginTop = "3px";
|
||||
this.dataLbl.style.marginLeft = "3px";
|
||||
this.dataLbl.style.marginBottom = "3px";
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
|
||||
this.dataLayersDiv = document.createElement("div");
|
||||
this.dataLayersDiv.style.paddingLeft = "10px";
|
||||
/*Event.observe(this.dataLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
|
||||
if (this.ascending) {
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
} else {
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
}
|
||||
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
Rico.Corner.round(this.div, {corners: "tl bl",
|
||||
|
||||
Reference in New Issue
Block a user