[Commits] r731 - sandbox/bartvde/legend/geoext/lib/GeoExt/widgets
commits at geoext.org
commits at geoext.org
Thu May 14 19:44:17 CEST 2009
Author: bartvde
Date: 2009-05-14 19:44:16 +0200 (Thu, 14 May 2009)
New Revision: 731
Modified:
sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
Log:
basic ascending support and change removeLegend implementation to actually remove instead of hide
Modified: sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js
===================================================================
--- sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js 2009-05-14 17:12:06 UTC (rev 730)
+++ sandbox/bartvde/legend/geoext/lib/GeoExt/widgets/LegendPanel.js 2009-05-14 17:44:16 UTC (rev 731)
@@ -20,6 +20,14 @@
*/
GeoExt.LegendPanel = Ext.extend(Ext.Panel, {
+ /** api: config[ascending]
+ * ``Boolean``
+ * If true the layers in the legend will show the bottom OpenLayers
+ * layer on top and the top OpenLayers layer on the bottom.
+ * If false, this is inverted. Default value is true.
+ */
+ ascending: true,
+
/** api: config[showTitle]
* ``Boolean``
* Whether or not to show the title of a layer. This can be a global
@@ -53,7 +61,7 @@
initComponent: function() {
GeoExt.LegendPanel.superclass.initComponent.call(this);
},
-
+
/** private: method[onRender]
* Private method called when the legend panel is being rendered.
*/
@@ -62,7 +70,13 @@
if(!this.layerStore) {
this.layerStore = GeoExt.MapPanel.guess().layers;
}
- this.layerStore.each(this.addLegend, this);
+ if (this.ascending) {
+ this.layerStore.each(this.addLegend, this);
+ } else {
+ for (var i=this.layerStore.data.items.length-1; i>=0; i--) {
+ this.addLegend(this.layerStore.data.items[i]);
+ }
+ }
this.layerStore.on({
"add": this.onStoreAdd,
"remove": this.onStoreRemove,
@@ -106,8 +120,11 @@
* store to remove.
*/
removeLegend: function(record) {
- this.getComponent(record.get('layer').id).hide();
- this.doLayout();
+ var legend = this.getComponent(record.get('layer').id);
+ if (legend) {
+ this.remove(legend, false);
+ this.doLayout();
+ }
},
/** private: method[addLegend]
More information about the Commits
mailing list