[Commits] r944 - in sandbox/camptocamp/geobretagne: lib/GeoExt/widgets tests tests/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Tue Jun 2 15:03:47 CEST 2009


Author: fredj
Date: 2009-06-02 15:03:47 +0200 (Tue, 02 Jun 2009)
New Revision: 944

Added:
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LayerOpacitySlider.html
Modified:
   sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js
   sandbox/camptocamp/geobretagne/tests/list-tests.html
Log:
opacity slider (see #75)

Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js	2009-06-02 12:41:29 UTC (rev 943)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LayerOpacitySlider.js	2009-06-02 13:03:47 UTC (rev 944)
@@ -1,18 +1,37 @@
-/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+/* 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 */
+ * pending approval */
 
 Ext.namespace("GeoExt");
 
 GeoExt.LayerOpacitySlider = Ext.extend(Ext.Slider, {
+    
+    /** api: config[layer]
+     *  ``OpenLayers.Layer`` or ``GeoExt.data.LayerRecord`` or ``GeoExt.tree.LayerNode``
+     */
     layer: null,
 
     minValue: 0,
     maxValue: 100,
 
+// FIXME: test this:
+//     /** private */
+//     constructor: function(config) {
+//         if (config.layer) {
+//             if (config.layer instanceof OpenLayers.Layer) {
+//                 this.layer = config.layer;
+//             } else if (config.layer instanceof GeoExt.data.LayerRecord || 
+//                        config.layer instanceof GeoExt.tree.LayerNode) {
+//                 this.layer = config.layer.layer;
+//             }
+//             delete config.layer;
+//         }
+//         GeoExt.LayerOpacitySlider.superclass.constructor.call(this, config);
+//     },
+
     initComponent: function() {
         // set the slider initial value
         if (this.layer && this.layer.opacity && this.layer.opacity != null) {

Added: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LayerOpacitySlider.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LayerOpacitySlider.html	                        (rev 0)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LayerOpacitySlider.html	2009-06-02 13:03:47 UTC (rev 944)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html debug="true">
+  <head>
+    <script type="text/javascript" src="../../../../../openlayers/lib/OpenLayers.js"></script>
+    <script type="text/javascript" src="../../../../../ext/adapter/ext/ext-base.js"></script>
+    <script type="text/javascript" src="../../../../../ext/ext-all-debug.js"></script>
+    <script type="text/javascript" src="../../../../lib/GeoExt.js"></script>
+
+    <script type="text/javascript">
+        function test_constructor(t) {
+            t.plan(0);            
+        }
+
+        function test_initalOpacity(t) {
+            t.plan(2);
+
+            var slider = new GeoExt.LayerOpacitySlider({
+                layer: new OpenLayers.Layer('foo')
+            });
+            t.ok(slider.getValue() == 100,
+                 "set the value to 100 if the layer has no opacity");
+
+            slider = new GeoExt.LayerOpacitySlider({
+                layer: new OpenLayers.Layer('foo', { opacity: 0.42})
+            });
+
+            t.ok(slider.getValue() == 42,
+                 "initial layer's opacity sets the slider value");
+        }
+
+    </script>
+  <body>
+  </body>
+</html>

Modified: sandbox/camptocamp/geobretagne/tests/list-tests.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/list-tests.html	2009-06-02 12:41:29 UTC (rev 943)
+++ sandbox/camptocamp/geobretagne/tests/list-tests.html	2009-06-02 13:03:47 UTC (rev 944)
@@ -9,6 +9,7 @@
   <li>lib/GeoExt/data/ProtocolProxy.html</li>
   <li>lib/GeoExt/data/WMSCapabilitiesReader.html</li>
   <li>lib/GeoExt/widgets/Action.html</li>
+  <li>lib/GeoExt/widgets/LayerOpacitySlider.html</li>
   <li>lib/GeoExt/widgets/MapPanel.html</li>
   <li>lib/GeoExt/widgets/Popup.html</li>
   <li>lib/GeoExt/widgets/form.html</li>



More information about the Commits mailing list