[OpenLayers-Commits] r4786 - sandbox/tschaub/wfsv/lib/OpenLayers/Control
commits at openlayers.org
commits at openlayers.org
Wed Oct 3 12:28:12 EDT 2007
Author: tcoulter
Date: 2007-10-03 12:28:09 -0400 (Wed, 03 Oct 2007)
New Revision: 4786
Modified:
sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js
Log:
I little bit of code cleanup/documentation.
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js 2007-10-03 16:19:04 UTC (rev 4785)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Control/UndoRedo.js 2007-10-03 16:28:09 UTC (rev 4786)
@@ -38,35 +38,49 @@
*/
KEY_Y: 89,
+ /**
+ * APIMethod: onUndo
+ *
+ * Called after a successful undo, passing in the feature that was altered.
+ */
onUndo: function(){},
+
+ /**
+ * APIMethod: onRedo
+ *
+ * Called after a successful redo, passing in the feature that was altered.
+ */
onRedo: function(){},
+
+ /**
+ * APIMethod: onRemoveFeature
+ *
+ * Called when the Undo/Redo control is about to remove a feature from the layer. This call happens before the feature is removed.
+ */
onRemoveFeature: function(){},
- ACTION_UNDO: true,
- ACTION_REDO: false,
-
/**
- * Property: undoOrderStack
+ * Property: undoStack
* {<Array>}
*
- * A stack containing the order in which features should be undone. When registering an addition or modification for
- * a given feature, that feature set as "next" on the undo list (the top of the stack).
+ * A stack containing states of a feature that can be undone. Objects on this stack are hashes, of the form {feature: ..., :geometry ...}.
*/
undoStack: null,
+
+ /**
+ * Property: redoStack
+ * {<Array>}
+ *
+ * A stack containing states of a feature that can be redone. Objects on this stack are hashes, of the form {feature: ..., :geometry ...}.
+ */
redoStack: null,
/**
* Constructor: OpenLayers.Control.UndoRedo
- * Create a new Undo/Redo control.
- *
- * Parameters:
- * layer - {<OpenLayers.Layer.Vector>} Layer that contains features that
- * will be modified.
- * options - {Object} Optional object whose properties will be set on the
- * control.
+ * Create a new Undo/Redo control. Does not take any parameters.
*/
- initialize: function(layer, options) {
- OpenLayers.Control.prototype.initialize.apply(this, [options]);
+ initialize: function() {
+ OpenLayers.Control.prototype.initialize.apply(this, [{}]);
// Configure the keyboard handler
var keyboardOptions = {
@@ -83,7 +97,7 @@
/**
* Method: draw
- * Create handler.
+ * Activates the control.
*/
draw: function() {
this.activate();
@@ -104,14 +118,14 @@
this.undo();
}
else if (evt.ctrlKey == true && ((code == this.KEY_Y) || (code == this.KEY_Z && evt.shiftKey == true)))
-
{
this.redo();
}
},
/**
- * Method: undo
+ * APIMethod: undo
+ * Causes an the Undo/Redo control to process an undo.
*/
undo: function() {
var feature = this.moveBetweenStacks(this.undoStack, this.redoStack);
@@ -120,7 +134,8 @@
},
/**
- * Method: redo
+ * APIMethod: redo
+ * Causes an the Undo/Redo control to process an undo.
*/
redo: function() {
var feature = this.moveBetweenStacks(this.redoStack, this.undoStack);
@@ -130,7 +145,8 @@
/**
* Method: moveBetweenStacks
- * The "meat" of the Undo/Redo control -- it actually does the undoing/redoing.
+ * The "meat" of the Undo/Redo control -- it actually does the undoing/redoing. Although some idiosyncrasies exist, this function
+ * handles moving states from the undo stack to the redo stack, and vice versa. It also handles adding and removing features from the map.
*
* Parameters: TODO
*/
@@ -182,11 +198,8 @@
},
/**
- * Method: registerState
- * Function to register an undoable state with the Undo/Redo control. Note that the Undo/Redo control will never hold
- * the most recent modification for any given feature -- it doesn't need to know that information. Instead, it interprets
- * all registered states as *previous* states that a feature may be reverted back to. Put differently, all states registered
- * with the Undo/Redo control are past states, and never present states.
+ * APIMethod: registerState
+ * Function to register an undoable state with the Undo/Redo control.
*
* Parameters:
* {<OpenLayers.Feature.Vector>} Feature that is being registered.
More information about the Commits
mailing list