[Commits] r344 - apps/opengeo/geoexplorer/trunk/lib

commits at geoext.org commits at geoext.org
Fri Apr 3 17:05:44 CEST 2009


Author: dwins
Date: 2009-04-03 17:05:44 +0200 (Fri, 03 Apr 2009)
New Revision: 344

Modified:
   apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js
   apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js
   apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js
Log:
Add ND for the map tool controls


Modified: apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js	2009-04-03 14:04:57 UTC (rev 343)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js	2009-04-03 15:05:44 UTC (rev 344)
@@ -2,6 +2,37 @@
  * Copyright (c) 2008 The Open Planning Project
  */
 
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the menu entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * > var menu = new MapToolMenu({tools: [measure, select, zoomBox, draw]});
+ *
+ * This one provides a custom name and icon for one of the entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * > var menu = new MapToolMenu({tools: [{
+ * >         text: 'Find a distance', 
+ * >         tool: measure, 
+ * >         iconCls: 'x-icon-distance-finder'
+ * >     }, 
+ * >     select, 
+ * >     zoomBox, 
+ * >     draw
+ * > ]});
+ */
+
+/*
+ * Constructor: MapToolMenu
+ * Simply create a menu that manipulates OpenLayers map controls 
+ *
+ * Parameters: 
+ * config - {Object} Various options, see {Ext.menu.Menu}
+ *
+ * In addition to the normal [items] array, MapToolMenu recognizes a [tools] array. 
+ * This can be an array of OpenLayers Control objects, or of simple configuration 
+ * objects analogous to Ext Map entries.
+ */
 var MapToolMenu = function(options) { 
     options.items = options.items || [];
 

Modified: apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js	2009-04-03 14:04:57 UTC (rev 343)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js	2009-04-03 15:05:44 UTC (rev 344)
@@ -3,8 +3,45 @@
  * @requires MapToolMenu.js
  */
 
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the button and menu entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * : var menu = new MapToolSplitToggle({defaultTool: select, tools: [measure, select, zoomBox, draw]});
+ *
+ * This one provides a custom name and icon for one of the entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * : var menu = new MapToolSplitToggle({
+ * >     defaultTool: zoomBox,
+ * >     tools: [{
+ * >         text: 'Find a distance', 
+ * >         tool: measure, 
+ * >         iconCls: 'x-icon-distance-finder'
+ * >     }, 
+ * >     select, 
+ * >     zoomBox, 
+ * >     draw
+ * > ]});
+ */
+
+/**
+ * Constructor: MapToolSplitToggle
+ * Creates an Ext SplitButton suited to switching between multiple related OpenLayers Controls.
+ * The MapToolSplitToggle accepts an array of controls, which can be activated from the dropdown menu.
+ * The main button simply toggles the most recently used control.
+ *
+ * Parameters:
+ * config - {Object} the configuration options for this split toggle, see {Ext.SplitButton}. 
+ *
+ * In addition to the options accepted by Ext.SplitButton, the MapToolSplitToggle accepts:
+ * defaultTool - {OpenLayers.Control} the control which is to be activated if the button is toggled 
+ * before the user selects one from the drop-down menu.
+ * tools - {Array} the controls to display in the drop-down menu.  These may be simple Control objects,
+ * or Ext menu specifications with a tool parameter containing the control.  (see MapToolMenu)
+ */
 var MapToolSplitToggle = function(options) { 
-    this.lastActiveTool = options.defaultTool;
+    this.lastActiveTool = options.defaultTool || options.tools[0];
     this.tools = options.tools;
 
     Ext.applyIf(options, {
@@ -33,6 +70,19 @@
      */
     lastActiveTool: null,
 
+    /**
+     * Property: tools
+     * {Array} the OpenLayers tools from this component's configuration.
+     */
+    tools: null,
+    
+    /**
+     * Method: handleEvent
+     * Called when the main button is toggled, handled the (de)activation of the last active tool.
+     *
+     * Parameters:
+     * item - the component that triggered the event (ie, this SplitButton)
+     */
     handleEvent: function(item) {
         if (item.pressed) {
             this.lastActiveTool.activate();
@@ -41,6 +91,15 @@
         }
     }, 
 
+    /**
+     * Method: handleMenu
+     * Called when an item in the menu is selected.  All this does is update lastActiveTool;
+     * the menu should be a {MapToolMenu} to handle the control (de)activation.
+     *
+     * Parameters:
+     * item - the component that triggered the event (ie, the Menu item)
+     * evt  - the Ext selection event
+     */
     handleMenu: function(item, evt) {
         for (var i = 0, len = this.tools.length; i < len; i++) {
             var t = this.tools[i].tool || this.tools[i];
@@ -51,10 +110,20 @@
         }
     },
     
+    /**
+     * Method: findIconCls
+     * Determine the icon class for this split button, based on the {OpenLayers.Control} the
+     * button has been configured with.
+     */
     findIconCls: function() {
         return this.lastActiveTool.CLASS_NAME;
     },
 
+    /**
+     * Method: findLabel
+     * Determine the text label for this split button, based on the {OpenLayers.Control} the
+     * button has been configured with.
+     */
     findLabel: function() {
         return this.lastActiveTool.CLASS_NAME;
     }

Modified: apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js	2009-04-03 14:04:57 UTC (rev 343)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js	2009-04-03 15:05:44 UTC (rev 344)
@@ -2,6 +2,33 @@
  * Copyright (c) 2008 The Open Planning Project
  */
 
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the button.
+ * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
+ * : var btn = new MapToolToggle({tool: measure});
+ *
+ * This one provides a custom name and icon.
+ * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
+ * : var btn = new MapToolToggle({
+ * >         text: 'Find a distance', 
+ * >         tool: measure, 
+ * >         iconCls: 'x-icon-distance-finder'
+ * >     });
+ */
+
+/**
+ * Constructor: MapToolToggle
+ * Creates an Ext Button suited to activating and deactivating an {OpenLayers.Control}.
+ * The MapToolToggle accepts a control as part of its configuration.
+ *
+ * Parameters:
+ * config - {Object} the configuration options for this split toggle, see {Ext.Button}. 
+ *
+ * In addition to the options accepted by Ext.Button, the MapToolToggle accepts:
+ * tool - {OpenLayers.Control} the control which is to be manipulated by the button 
+ */
 var MapToolToggle = function(options) {
     this.mapTool = options.tool;
     Ext.applyIf(options, {
@@ -21,6 +48,13 @@
      */
     mapTool: null,
 
+    /**
+     * Method: handleEvent
+     * Called when the main button is toggled, handled the (de)activation of the last active tool.
+     *
+     * Parameters:
+     * item - the component that triggered the event (ie, this SplitButton)
+     */
     handleEvent: function(item) {
         if (item.pressed) {
             this.mapTool.activate();
@@ -29,10 +63,20 @@
         }
     }, 
     
+    /**
+     * Method: findIconCls
+     * Determine the icon class for this split button, based on the {OpenLayers.Control} the
+     * button has been configured with.
+     */
     findIconCls: function() {
         return this.mapTool.CLASS_NAME;
     },
 
+    /**
+     * Method: findLabel
+     * Determine the text label for this split button, based on the {OpenLayers.Control} the
+     * button has been configured with.
+     */
     findLabel: function() {
         return this.mapTool.CLASS_NAME;
     }



More information about the Commits mailing list