[Commits] r899 - sandbox/camptocamp/geobretagne/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Fri May 29 15:09:40 CEST 2009


Author: fredj
Date: 2009-05-29 15:09:40 +0200 (Fri, 29 May 2009)
New Revision: 899

Added:
   sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js
Log:
layer opacity slider, first draft: see http://www.geoext.org/trac/geoext/ticket/75

Added: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js	                        (rev 0)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js	2009-05-29 13:09:40 UTC (rev 899)
@@ -0,0 +1,39 @@
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ * 
+ * ¹ pending approval */
+
+Ext.namespace("GeoExt");
+
+GeoExt.LayerOpacitySlider = Ext.extend(Ext.Slider, {
+    layer: null,
+
+    minValue: 0,
+    maxValue: 100,
+
+    initComponent: function() {
+        // set the slider initial value
+        if (this.layer && this.layer.opacity && this.layer.opacity != null) {
+            this.value = parseInt(this.layer.opacity * 100);
+        } else {
+            // assume that the layer has no opacity
+            this.value = 100;
+        }
+        // FIXME: listen to layer events (opacitychanged, see: http://trac.openlayers.org/ticket/2112)
+        
+        GeoExt.LayerOpacitySlider.superclass.initComponent.call(this);
+        
+        this.on('change', this.opacityChanged, this);
+    },
+
+    // private
+    opacityChanged: function(slider, value) {
+        if (this.layer) {
+            this.layer.setOpacity(value / 100.0);
+        }
+    }
+});
+
+Ext.reg('gx_opacityslider', GeoExt.LayerOpacitySlider); 



More information about the Commits mailing list